From 1b788c0a46d3e6695fb60fa939f93f563192879e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 26 Jul 2017 19:04:39 -0700 Subject: [PATCH] Comment and clean up HistoryTableModel code. --- .../abacus/window/HistoryTableModel.java | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/org/nwapw/abacus/window/HistoryTableModel.java b/src/org/nwapw/abacus/window/HistoryTableModel.java index 934e699..f488faf 100644 --- a/src/org/nwapw/abacus/window/HistoryTableModel.java +++ b/src/org/nwapw/abacus/window/HistoryTableModel.java @@ -7,20 +7,34 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; import java.util.ArrayList; +/** + * A table model to store data about the history of inputs + * in the calculator. + */ public class HistoryTableModel extends AbstractTableModel { + /** + * Static array used to get the column names. + */ public static final String[] COLUMN_NAMES = { "Input", "Parsed Input", "Output" }; + /** + * Static array used to get the class of each column. + */ public static final Class[] CLASS_TYPES = { String.class, TreeNode.class, String.class }; + /** + * Class used specifically to hold data about + * the previous entries into the calculator. + */ public static class HistoryEntry { public String input; public TreeNode parsedInput; @@ -40,17 +54,27 @@ public class HistoryTableModel extends AbstractTableModel { } } + /** + * The list of entries. + */ ArrayList entries; + /** + * Creates a new empty history table model + */ public HistoryTableModel() { entries = new ArrayList<>(); } + /** + * Adds an entry to the model. + * @param entry the entry to add. + */ public void addEntry(HistoryEntry entry){ entries.add(entry); } - @Override + @Override public int getRowCount() { return entries.size(); } @@ -80,18 +104,4 @@ public class HistoryTableModel extends AbstractTableModel { 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) { - - } }