01: package abbot.editor;
02:
03: import javax.swing.ActionMap;
04: import javax.swing.table.AbstractTableModel;
05: import abbot.i18n.Strings;
06:
07: public class ActionMapModel extends AbstractTableModel {
08:
09: public static ActionMapModel EMPTY = new ActionMapModel() {
10: public int getRowCount() {
11: return 1;
12: }
13:
14: public Object getValueAt(int row, int col) {
15: return col == 0 ? Strings.get("actionmap.unavailable") : "";
16: }
17: };
18:
19: private static final String[] COLUMN_NAMES = {
20: Strings.get("actionmap.key"),
21: Strings.get("actionmap.value"), };
22:
23: private ActionMap map;
24:
25: public ActionMapModel() {
26: this (new ActionMap());
27: }
28:
29: public ActionMapModel(ActionMap map) {
30: this .map = map;
31: }
32:
33: public String getColumnName(int col) {
34: return COLUMN_NAMES[col];
35: }
36:
37: public int getRowCount() {
38: Object[] keys = map.allKeys();
39: return keys == null ? 0 : keys.length;
40: }
41:
42: public int getColumnCount() {
43: return 2;
44: }
45:
46: public Object getValueAt(int row, int col) {
47: Object key = map.allKeys()[row];
48: return col == 0 ? key : map.get(key);
49: }
50:
51: public boolean isCellEditable(int row, int col) {
52: return false;
53: }
54: }
|