1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-24 08:12:39 -08:00

Comment and clean up HistoryTableModel code.

This commit is contained in:
Danila Fedorin 2017-07-26 19:04:39 -07:00
parent d54ec9e8fa
commit 1b788c0a46

View File

@ -7,20 +7,34 @@ import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import java.util.ArrayList; import java.util.ArrayList;
/**
* A table model to store data about the history of inputs
* in the calculator.
*/
public class HistoryTableModel extends AbstractTableModel { public class HistoryTableModel extends AbstractTableModel {
/**
* Static array used to get the column names.
*/
public static final String[] COLUMN_NAMES = { public static final String[] COLUMN_NAMES = {
"Input", "Input",
"Parsed Input", "Parsed Input",
"Output" "Output"
}; };
/**
* Static array used to get the class of each column.
*/
public static final Class[] CLASS_TYPES = { public static final Class[] CLASS_TYPES = {
String.class, String.class,
TreeNode.class, TreeNode.class,
String.class String.class
}; };
/**
* Class used specifically to hold data about
* the previous entries into the calculator.
*/
public static class HistoryEntry { public static class HistoryEntry {
public String input; public String input;
public TreeNode parsedInput; public TreeNode parsedInput;
@ -40,12 +54,22 @@ public class HistoryTableModel extends AbstractTableModel {
} }
} }
/**
* The list of entries.
*/
ArrayList<HistoryEntry> entries; ArrayList<HistoryEntry> entries;
/**
* Creates a new empty history table model
*/
public HistoryTableModel() { public HistoryTableModel() {
entries = new ArrayList<>(); entries = new ArrayList<>();
} }
/**
* Adds an entry to the model.
* @param entry the entry to add.
*/
public void addEntry(HistoryEntry entry){ public void addEntry(HistoryEntry entry){
entries.add(entry); entries.add(entry);
} }
@ -80,18 +104,4 @@ public class HistoryTableModel extends AbstractTableModel {
return entries.get(rowIndex).nthValue(columnIndex); return entries.get(rowIndex).nthValue(columnIndex);
} }
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
return;
}
@Override
public void addTableModelListener(TableModelListener l) {
}
@Override
public void removeTableModelListener(TableModelListener l) {
}
} }