1 |
ajm |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
tdb |
1.14 |
package uk.org.iscream.cms.conient; |
3 |
ajm |
1.1 |
|
4 |
|
|
//---IMPORTS--- |
5 |
ajm |
1.8 |
import java.awt.*; |
6 |
ajm |
1.3 |
import java.awt.event.*; |
7 |
|
|
import javax.swing.*; |
8 |
|
|
import javax.swing.border.*; |
9 |
ajm |
1.1 |
import java.util.Properties; |
10 |
ajm |
1.5 |
import java.util.StringTokenizer; |
11 |
ajm |
1.11 |
import java.util.Collections; |
12 |
|
|
import java.util.ArrayList; |
13 |
|
|
import java.util.Iterator; |
14 |
ajm |
1.1 |
|
15 |
|
|
/** |
16 |
|
|
* This provides a modal dialog from which the user |
17 |
|
|
* can reconfigure the conient client. |
18 |
|
|
* |
19 |
ajm |
1.9 |
* Look at the comments for the attributes of this class to see |
20 |
|
|
* what configuration options this class deals with. |
21 |
|
|
* |
22 |
|
|
* It then writes back the configuration to the loaded configuration. |
23 |
|
|
* The user can then opt to save it. |
24 |
ajm |
1.1 |
* |
25 |
|
|
* |
26 |
|
|
* @author $Author: ajm4 $ |
27 |
tdb |
1.14 |
* @version $Id: ConfigurationDialog.java,v 1.13 2001/03/23 03:58:26 ajm4 Exp $ |
28 |
ajm |
1.1 |
*/ |
29 |
|
|
public class ConfigurationDialog extends JDialog { |
30 |
|
|
|
31 |
|
|
//---FINAL ATTRIBUTES--- |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
* The current CVS revision of this class |
35 |
|
|
*/ |
36 |
tdb |
1.14 |
public static final String REVISION = "$Revision: 1.13 $"; |
37 |
ajm |
1.1 |
|
38 |
|
|
//---STATIC METHODS--- |
39 |
|
|
|
40 |
|
|
//---CONSTRUCTORS--- |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* Constructs and shows the dialog for the user |
44 |
|
|
*/ |
45 |
ajm |
1.2 |
public ConfigurationDialog() { |
46 |
ajm |
1.3 |
super(Conient.getFrame(), "Configuration Options", true); |
47 |
ajm |
1.2 |
|
48 |
ajm |
1.3 |
// setup the buttoms |
49 |
|
|
JPanel buttonPanel = new JPanel(); |
50 |
|
|
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); |
51 |
|
|
JButton ok = new JButton("OK"); |
52 |
ajm |
1.4 |
ok.addActionListener(new ActionListener() { |
53 |
|
|
public void actionPerformed(ActionEvent e) { |
54 |
|
|
setNewSettingsAndClose(); |
55 |
|
|
} |
56 |
|
|
}); |
57 |
|
|
|
58 |
|
|
JButton cancel = new JButton("Cancel"); |
59 |
ajm |
1.3 |
cancel.addActionListener(new ActionListener() { |
60 |
|
|
public void actionPerformed(ActionEvent e) { |
61 |
|
|
dispose(); |
62 |
|
|
} |
63 |
|
|
}); |
64 |
|
|
buttonPanel.add(Box.createHorizontalGlue()); |
65 |
|
|
buttonPanel.add(ok); |
66 |
|
|
buttonPanel.add(cancel); |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
// setup the options panes |
70 |
ajm |
1.5 |
JTabbedPane center = new JTabbedPane(); |
71 |
|
|
//center.setLayout(new BoxLayout(center, BoxLayout.Y_AXIS)); |
72 |
ajm |
1.3 |
|
73 |
|
|
// client options |
74 |
ajm |
1.5 |
center.addTab("Client Options", createClientOptions()); |
75 |
ajm |
1.3 |
|
76 |
ajm |
1.11 |
// _server options |
77 |
ajm |
1.12 |
center.addTab("Server Options", createServerOptions()); |
78 |
ajm |
1.4 |
|
79 |
|
|
// firewall options |
80 |
ajm |
1.5 |
center.addTab("Firewall Options", createFirewallOptions()); |
81 |
ajm |
1.4 |
|
82 |
|
|
// data options |
83 |
ajm |
1.5 |
center.addTab("Data Options", createDataOptions()); |
84 |
ajm |
1.4 |
|
85 |
|
|
// display the current settings |
86 |
|
|
getCurrentSettings(); |
87 |
|
|
|
88 |
|
|
// set the window up |
89 |
|
|
getContentPane().add(buttonPanel, "South"); |
90 |
|
|
getContentPane().add(center, "Center"); |
91 |
|
|
pack(); |
92 |
|
|
setLocationRelativeTo(Conient.getFrame()); |
93 |
|
|
setResizable(false); |
94 |
|
|
setVisible(true); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
//---PUBLIC METHODS--- |
98 |
|
|
|
99 |
|
|
//---PRIVATE METHODS--- |
100 |
ajm |
1.5 |
|
101 |
ajm |
1.9 |
/** |
102 |
|
|
* creates a JPanel for the client options |
103 |
|
|
* |
104 |
|
|
* @return the build panel with the options |
105 |
|
|
*/ |
106 |
ajm |
1.4 |
private JPanel createClientOptions() { |
107 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
108 |
|
|
GridBagLayout gridbag2 = new GridBagLayout(); |
109 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
110 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
111 |
|
|
|
112 |
ajm |
1.4 |
JPanel clientPanel = new JPanel(); |
113 |
ajm |
1.8 |
clientPanel.setLayout(gridbag); |
114 |
ajm |
1.12 |
JLabel nameLabel = new JLabel("Client name:"); |
115 |
|
|
nameLabel.setHorizontalAlignment(JLabel.RIGHT); |
116 |
ajm |
1.11 |
_name = new JTextField(20); |
117 |
ajm |
1.12 |
JPanel nameBox = new JPanel(); |
118 |
|
|
nameBox.setLayout(new GridLayout(1,2)); |
119 |
|
|
nameBox.add(nameLabel); |
120 |
|
|
nameBox.add(_name); |
121 |
ajm |
1.8 |
|
122 |
|
|
c.gridy = 0; |
123 |
ajm |
1.12 |
gridbag.setConstraints(nameBox, c); |
124 |
|
|
clientPanel.add(nameBox); |
125 |
ajm |
1.5 |
|
126 |
|
|
JPanel lists = new JPanel(); |
127 |
ajm |
1.8 |
lists.setLayout(gridbag2); |
128 |
ajm |
1.5 |
|
129 |
ajm |
1.12 |
JPanel knownHostsPanel = new JPanel(); |
130 |
|
|
knownHostsPanel.setLayout(new BoxLayout(knownHostsPanel, BoxLayout.Y_AXIS)); |
131 |
ajm |
1.11 |
_hostDiscoveryMode = new JCheckBox("Discover new hosts from the server"); |
132 |
ajm |
1.12 |
knownHostsPanel.add(_hostDiscoveryMode); |
133 |
|
|
knownHostsPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Known Hosts ")); |
134 |
ajm |
1.11 |
_knownHosts = new JList(); |
135 |
|
|
_knownHosts.setVisibleRowCount(10); |
136 |
ajm |
1.12 |
JScrollPane knownHostsScrollPane = new JScrollPane(_knownHosts); |
137 |
|
|
knownHostsPanel.add(knownHostsScrollPane); |
138 |
|
|
JLabel newHostLabel = new JLabel("New host:"); |
139 |
|
|
newHostLabel.setHorizontalAlignment(JLabel.RIGHT); |
140 |
ajm |
1.11 |
_newHost = new JTextField(20); |
141 |
ajm |
1.8 |
|
142 |
ajm |
1.12 |
JButton newHostButton = new JButton("Add Host"); |
143 |
|
|
newHostButton.addActionListener(new ActionListener() { |
144 |
ajm |
1.6 |
public void actionPerformed(ActionEvent e) { |
145 |
ajm |
1.11 |
_knownHostsData.add(_newHost.getText()); |
146 |
|
|
_newHost.setText(""); |
147 |
|
|
setListDisplay(); |
148 |
ajm |
1.6 |
} |
149 |
|
|
}); |
150 |
ajm |
1.8 |
JButton removeHostButton = new JButton("Remove Host(s)"); |
151 |
|
|
removeHostButton.addActionListener(new ActionListener() { |
152 |
|
|
public void actionPerformed(ActionEvent e) { |
153 |
ajm |
1.11 |
Object[] selected = _knownHosts.getSelectedValues(); |
154 |
ajm |
1.8 |
for(int x = 0; x < selected.length; x++) { |
155 |
ajm |
1.11 |
_knownHostsData.remove(_knownHostsData.indexOf(selected[x])); |
156 |
|
|
setListDisplay(); |
157 |
ajm |
1.8 |
} |
158 |
|
|
} |
159 |
|
|
}); |
160 |
ajm |
1.12 |
JPanel newHostBox = new JPanel(); |
161 |
|
|
newHostBox.setLayout(new GridLayout(1,3)); |
162 |
|
|
newHostBox.add(newHostLabel); |
163 |
|
|
newHostBox.add(_newHost); |
164 |
ajm |
1.8 |
|
165 |
|
|
JPanel buttonPanel = new JPanel(); |
166 |
ajm |
1.13 |
buttonPanel.add(newHostButton); |
167 |
ajm |
1.8 |
buttonPanel.add(removeHostButton); |
168 |
ajm |
1.12 |
knownHostsPanel.add(buttonPanel); |
169 |
ajm |
1.13 |
knownHostsPanel.add(newHostBox); |
170 |
ajm |
1.8 |
|
171 |
|
|
|
172 |
|
|
c.gridy = 0; |
173 |
|
|
c.gridx = 0; |
174 |
ajm |
1.12 |
gridbag.setConstraints(knownHostsPanel, c); |
175 |
|
|
lists.add(knownHostsPanel); |
176 |
ajm |
1.5 |
|
177 |
|
|
|
178 |
|
|
JPanel addRemoveBox = new JPanel(); |
179 |
|
|
addRemoveBox.setLayout(new BoxLayout(addRemoveBox, BoxLayout.Y_AXIS)); |
180 |
|
|
addRemoveBox.add(Box.createGlue()); |
181 |
|
|
JButton add = new JButton(">>>"); |
182 |
ajm |
1.6 |
add.addActionListener(new ActionListener() { |
183 |
|
|
public void actionPerformed(ActionEvent e) { |
184 |
ajm |
1.11 |
Object[] selected = _knownHosts.getSelectedValues(); |
185 |
ajm |
1.6 |
for(int x = 0; x < selected.length; x++) { |
186 |
ajm |
1.11 |
_knownHostsData.remove(_knownHostsData.indexOf(selected[x])); |
187 |
|
|
_hostListData.add(selected[x]); |
188 |
|
|
setListDisplay(); |
189 |
ajm |
1.6 |
} |
190 |
|
|
} |
191 |
|
|
}); |
192 |
|
|
|
193 |
ajm |
1.5 |
addRemoveBox.add(add); |
194 |
|
|
addRemoveBox.add(Box.createGlue()); |
195 |
|
|
JButton remove = new JButton("<<<"); |
196 |
ajm |
1.6 |
remove.addActionListener(new ActionListener() { |
197 |
|
|
public void actionPerformed(ActionEvent e) { |
198 |
ajm |
1.11 |
Object[] selected = _hostList.getSelectedValues(); |
199 |
ajm |
1.6 |
for(int x = 0; x < selected.length; x++) { |
200 |
ajm |
1.11 |
_hostListData.remove(_hostListData.indexOf(selected[x])); |
201 |
|
|
_knownHostsData.add(selected[x]); |
202 |
|
|
setListDisplay(); |
203 |
ajm |
1.6 |
} |
204 |
|
|
} |
205 |
|
|
}); |
206 |
ajm |
1.5 |
addRemoveBox.add(remove); |
207 |
|
|
addRemoveBox.add(Box.createGlue()); |
208 |
ajm |
1.8 |
|
209 |
|
|
c.gridy = 0; |
210 |
|
|
c.gridx = 1; |
211 |
|
|
gridbag.setConstraints(addRemoveBox, c); |
212 |
ajm |
1.5 |
lists.add(addRemoveBox); |
213 |
|
|
|
214 |
ajm |
1.12 |
JPanel hostListPanel = new JPanel(); |
215 |
|
|
hostListPanel.setLayout(new BoxLayout(hostListPanel, BoxLayout.Y_AXIS)); |
216 |
ajm |
1.11 |
_useHostList = new JCheckBox("Only monitor hosts in this list"); |
217 |
ajm |
1.12 |
hostListPanel.add(_useHostList); |
218 |
|
|
hostListPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Hosts To Monitor ")); |
219 |
ajm |
1.11 |
_hostList = new JList(); |
220 |
|
|
_hostList.setVisibleRowCount(10); |
221 |
ajm |
1.12 |
JScrollPane hostListScrollPane = new JScrollPane(_hostList); |
222 |
|
|
hostListPanel.add(hostListScrollPane); |
223 |
ajm |
1.8 |
|
224 |
|
|
c.gridy = 0; |
225 |
|
|
c.gridx = 2; |
226 |
ajm |
1.12 |
gridbag.setConstraints(hostListPanel, c); |
227 |
|
|
lists.add(hostListPanel); |
228 |
ajm |
1.5 |
|
229 |
ajm |
1.8 |
c.gridy = 1; |
230 |
|
|
c.gridx = 0; |
231 |
|
|
gridbag.setConstraints(lists, c); |
232 |
ajm |
1.5 |
clientPanel.add(lists); |
233 |
ajm |
1.4 |
return clientPanel; |
234 |
|
|
} |
235 |
ajm |
1.9 |
|
236 |
|
|
/** |
237 |
|
|
* creates a JPanel for the server options |
238 |
|
|
* |
239 |
|
|
* @return the build panel with the options |
240 |
|
|
*/ |
241 |
ajm |
1.13 |
private JPanel createServerOptions() { |
242 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
243 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
244 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
245 |
ajm |
1.12 |
JPanel serverPanel = new JPanel(); |
246 |
|
|
serverPanel.setLayout(gridbag); |
247 |
ajm |
1.11 |
_connectControl = new JCheckBox("Automatically connect the control channel"); |
248 |
ajm |
1.9 |
c.gridy = 0; |
249 |
ajm |
1.11 |
gridbag.setConstraints(_connectControl, c); |
250 |
ajm |
1.12 |
serverPanel.add(_connectControl); |
251 |
ajm |
1.11 |
_connectData = new JCheckBox("Automatically connect the data channel"); |
252 |
ajm |
1.9 |
c.gridy = 1; |
253 |
ajm |
1.11 |
gridbag.setConstraints(_connectData, c); |
254 |
ajm |
1.12 |
serverPanel.add(_connectData); |
255 |
|
|
JLabel serverLabel = new JLabel("i-scream server:"); |
256 |
|
|
serverLabel.setHorizontalAlignment(JLabel.RIGHT); |
257 |
ajm |
1.11 |
_server = new JTextField(20); |
258 |
ajm |
1.12 |
JPanel serverBox = new JPanel(); |
259 |
|
|
serverBox.setLayout(new GridLayout(1,2)); |
260 |
|
|
serverBox.add(serverLabel); |
261 |
|
|
serverBox.add(_server); |
262 |
ajm |
1.9 |
c.gridy = 2; |
263 |
ajm |
1.12 |
gridbag.setConstraints(serverBox, c); |
264 |
|
|
serverPanel.add(serverBox); |
265 |
|
|
JLabel portLabel = new JLabel("Client interface port:"); |
266 |
|
|
portLabel.setHorizontalAlignment(JLabel.RIGHT); |
267 |
ajm |
1.11 |
_port = new JTextField(4); |
268 |
ajm |
1.12 |
JPanel portBox = new JPanel(); |
269 |
|
|
portBox.setLayout(new GridLayout(1,2)); |
270 |
|
|
portBox.add(portLabel); |
271 |
|
|
portBox.add(_port); |
272 |
ajm |
1.9 |
c.gridy = 3; |
273 |
ajm |
1.12 |
gridbag.setConstraints(portBox, c); |
274 |
|
|
serverPanel.add(portBox); |
275 |
|
|
return serverPanel; |
276 |
ajm |
1.4 |
} |
277 |
ajm |
1.3 |
|
278 |
ajm |
1.9 |
/** |
279 |
|
|
* creates a JPanel for the firewall options |
280 |
|
|
* |
281 |
|
|
* @return the build panel with the options |
282 |
|
|
*/ |
283 |
ajm |
1.4 |
private JPanel createFirewallOptions() { |
284 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
285 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
286 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
287 |
ajm |
1.3 |
JPanel firewallPanel = new JPanel(); |
288 |
ajm |
1.8 |
firewallPanel.setLayout(gridbag); |
289 |
ajm |
1.4 |
|
290 |
ajm |
1.11 |
_useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
291 |
ajm |
1.8 |
c.gridy = 0; |
292 |
ajm |
1.11 |
gridbag.setConstraints(_useFirewall, c); |
293 |
|
|
firewallPanel.add(_useFirewall); |
294 |
ajm |
1.8 |
|
295 |
ajm |
1.3 |
JLabel commandLabel = new JLabel("Firewall command:"); |
296 |
ajm |
1.4 |
commandLabel.setHorizontalAlignment(JLabel.RIGHT); |
297 |
ajm |
1.11 |
_firewallCommand = new JTextField(20); |
298 |
ajm |
1.4 |
JPanel commandBox = new JPanel(); |
299 |
|
|
commandBox.setLayout(new GridLayout(1,2)); |
300 |
ajm |
1.3 |
commandBox.add(commandLabel); |
301 |
ajm |
1.11 |
commandBox.add(_firewallCommand); |
302 |
ajm |
1.5 |
|
303 |
ajm |
1.8 |
c.gridy = 1; |
304 |
|
|
gridbag.setConstraints(commandBox, c); |
305 |
ajm |
1.3 |
firewallPanel.add(commandBox); |
306 |
|
|
|
307 |
|
|
JLabel waitLabel = new JLabel("Firewall wait time:"); |
308 |
ajm |
1.4 |
waitLabel.setHorizontalAlignment(JLabel.RIGHT); |
309 |
ajm |
1.11 |
_firewallWait = new JTextField(2); |
310 |
ajm |
1.4 |
JPanel waitBox = new JPanel(); |
311 |
|
|
waitBox.setLayout(new GridLayout(1,2)); |
312 |
ajm |
1.3 |
waitBox.add(waitLabel); |
313 |
ajm |
1.11 |
waitBox.add(_firewallWait); |
314 |
ajm |
1.8 |
|
315 |
|
|
c.gridy = 2; |
316 |
|
|
gridbag.setConstraints(waitBox, c); |
317 |
ajm |
1.3 |
firewallPanel.add(waitBox); |
318 |
|
|
|
319 |
ajm |
1.11 |
JLabel fServerLabel = new JLabel("Firewall server:"); |
320 |
|
|
fServerLabel.setHorizontalAlignment(JLabel.RIGHT); |
321 |
|
|
_firewallServer = new JTextField(20); |
322 |
|
|
JPanel fServerBox = new JPanel(); |
323 |
|
|
fServerBox.setLayout(new GridLayout(1,2)); |
324 |
|
|
fServerBox.add(fServerLabel); |
325 |
|
|
fServerBox.add(_firewallServer); |
326 |
ajm |
1.5 |
|
327 |
ajm |
1.8 |
c.gridy = 3; |
328 |
ajm |
1.11 |
gridbag.setConstraints(fServerBox, c); |
329 |
|
|
firewallPanel.add(fServerBox); |
330 |
ajm |
1.8 |
|
331 |
ajm |
1.4 |
return firewallPanel; |
332 |
|
|
} |
333 |
|
|
|
334 |
ajm |
1.9 |
/** |
335 |
|
|
* creates a JPanel for the data options |
336 |
|
|
* |
337 |
|
|
* @return the build panel with the options |
338 |
|
|
*/ |
339 |
ajm |
1.4 |
private JPanel createDataOptions() { |
340 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
341 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
342 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
343 |
ajm |
1.4 |
JPanel dataPanel = new JPanel(); |
344 |
ajm |
1.8 |
dataPanel.setLayout(gridbag); |
345 |
ajm |
1.11 |
_displayQueue = new JCheckBox("Display server queue information"); |
346 |
ajm |
1.8 |
c.gridy = 0; |
347 |
ajm |
1.11 |
gridbag.setConstraints(_displayQueue, c); |
348 |
|
|
dataPanel.add(_displayQueue); |
349 |
|
|
_displayExtra = new JCheckBox("Display extra data found in packets"); |
350 |
ajm |
1.8 |
c.gridy = 1; |
351 |
ajm |
1.11 |
gridbag.setConstraints(_displayExtra, c); |
352 |
|
|
dataPanel.add(_displayExtra); |
353 |
|
|
_packetDump = new JCheckBox("Dump raw packet data to the console"); |
354 |
ajm |
1.8 |
c.gridy = 2; |
355 |
ajm |
1.11 |
gridbag.setConstraints(_packetDump, c); |
356 |
|
|
dataPanel.add(_packetDump); |
357 |
ajm |
1.10 |
|
358 |
ajm |
1.12 |
JLabel queueLimitLabel = new JLabel("Maximum data queue size:"); |
359 |
|
|
queueLimitLabel.setHorizontalAlignment(JLabel.RIGHT); |
360 |
ajm |
1.11 |
_queueLimit = new JTextField(4); |
361 |
ajm |
1.10 |
JPanel queueBox = new JPanel(); |
362 |
|
|
queueBox.setLayout(new GridLayout(1,2)); |
363 |
ajm |
1.12 |
queueBox.add(queueLimitLabel); |
364 |
ajm |
1.11 |
queueBox.add(_queueLimit); |
365 |
ajm |
1.10 |
c.gridy = 3; |
366 |
|
|
gridbag.setConstraints(queueBox, c); |
367 |
|
|
dataPanel.add(queueBox); |
368 |
ajm |
1.4 |
return dataPanel; |
369 |
|
|
} |
370 |
|
|
|
371 |
ajm |
1.9 |
/** |
372 |
|
|
* Reads in the current settings from the loaded configuration |
373 |
|
|
*/ |
374 |
ajm |
1.4 |
private void getCurrentSettings() { |
375 |
ajm |
1.11 |
_name.setText(_config.getProperty("clientname")); |
376 |
|
|
_server.setText(_config.getProperty("control.server")); |
377 |
|
|
_port.setText(_config.getProperty("control.port")); |
378 |
|
|
_connectControl.setSelected(_config.getProperty("control.onstartconnect").equals("1")); |
379 |
|
|
_connectData.setSelected(_config.getProperty("data.onstartconnect").equals("1")); |
380 |
|
|
_firewallCommand.setText(_config.getProperty("firewall.command")); |
381 |
|
|
_firewallCommand.moveCaretPosition(0); |
382 |
|
|
_firewallWait.setText(_config.getProperty("firewall.commandwait")); |
383 |
|
|
_firewallServer.setText(_config.getProperty("firewall.server")); |
384 |
|
|
_displayQueue.setSelected(_config.getProperty("displayQueueInformation").equals("1")); |
385 |
|
|
_displayExtra.setSelected(_config.getProperty("displayExtraData").equals("1")); |
386 |
|
|
_packetDump.setSelected(_config.getProperty("packetDump").equals("1")); |
387 |
|
|
_useFirewall.setSelected(_config.getProperty("useFirewall").equals("1")); |
388 |
|
|
_hostDiscoveryMode.setSelected(_config.getProperty("hostDiscoveryMode").equals("1")); |
389 |
|
|
_useHostList.setSelected(_config.getProperty("useHostList").equals("1")); |
390 |
|
|
_queueLimit.setText(_config.getProperty("dataQueueSize")); |
391 |
ajm |
1.5 |
prepareLists(); |
392 |
|
|
} |
393 |
|
|
|
394 |
ajm |
1.9 |
/** |
395 |
|
|
* Displays the host lists in the host windows |
396 |
ajm |
1.11 |
* in alphabetical order |
397 |
ajm |
1.9 |
*/ |
398 |
ajm |
1.5 |
private void prepareLists() { |
399 |
ajm |
1.11 |
_knownHostsData = new ArrayList(); |
400 |
|
|
_hostListData = new ArrayList(); |
401 |
|
|
String _configKnownHostsList = _config.getProperty("knownHostsList"); |
402 |
|
|
String _configHostList = _config.getProperty("hostList"); |
403 |
ajm |
1.5 |
StringTokenizer st; |
404 |
ajm |
1.11 |
st = new StringTokenizer(_configKnownHostsList, ";"); |
405 |
ajm |
1.5 |
while(st.hasMoreTokens()) { |
406 |
ajm |
1.6 |
// check its not in the other list...as we only want one entry in the two |
407 |
|
|
String knownHost = st.nextToken(); |
408 |
ajm |
1.11 |
if(_configHostList.indexOf(knownHost) == -1) _knownHostsData.add(knownHost); |
409 |
ajm |
1.5 |
} |
410 |
ajm |
1.11 |
st = new StringTokenizer(_configHostList, ";"); |
411 |
ajm |
1.5 |
while(st.hasMoreTokens()) { |
412 |
ajm |
1.11 |
_hostListData.add(st.nextToken()); |
413 |
ajm |
1.5 |
} |
414 |
ajm |
1.11 |
setListDisplay(); |
415 |
|
|
} |
416 |
|
|
|
417 |
|
|
/** |
418 |
|
|
* Because of the limitation of the existing |
419 |
|
|
* data model for lists, ArrayLists are used. |
420 |
|
|
* Whenever the data in these lists is changed, |
421 |
|
|
* this method is called to re-sort the lists |
422 |
|
|
* and reset the display. |
423 |
|
|
*/ |
424 |
|
|
private void setListDisplay() { |
425 |
|
|
// ensure the order |
426 |
|
|
Collections.sort(_hostListData); |
427 |
|
|
Collections.sort(_knownHostsData); |
428 |
|
|
|
429 |
|
|
_knownHosts.setListData(_knownHostsData.toArray()); |
430 |
|
|
_hostList.setListData(_hostListData.toArray()); |
431 |
ajm |
1.4 |
} |
432 |
|
|
|
433 |
ajm |
1.9 |
/** |
434 |
|
|
* Writes the changes back to the loaded configuration |
435 |
|
|
* Then closes the windows |
436 |
|
|
*/ |
437 |
ajm |
1.4 |
private void setNewSettingsAndClose() { |
438 |
ajm |
1.5 |
|
439 |
ajm |
1.11 |
_config.setProperty("clientname", _name.getText().trim()); |
440 |
|
|
_config.setProperty("control.server", _server.getText().trim()); |
441 |
|
|
_config.setProperty("control.port", _port.getText().trim()); |
442 |
|
|
_config.setProperty("firewall.command", _firewallCommand.getText().trim()); |
443 |
|
|
_config.setProperty("firewall.commandwait", _firewallWait.getText().trim()); |
444 |
|
|
_config.setProperty("firewall.server", _firewallServer.getText().trim()); |
445 |
|
|
_config.setProperty("dataQueueSize", _queueLimit.getText().trim()); |
446 |
|
|
if (_useFirewall.isSelected()) { |
447 |
|
|
_config.setProperty("useFirewall", "1"); |
448 |
ajm |
1.4 |
} else { |
449 |
ajm |
1.11 |
_config.setProperty("useFirewall", "0"); |
450 |
ajm |
1.4 |
} |
451 |
ajm |
1.11 |
if (_connectControl.isSelected()) { |
452 |
|
|
_config.setProperty("control.onstartconnect", "1"); |
453 |
ajm |
1.4 |
} else { |
454 |
ajm |
1.11 |
_config.setProperty("control.onstartconnect", "0"); |
455 |
ajm |
1.4 |
} |
456 |
ajm |
1.11 |
if (_connectData.isSelected()) { |
457 |
|
|
_config.setProperty("data.onstartconnect", "1"); |
458 |
ajm |
1.4 |
} else { |
459 |
ajm |
1.11 |
_config.setProperty("data.onstartconnect", "0"); |
460 |
ajm |
1.4 |
} |
461 |
ajm |
1.11 |
if (_packetDump.isSelected()) { |
462 |
|
|
_config.setProperty("packetDump", "1"); |
463 |
ajm |
1.4 |
} else { |
464 |
ajm |
1.11 |
_config.setProperty("packetDump", "0"); |
465 |
ajm |
1.4 |
} |
466 |
ajm |
1.11 |
if (_displayExtra.isSelected()) { |
467 |
|
|
_config.setProperty("displayExtraData", "1"); |
468 |
ajm |
1.4 |
} else { |
469 |
ajm |
1.11 |
_config.setProperty("displayExtraData", "0"); |
470 |
ajm |
1.4 |
} |
471 |
ajm |
1.11 |
if (_displayQueue.isSelected()) { |
472 |
|
|
_config.setProperty("displayQueueInformation", "1"); |
473 |
ajm |
1.4 |
} else { |
474 |
ajm |
1.11 |
_config.setProperty("displayQueueInformation", "0"); |
475 |
ajm |
1.4 |
} |
476 |
ajm |
1.11 |
if (_useHostList.isSelected()) { |
477 |
|
|
_config.setProperty("useHostList", "1"); |
478 |
ajm |
1.5 |
} else { |
479 |
ajm |
1.11 |
_config.setProperty("useHostList", "0"); |
480 |
ajm |
1.5 |
} |
481 |
ajm |
1.11 |
if (_hostDiscoveryMode.isSelected()) { |
482 |
|
|
_config.setProperty("hostDiscoveryMode", "1"); |
483 |
ajm |
1.5 |
} else { |
484 |
ajm |
1.11 |
_config.setProperty("hostDiscoveryMode", "0"); |
485 |
ajm |
1.5 |
} |
486 |
ajm |
1.6 |
|
487 |
|
|
// sort out the hosts lists |
488 |
|
|
|
489 |
|
|
// known hosts are both the known hosts list AND the host list |
490 |
ajm |
1.11 |
// first the hostList... |
491 |
|
|
Iterator i; |
492 |
|
|
i = _hostListData.iterator(); |
493 |
|
|
String _hostListSave = ""; |
494 |
|
|
while(i.hasNext()) { |
495 |
|
|
_hostListSave += (String) i.next() + ";"; |
496 |
|
|
} |
497 |
|
|
|
498 |
|
|
i = _knownHostsData.iterator(); |
499 |
|
|
String _knownHostsListSave = ""; |
500 |
|
|
while(i.hasNext()) { |
501 |
|
|
_knownHostsListSave += (String) i.next() + ";"; |
502 |
|
|
} |
503 |
|
|
|
504 |
|
|
_knownHostsListSave += _hostListSave; |
505 |
|
|
_config.setProperty("hostList", _hostListSave); |
506 |
|
|
_config.setProperty("knownHostsList", _knownHostsListSave); |
507 |
ajm |
1.4 |
dispose(); |
508 |
ajm |
1.1 |
} |
509 |
|
|
|
510 |
ajm |
1.4 |
//---ACCESSOR/MUTATOR METHODS--- |
511 |
ajm |
1.1 |
|
512 |
ajm |
1.4 |
//---ATTRIBUTES--- |
513 |
ajm |
1.1 |
|
514 |
ajm |
1.9 |
/** |
515 |
|
|
* A reference to the configuration in use |
516 |
|
|
*/ |
517 |
ajm |
1.11 |
Configuration _config = Configuration.getInstance(); |
518 |
ajm |
1.9 |
|
519 |
|
|
/** |
520 |
|
|
* Used to add a new host to the known host list |
521 |
|
|
*/ |
522 |
ajm |
1.11 |
private JTextField _newHost; |
523 |
ajm |
1.5 |
|
524 |
ajm |
1.9 |
/** |
525 |
|
|
* Lists the known hosts (less the ones we're monitoring) |
526 |
|
|
*/ |
527 |
ajm |
1.11 |
private JList _knownHosts; |
528 |
ajm |
1.9 |
|
529 |
|
|
/** |
530 |
|
|
* The list of hosts we're monitoring |
531 |
|
|
*/ |
532 |
ajm |
1.11 |
private JList _hostList; |
533 |
ajm |
1.9 |
|
534 |
|
|
/** |
535 |
ajm |
1.12 |
* If we are making a note of the hosts the server |
536 |
ajm |
1.9 |
* sends us. |
537 |
|
|
*/ |
538 |
ajm |
1.11 |
private JCheckBox _hostDiscoveryMode; |
539 |
ajm |
1.9 |
|
540 |
|
|
/** |
541 |
|
|
* If we are using the host list setting to only view data |
542 |
|
|
* from certain hosts |
543 |
|
|
*/ |
544 |
ajm |
1.11 |
private JCheckBox _useHostList; |
545 |
ajm |
1.9 |
|
546 |
|
|
/** |
547 |
ajm |
1.12 |
* The name to identify this client to the server |
548 |
ajm |
1.9 |
*/ |
549 |
ajm |
1.11 |
private JTextField _name; |
550 |
ajm |
1.9 |
|
551 |
|
|
/** |
552 |
ajm |
1.11 |
* The _port the i-scream _server is running on |
553 |
ajm |
1.9 |
*/ |
554 |
ajm |
1.11 |
private JTextField _port; |
555 |
ajm |
1.9 |
|
556 |
|
|
/** |
557 |
ajm |
1.11 |
* The host_name of the i-scream server |
558 |
ajm |
1.9 |
*/ |
559 |
ajm |
1.11 |
private JTextField _server; |
560 |
ajm |
1.9 |
|
561 |
|
|
/** |
562 |
|
|
* If we want to start the control channel on startup |
563 |
|
|
*/ |
564 |
ajm |
1.11 |
private JCheckBox _connectControl; |
565 |
ajm |
1.9 |
|
566 |
|
|
/** |
567 |
|
|
* If we want to start the data channel on startup |
568 |
|
|
*/ |
569 |
ajm |
1.11 |
private JCheckBox _connectData; |
570 |
ajm |
1.9 |
|
571 |
|
|
/** |
572 |
|
|
* If we want to use the firewall command to connect |
573 |
|
|
*/ |
574 |
ajm |
1.11 |
private JCheckBox _useFirewall; |
575 |
ajm |
1.9 |
|
576 |
|
|
/** |
577 |
|
|
* The command to run to open a pipe to the iscream server |
578 |
|
|
*/ |
579 |
ajm |
1.11 |
private JTextField _firewallCommand; |
580 |
ajm |
1.9 |
|
581 |
|
|
/** |
582 |
|
|
* How long to wait for the firewall command to execute |
583 |
|
|
*/ |
584 |
ajm |
1.11 |
private JTextField _firewallWait; |
585 |
ajm |
1.9 |
|
586 |
|
|
/** |
587 |
|
|
* The name of the machine to locally connect through to |
588 |
|
|
* reach the i-scream server |
589 |
|
|
*/ |
590 |
ajm |
1.11 |
private JTextField _firewallServer; |
591 |
ajm |
1.9 |
|
592 |
|
|
/** |
593 |
|
|
* Whether to display server queue debugging information |
594 |
|
|
*/ |
595 |
ajm |
1.11 |
private JCheckBox _displayQueue; |
596 |
ajm |
1.9 |
|
597 |
|
|
/** |
598 |
|
|
* Whether to display extra data contained in packets |
599 |
|
|
*/ |
600 |
ajm |
1.11 |
private JCheckBox _displayExtra; |
601 |
ajm |
1.9 |
|
602 |
|
|
/** |
603 |
|
|
* Whether to dump raw packet data to the console |
604 |
|
|
*/ |
605 |
ajm |
1.11 |
private JCheckBox _packetDump; |
606 |
ajm |
1.10 |
|
607 |
|
|
/** |
608 |
|
|
* The limit on the data queue size |
609 |
|
|
*/ |
610 |
ajm |
1.11 |
private JTextField _queueLimit; |
611 |
ajm |
1.9 |
|
612 |
|
|
/** |
613 |
|
|
* holds the known hosts |
614 |
|
|
*/ |
615 |
ajm |
1.11 |
private ArrayList _knownHostsData; |
616 |
ajm |
1.9 |
|
617 |
|
|
/** |
618 |
|
|
* holds the monitored hosts |
619 |
|
|
*/ |
620 |
ajm |
1.11 |
private ArrayList _hostListData; |
621 |
ajm |
1.1 |
|
622 |
|
|
//---STATIC ATTRIBUTES--- |
623 |
|
|
|
624 |
|
|
} |