|
1
|
|
package abbot.editor;
|
|
2
|
|
|
|
3
|
|
import javax.swing.InputMap;
|
|
4
|
|
import javax.swing.KeyStroke;
|
|
5
|
|
import javax.swing.table.AbstractTableModel;
|
|
6
|
|
import abbot.i18n.Strings;
|
|
7
|
|
|
|
8
|
|
public class InputMapModel extends AbstractTableModel {
|
|
9
|
|
|
|
10
|
|
public static InputMapModel EMPTY = new InputMapModel() {
|
|
11
|
28
|
public int getRowCount() { return 1; }
|
|
12
|
0
|
public Object getValueAt(int row, int col) {
|
|
13
|
0
|
return col == 0 ? Strings.get("inputmap.unavailable") : "";
|
|
14
|
|
}
|
|
15
|
|
};
|
|
16
|
|
|
|
17
|
|
private static final String[] COLUMN_NAMES = {
|
|
18
|
|
Strings.get("inputmap.key"),
|
|
19
|
|
Strings.get("inputmap.value"),
|
|
20
|
|
};
|
|
21
|
|
|
|
22
|
|
private InputMap map;
|
|
23
|
|
|
|
24
|
2
|
public InputMapModel() {
|
|
25
|
2
|
this(new InputMap());
|
|
26
|
|
}
|
|
27
|
|
|
|
28
|
4
|
public InputMapModel(InputMap map) {
|
|
29
|
4
|
this.map = map;
|
|
30
|
|
}
|
|
31
|
|
|
|
32
|
14
|
public String getColumnName(int col) { return COLUMN_NAMES[col]; }
|
|
33
|
0
|
public int getRowCount() {
|
|
34
|
0
|
KeyStroke[] keys = map.allKeys();
|
|
35
|
0
|
return keys == null ? 0 : keys.length;
|
|
36
|
|
}
|
|
37
|
21
|
public int getColumnCount() { return 2; }
|
|
38
|
0
|
public Object getValueAt(int row, int col) {
|
|
39
|
0
|
KeyStroke key = map.allKeys()[row];
|
|
40
|
0
|
return col == 0 ? key : map.get(key);
|
|
41
|
|
}
|
|
42
|
0
|
public boolean isCellEditable(int row, int col) { return false; }
|
|
43
|
|
}
|
|
44
|
|
|