blob: 874abaae2093decf5ca160c1e8dee25919d7ee53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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();
}
}
|