01: package com.opensymphony.workflow.designer.model;
02:
03: import java.util.*;
04: import com.opensymphony.workflow.designer.ResourceManager;
05:
06: /**
07: * @author Andrea Capitani (a.capitani@leonardomultimedia.it)
08: * Date: Nov 16, 2004
09: * Time: 16:56:16 PM
10: */
11: public class AttributesTableModel extends MapTableModel {
12: private String[] header = new String[] {
13: ResourceManager.getString("name"),
14: ResourceManager.getString("value") };
15:
16: public AttributesTableModel() {
17: }
18:
19: public boolean isCellEditable(int rowIndex, int columnIndex) {
20: return false;
21: }
22:
23: public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
24: String sKey = getRowAttributeKey(rowIndex);
25: if (sKey.length() > 0) {
26: switch (columnIndex) {
27: case 0: // Name (Key)
28: break;
29: case 1:
30: map.put(sKey, aValue);
31: break;
32: default:
33: break;
34: }
35: }
36: }
37:
38: public int getColumnCount() {
39: return header.length;
40: }
41:
42: public String getColumnName(int column) {
43: return header[column];
44: }
45:
46: public Class getColumnClass(int columnIndex) {
47: return String.class;
48: }
49:
50: public Object getValueAt(int rowIndex, int columnIndex) {
51: String sKey = getRowAttributeKey(rowIndex);
52: if (sKey.length() > 0) {
53: switch (columnIndex) {
54: case 0: // Name (Key)
55: return sKey;
56: case 1: // Value
57: String sValue = (String) map.get(sKey);
58: if (sValue != null)
59: return sValue;
60: default:
61: return "";
62: }
63: }
64: return "";
65: }
66:
67: private String getRowAttributeKey(int rowIndex) {
68: int counter = 0;
69: Iterator it = map.keySet().iterator();
70: while (it.hasNext()) {
71: String sKey = (String) it.next();
72: if (counter == rowIndex)
73: return sKey;
74: counter++;
75: }
76: return "";
77: }
78: }
|