summaryrefslogtreecommitdiff
path: root/sources/prefs/editors/VSEditorTable.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-21 11:25:06 +0000
committerPaul Buetow <paul@buetow.org>2008-05-21 11:25:06 +0000
commit47f50635ca3fa3665f2b0bfb3cc29b2e9b88e88e (patch)
tree8539c14942ff620b0ee11d861b90e8026445577b /sources/prefs/editors/VSEditorTable.java
parent986ba9e27e6a3f6bced32d675246c85448b83f4f (diff)
Initial JTable editor.
Diffstat (limited to 'sources/prefs/editors/VSEditorTable.java')
-rw-r--r--sources/prefs/editors/VSEditorTable.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java
new file mode 100644
index 0000000..874abaa
--- /dev/null
+++ b/sources/prefs/editors/VSEditorTable.java
@@ -0,0 +1,85 @@
+package prefs.editors;
+
+import java.util.*;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.*;
+
+import prefs.*;
+
+public class VSEditorTable extends JTable {
+ private VSPrefs prefs;
+ private ArrayList<VSNode> nodes;
+ private VSEditorTableModel model;
+
+ private class VSNode {
+ private String key;
+ private Component comp;
+
+ public VSNode(String key, Component comp) {
+ this.key = key;
+ this.comp = comp;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Component getComponent() {
+ return comp;
+ }
+ }
+
+ private class VSEditorTableModel extends AbstractTableModel {
+ public VSEditorTableModel() {
+ }
+
+ public String getColumnName(int col) {
+ if (col == 0)
+ return prefs.getString("lang.variable");
+
+ return prefs.getString("lang.value");
+ }
+
+ public int getRowCount() {
+ return nodes.size();
+ }
+
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public Object getValueAt(int row, int col) {
+ VSNode node = nodes.get(row);
+
+ if (col == 0)
+ return node.getKey();
+ else
+ return node.getComponent();
+ }
+
+ public boolean isCellEditable(int row, int col) {
+ if (col == 0)
+ return false;
+
+ return true;
+ }
+
+ public void setValueAt(Object value, int row, int col) {
+ }
+ }
+
+ public VSEditorTable(VSPrefs prefs) {
+ this.prefs = prefs;
+ this.nodes = new ArrayList<VSNode>();
+ this.model = new VSEditorTableModel();
+ setModel(model);
+ }
+
+ public void addVariable(String key, Component comp) {
+ nodes.add(new VSNode(key, comp));
+ model.fireTableDataChanged();
+ }
+}