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 * DbProxyModel.java
26 *
27 * The underlying model for the DbProxy Table
28 *****************************************************************************/
29
30 package zeus.generator.code;
31
32 import java.util.*;
33 import javax.swing.table.*;
34 import javax.swing.event.*;
35
36 import zeus.util.*;
37
38
39 public class DbProxyModel extends UtilityModel {
40
41 static final int NAME = 0;
42 static final int HOST = 1;
43 static final int SERVER_FILE = 2;
44 static final int PATH = 3;
45 static final int HAS_GUI = 4;
46 static final int EXTERNAL = 5;
47
48 protected static final String[] columnNames = {
49 "Name", "Host", "DNS file", "Proxy classpath",
50 "Create GUI?", "External Program"
51 };
52
53 protected Vector data = new Vector();
54 protected GenerationPlan genplan;
55
56 public DbProxyModel(GenerationPlan genplan) {
57 this.genplan = genplan;
58 genplan.addChangeListener(this);
59 refresh();
60 }
61
62 public void addNewRow() {
63 genplan.createDbProxy();
64 }
65 public void removeRows(int[] rows) {
66 for(int i = 0; i < rows.length; i++ ) {
67 DbProxyInfo info = (DbProxyInfo)data.elementAt(rows[i]-i);
68 genplan.removeDbProxy(info.id);
69 }
70 }
71
72 protected void refresh() {
73 data.removeAllElements();
74 DbProxyInfo[] info = genplan.getDbProxys();
75 for(int i = 0; i < info.length; i++ )
76 data.addElement(info[i]);
77 fireTableDataChanged();
78 }
79
80 public int getColumnCount() { return columnNames.length - 2; }
81 public int getRowCount() { return data.size(); }
82 public String getColumnName(int col) { return columnNames[col]; }
83
84 public boolean isCellEditable(int row, int col) { return true; }
85
86 public Object getValueAt(int row, int column) {
87 DbProxyInfo info = (DbProxyInfo)data.elementAt(row);
88 switch(column) {
89 case NAME:
90 return info.name;
91
92 case HOST:
93 return info.host;
94
95 case HAS_GUI:
96 return new Boolean(info.has_gui);
97
98 case EXTERNAL:
99 return info.zeus_external;
100
101 case PATH:
102 return info.path;
103
104 case SERVER_FILE:
105 return info.dns_file;
106 }
107 return null;
108 }
109
110 public void setValueAt(Object aValue, int row, int column) {
111 DbProxyInfo info = (DbProxyInfo)data.elementAt(row);
112 switch(column) {
113 case NAME:
114 info.name = updateString(info.name,aValue,false);
115 break;
116
117 case HOST:
118 info.host = updateString(info.host,aValue);
119 break;
120
121 case HAS_GUI:
122 info.has_gui = updateBoolean(info.has_gui,aValue);
123 break;
124
125 case EXTERNAL:
126 info.zeus_external = updateString(info.zeus_external,aValue);
127 break;
128
129 case PATH:
130 info.path = updateString(info.path,aValue);
131 break;
132
133 case SERVER_FILE:
134 info.dns_file = updateString(info.dns_file,aValue);
135 break;
136 }
137 if ( changed ) genplan.setDbProxy(info);
138 }
139 }