diff options
Diffstat (limited to 'sources/prefs/editors/VSEditorTable.java')
| -rw-r--r-- | sources/prefs/editors/VSEditorTable.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java index 27c422f..b641f33 100644 --- a/sources/prefs/editors/VSEditorTable.java +++ b/sources/prefs/editors/VSEditorTable.java @@ -1,3 +1,7 @@ +/* + * VS is (c) 2008 by Paul C. Buetow + * vs@dev.buetow.org + */ package prefs.editors; import java.util.*; @@ -9,58 +13,127 @@ import javax.swing.text.*; import prefs.*; +// TODO: Auto-generated Javadoc +/** + * The Class VSEditorTable. + */ public class VSEditorTable extends JTable { + + /** The Constant MIN_ROWS. */ private static final int MIN_ROWS = 20; + + /** The prefs. */ private VSPrefs prefs; + + /** The nodes. */ private ArrayList<VSNode> nodes; + + /** The model. */ private VSEditorTableModel model; + /** + * The Class VSNode. + */ private class VSNode { + + /** The key. */ private String key; + + /** The comp. */ private Component comp; + /** + * Instantiates a new vS node. + * + * @param key the key + */ public VSNode(String key) { this.key = key; } + /** + * Instantiates a new vS node. + * + * @param key the key + * @param comp the comp + */ public VSNode(String key, Component comp) { this.key = key; this.comp = comp; } + /** + * Gets the key. + * + * @return the key + */ public String getKey() { return key; } + /** + * Gets the component. + * + * @return the component + */ public Component getComponent() { return comp; } + /** + * Gets the renderer component. + * + * @return the renderer component + */ public Component getRendererComponent() { return comp; } + /** + * Checks if is separator. + * + * @return true, if is separator + */ public boolean isSeparator() { return comp == null; } } + /** + * The Class VSEditorTableModel. + */ private class VSEditorTableModel extends AbstractTableModel implements TableCellRenderer { + + /** + * Instantiates a new vS editor table model. + */ public VSEditorTableModel() { } + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#getColumnName(int) + */ public String getColumnName(int col) { return ""; } + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getRowCount() + */ public int getRowCount() { return nodes.size(); } + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getColumnCount() + */ public int getColumnCount() { return 2; } + /* (non-Javadoc) + * @see javax.swing.table.TableModel#getValueAt(int, int) + */ public Object getValueAt(int row, int col) { VSNode node = nodes.get(row); @@ -77,6 +150,9 @@ public class VSEditorTable extends JTable { return node.getComponent(); } + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int) + */ public boolean isCellEditable(int row, int col) { if (col == 0) return false; @@ -87,9 +163,15 @@ public class VSEditorTable extends JTable { return true; } + /* (non-Javadoc) + * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int) + */ public void setValueAt(Object value, int row, int col) { } + /* (non-Javadoc) + * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) + */ public Component getTableCellRendererComponent(JTable table, Object object, boolean isSelected, boolean hasFocus, int row, int col) { @@ -119,18 +201,32 @@ public class VSEditorTable extends JTable { } } + /** + * The Class VSTableCellEditor. + */ private class VSTableCellEditor extends AbstractCellEditor implements TableCellEditor { + /* (non-Javadoc) + * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int) + */ public Component getTableCellEditorComponent(JTable table, Object object, boolean isSelected, int row, int col) { return nodes.get(row).getComponent(); } + /* (non-Javadoc) + * @see javax.swing.CellEditor#getCellEditorValue() + */ public Object getCellEditorValue() { return new String(""); } } + /** + * Instantiates a new vS editor table. + * + * @param prefs the prefs + */ public VSEditorTable(VSPrefs prefs) { this.prefs = prefs; this.nodes = new ArrayList<VSNode>(); @@ -151,14 +247,28 @@ public class VSEditorTable extends JTable { col.sizeWidthToFit(); } + /** + * Adds the variable. + * + * @param key the key + * @param comp the comp + */ public void addVariable(String key, Component comp) { nodes.add(new VSNode(key, comp)); } + /** + * Adds the separator. + * + * @param text the text + */ public void addSeparator(String text) { nodes.add(new VSNode(text)); } + /** + * Fire table data changed. + */ public void fireTableDataChanged() { model.fireTableDataChanged(); } |
