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