1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* http://www.i-scream.org.uk |
4 |
+ |
* Copyright (C) 2000-2002 i-scream |
5 |
+ |
* |
6 |
+ |
* This program is free software; you can redistribute it and/or |
7 |
+ |
* modify it under the terms of the GNU General Public License |
8 |
+ |
* as published by the Free Software Foundation; either version 2 |
9 |
+ |
* of the License, or (at your option) any later version. |
10 |
+ |
* |
11 |
+ |
* This program is distributed in the hope that it will be useful, |
12 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
+ |
* GNU General Public License for more details. |
15 |
+ |
* |
16 |
+ |
* You should have received a copy of the GNU General Public License |
17 |
+ |
* along with this program; if not, write to the Free Software |
18 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
+ |
*/ |
20 |
+ |
|
21 |
|
//---PACKAGE DECLARATION--- |
22 |
< |
package uk.org.iscream.conient; |
22 |
> |
package uk.org.iscream.cms.conient; |
23 |
|
|
24 |
|
//---IMPORTS--- |
25 |
|
import java.awt.*; |
28 |
|
import javax.swing.border.*; |
29 |
|
import java.util.Properties; |
30 |
|
import java.util.StringTokenizer; |
31 |
+ |
import java.util.Collections; |
32 |
+ |
import java.util.ArrayList; |
33 |
+ |
import java.util.Iterator; |
34 |
|
|
35 |
|
/** |
36 |
|
* This provides a modal dialog from which the user |
37 |
|
* can reconfigure the conient client. |
38 |
|
* |
39 |
< |
* It then writes back the configuration to the file. |
39 |
> |
* Look at the comments for the attributes of this class to see |
40 |
> |
* what configuration options this class deals with. |
41 |
|
* |
42 |
< |
* Server configured options are displayed, but are |
43 |
< |
* for information purposes only, and cannot be changed. |
42 |
> |
* It then writes back the configuration to the loaded configuration. |
43 |
> |
* The user can then opt to save it. |
44 |
|
* |
45 |
+ |
* |
46 |
|
* @author $Author$ |
47 |
|
* @version $Id$ |
48 |
|
*/ |
93 |
|
// client options |
94 |
|
center.addTab("Client Options", createClientOptions()); |
95 |
|
|
96 |
< |
// server options |
96 |
> |
// _server options |
97 |
|
center.addTab("Server Options", createServerOptions()); |
98 |
|
|
99 |
|
// firewall options |
118 |
|
|
119 |
|
//---PRIVATE METHODS--- |
120 |
|
|
121 |
+ |
/** |
122 |
+ |
* creates a JPanel for the client options |
123 |
+ |
* |
124 |
+ |
* @return the build panel with the options |
125 |
+ |
*/ |
126 |
|
private JPanel createClientOptions() { |
127 |
|
GridBagLayout gridbag = new GridBagLayout(); |
128 |
|
GridBagLayout gridbag2 = new GridBagLayout(); |
133 |
|
clientPanel.setLayout(gridbag); |
134 |
|
JLabel nameLabel = new JLabel("Client name:"); |
135 |
|
nameLabel.setHorizontalAlignment(JLabel.RIGHT); |
136 |
< |
name = new JTextField(20); |
136 |
> |
_name = new JTextField(20); |
137 |
|
JPanel nameBox = new JPanel(); |
138 |
|
nameBox.setLayout(new GridLayout(1,2)); |
139 |
|
nameBox.add(nameLabel); |
140 |
< |
nameBox.add(name); |
140 |
> |
nameBox.add(_name); |
141 |
|
|
142 |
|
c.gridy = 0; |
143 |
|
gridbag.setConstraints(nameBox, c); |
148 |
|
|
149 |
|
JPanel knownHostsPanel = new JPanel(); |
150 |
|
knownHostsPanel.setLayout(new BoxLayout(knownHostsPanel, BoxLayout.Y_AXIS)); |
151 |
< |
hostDiscoveryMode = new JCheckBox("Discover new hosts from the server"); |
152 |
< |
knownHostsPanel.add(hostDiscoveryMode); |
151 |
> |
_hostDiscoveryMode = new JCheckBox("Discover new hosts from the server"); |
152 |
> |
knownHostsPanel.add(_hostDiscoveryMode); |
153 |
|
knownHostsPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Known Hosts ")); |
154 |
< |
knownHosts = new JList(); |
155 |
< |
knownHosts.setVisibleRowCount(10); |
156 |
< |
JScrollPane knownHostsScrollPane = new JScrollPane(knownHosts); |
154 |
> |
_knownHosts = new JList(); |
155 |
> |
_knownHosts.setVisibleRowCount(10); |
156 |
> |
JScrollPane knownHostsScrollPane = new JScrollPane(_knownHosts); |
157 |
|
knownHostsPanel.add(knownHostsScrollPane); |
158 |
|
JLabel newHostLabel = new JLabel("New host:"); |
159 |
|
newHostLabel.setHorizontalAlignment(JLabel.RIGHT); |
160 |
< |
newHost = new JTextField(20); |
160 |
> |
_newHost = new JTextField(20); |
161 |
|
|
162 |
|
JButton newHostButton = new JButton("Add Host"); |
163 |
|
newHostButton.addActionListener(new ActionListener() { |
164 |
|
public void actionPerformed(ActionEvent e) { |
165 |
< |
knownHostsModel.addElement(newHost.getText()); |
166 |
< |
newHost.setText(""); |
165 |
> |
_knownHostsData.add(_newHost.getText()); |
166 |
> |
_newHost.setText(""); |
167 |
> |
setListDisplay(); |
168 |
|
} |
169 |
|
}); |
170 |
|
JButton removeHostButton = new JButton("Remove Host(s)"); |
171 |
|
removeHostButton.addActionListener(new ActionListener() { |
172 |
|
public void actionPerformed(ActionEvent e) { |
173 |
< |
Object[] selected = knownHosts.getSelectedValues(); |
173 |
> |
Object[] selected = _knownHosts.getSelectedValues(); |
174 |
|
for(int x = 0; x < selected.length; x++) { |
175 |
< |
knownHostsModel.removeElement(selected[x]); |
175 |
> |
_knownHostsData.remove(_knownHostsData.indexOf(selected[x])); |
176 |
> |
setListDisplay(); |
177 |
|
} |
178 |
|
} |
179 |
|
}); |
180 |
|
JPanel newHostBox = new JPanel(); |
181 |
|
newHostBox.setLayout(new GridLayout(1,3)); |
182 |
|
newHostBox.add(newHostLabel); |
183 |
< |
newHostBox.add(newHost); |
183 |
> |
newHostBox.add(_newHost); |
184 |
|
|
185 |
|
JPanel buttonPanel = new JPanel(); |
186 |
|
buttonPanel.add(newHostButton); |
201 |
|
JButton add = new JButton(">>>"); |
202 |
|
add.addActionListener(new ActionListener() { |
203 |
|
public void actionPerformed(ActionEvent e) { |
204 |
< |
Object[] selected = knownHosts.getSelectedValues(); |
204 |
> |
Object[] selected = _knownHosts.getSelectedValues(); |
205 |
|
for(int x = 0; x < selected.length; x++) { |
206 |
< |
knownHostsModel.removeElement(selected[x]); |
207 |
< |
hostListModel.addElement(selected[x]); |
206 |
> |
_knownHostsData.remove(_knownHostsData.indexOf(selected[x])); |
207 |
> |
_hostListData.add(selected[x]); |
208 |
> |
setListDisplay(); |
209 |
|
} |
210 |
|
} |
211 |
|
}); |
215 |
|
JButton remove = new JButton("<<<"); |
216 |
|
remove.addActionListener(new ActionListener() { |
217 |
|
public void actionPerformed(ActionEvent e) { |
218 |
< |
Object[] selected = hostList.getSelectedValues(); |
218 |
> |
Object[] selected = _hostList.getSelectedValues(); |
219 |
|
for(int x = 0; x < selected.length; x++) { |
220 |
< |
hostListModel.removeElement(selected[x]); |
221 |
< |
knownHostsModel.addElement(selected[x]); |
220 |
> |
_hostListData.remove(_hostListData.indexOf(selected[x])); |
221 |
> |
_knownHostsData.add(selected[x]); |
222 |
> |
setListDisplay(); |
223 |
|
} |
224 |
|
} |
225 |
|
}); |
233 |
|
|
234 |
|
JPanel hostListPanel = new JPanel(); |
235 |
|
hostListPanel.setLayout(new BoxLayout(hostListPanel, BoxLayout.Y_AXIS)); |
236 |
< |
useHostList = new JCheckBox("Only monitor hosts in this list"); |
237 |
< |
hostListPanel.add(useHostList); |
236 |
> |
_useHostList = new JCheckBox("Only monitor hosts in this list"); |
237 |
> |
hostListPanel.add(_useHostList); |
238 |
|
hostListPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Hosts To Monitor ")); |
239 |
< |
hostList = new JList(); |
240 |
< |
hostList.setVisibleRowCount(10); |
241 |
< |
JScrollPane hostListScrollPane = new JScrollPane(hostList); |
239 |
> |
_hostList = new JList(); |
240 |
> |
_hostList.setVisibleRowCount(10); |
241 |
> |
JScrollPane hostListScrollPane = new JScrollPane(_hostList); |
242 |
|
hostListPanel.add(hostListScrollPane); |
243 |
|
|
244 |
|
c.gridy = 0; |
252 |
|
clientPanel.add(lists); |
253 |
|
return clientPanel; |
254 |
|
} |
255 |
< |
|
255 |
> |
|
256 |
> |
/** |
257 |
> |
* creates a JPanel for the server options |
258 |
> |
* |
259 |
> |
* @return the build panel with the options |
260 |
> |
*/ |
261 |
|
private JPanel createServerOptions() { |
262 |
|
GridBagLayout gridbag = new GridBagLayout(); |
263 |
|
GridBagConstraints c = new GridBagConstraints(); |
264 |
|
c.fill = GridBagConstraints.HORIZONTAL; |
265 |
|
JPanel serverPanel = new JPanel(); |
266 |
|
serverPanel.setLayout(gridbag); |
267 |
< |
JLabel serverLabel = new JLabel("i-scream Server:"); |
267 |
> |
_connectControl = new JCheckBox("Automatically connect the control channel"); |
268 |
> |
c.gridy = 0; |
269 |
> |
gridbag.setConstraints(_connectControl, c); |
270 |
> |
serverPanel.add(_connectControl); |
271 |
> |
_connectData = new JCheckBox("Automatically connect the data channel"); |
272 |
> |
c.gridy = 1; |
273 |
> |
gridbag.setConstraints(_connectData, c); |
274 |
> |
serverPanel.add(_connectData); |
275 |
> |
JLabel serverLabel = new JLabel("i-scream server:"); |
276 |
|
serverLabel.setHorizontalAlignment(JLabel.RIGHT); |
277 |
< |
server = new JTextField(20); |
277 |
> |
_server = new JTextField(20); |
278 |
|
JPanel serverBox = new JPanel(); |
279 |
|
serverBox.setLayout(new GridLayout(1,2)); |
280 |
|
serverBox.add(serverLabel); |
281 |
< |
serverBox.add(server); |
282 |
< |
c.gridy = 0; |
281 |
> |
serverBox.add(_server); |
282 |
> |
c.gridy = 2; |
283 |
|
gridbag.setConstraints(serverBox, c); |
284 |
|
serverPanel.add(serverBox); |
285 |
|
JLabel portLabel = new JLabel("Client interface port:"); |
286 |
|
portLabel.setHorizontalAlignment(JLabel.RIGHT); |
287 |
< |
port = new JTextField(4); |
287 |
> |
_port = new JTextField(4); |
288 |
|
JPanel portBox = new JPanel(); |
289 |
|
portBox.setLayout(new GridLayout(1,2)); |
290 |
|
portBox.add(portLabel); |
291 |
< |
portBox.add(port); |
292 |
< |
c.gridy = 1; |
291 |
> |
portBox.add(_port); |
292 |
> |
c.gridy = 3; |
293 |
|
gridbag.setConstraints(portBox, c); |
294 |
|
serverPanel.add(portBox); |
248 |
– |
connectControl = new JCheckBox("Automatically connect the control channel"); |
249 |
– |
c.gridy = 2; |
250 |
– |
gridbag.setConstraints(connectControl, c); |
251 |
– |
serverPanel.add(connectControl); |
252 |
– |
connectData = new JCheckBox("Automatically connect the data channel"); |
253 |
– |
c.gridy = 3; |
254 |
– |
gridbag.setConstraints(connectData, c); |
255 |
– |
serverPanel.add(connectData); |
295 |
|
return serverPanel; |
296 |
|
} |
297 |
|
|
298 |
+ |
/** |
299 |
+ |
* creates a JPanel for the firewall options |
300 |
+ |
* |
301 |
+ |
* @return the build panel with the options |
302 |
+ |
*/ |
303 |
|
private JPanel createFirewallOptions() { |
304 |
|
GridBagLayout gridbag = new GridBagLayout(); |
305 |
|
GridBagConstraints c = new GridBagConstraints(); |
306 |
|
c.fill = GridBagConstraints.HORIZONTAL; |
307 |
|
JPanel firewallPanel = new JPanel(); |
308 |
|
firewallPanel.setLayout(gridbag); |
265 |
– |
|
309 |
|
|
310 |
< |
useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
310 |
> |
_useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
311 |
|
c.gridy = 0; |
312 |
< |
gridbag.setConstraints(useFirewall, c); |
313 |
< |
firewallPanel.add(useFirewall); |
312 |
> |
gridbag.setConstraints(_useFirewall, c); |
313 |
> |
firewallPanel.add(_useFirewall); |
314 |
|
|
315 |
|
JLabel commandLabel = new JLabel("Firewall command:"); |
316 |
|
commandLabel.setHorizontalAlignment(JLabel.RIGHT); |
317 |
< |
firewallCommand = new JTextField(20); |
275 |
< |
firewallCommand.setSize(new Dimension(1,10)); |
317 |
> |
_firewallCommand = new JTextField(20); |
318 |
|
JPanel commandBox = new JPanel(); |
319 |
|
commandBox.setLayout(new GridLayout(1,2)); |
320 |
|
commandBox.add(commandLabel); |
321 |
< |
commandBox.add(firewallCommand); |
321 |
> |
commandBox.add(_firewallCommand); |
322 |
|
|
323 |
|
c.gridy = 1; |
324 |
|
gridbag.setConstraints(commandBox, c); |
326 |
|
|
327 |
|
JLabel waitLabel = new JLabel("Firewall wait time:"); |
328 |
|
waitLabel.setHorizontalAlignment(JLabel.RIGHT); |
329 |
< |
firewallWait = new JTextField(2); |
329 |
> |
_firewallWait = new JTextField(2); |
330 |
|
JPanel waitBox = new JPanel(); |
331 |
|
waitBox.setLayout(new GridLayout(1,2)); |
332 |
|
waitBox.add(waitLabel); |
333 |
< |
waitBox.add(firewallWait); |
333 |
> |
waitBox.add(_firewallWait); |
334 |
|
|
335 |
|
c.gridy = 2; |
336 |
|
gridbag.setConstraints(waitBox, c); |
337 |
|
firewallPanel.add(waitBox); |
338 |
|
|
339 |
< |
JLabel fserverLabel = new JLabel("Firewall server:"); |
340 |
< |
fserverLabel.setHorizontalAlignment(JLabel.RIGHT); |
341 |
< |
firewallServer = new JTextField(20); |
342 |
< |
JPanel fserverBox = new JPanel(); |
343 |
< |
fserverBox.setLayout(new GridLayout(1,2)); |
344 |
< |
fserverBox.add(fserverLabel); |
345 |
< |
fserverBox.add(firewallServer); |
339 |
> |
JLabel fServerLabel = new JLabel("Firewall server:"); |
340 |
> |
fServerLabel.setHorizontalAlignment(JLabel.RIGHT); |
341 |
> |
_firewallServer = new JTextField(20); |
342 |
> |
JPanel fServerBox = new JPanel(); |
343 |
> |
fServerBox.setLayout(new GridLayout(1,2)); |
344 |
> |
fServerBox.add(fServerLabel); |
345 |
> |
fServerBox.add(_firewallServer); |
346 |
|
|
347 |
|
c.gridy = 3; |
348 |
< |
gridbag.setConstraints(fserverBox, c); |
349 |
< |
firewallPanel.add(fserverBox); |
348 |
> |
gridbag.setConstraints(fServerBox, c); |
349 |
> |
firewallPanel.add(fServerBox); |
350 |
|
|
351 |
|
return firewallPanel; |
352 |
|
} |
353 |
|
|
354 |
+ |
/** |
355 |
+ |
* creates a JPanel for the data options |
356 |
+ |
* |
357 |
+ |
* @return the build panel with the options |
358 |
+ |
*/ |
359 |
|
private JPanel createDataOptions() { |
360 |
|
GridBagLayout gridbag = new GridBagLayout(); |
361 |
|
GridBagConstraints c = new GridBagConstraints(); |
362 |
|
c.fill = GridBagConstraints.HORIZONTAL; |
363 |
|
JPanel dataPanel = new JPanel(); |
364 |
|
dataPanel.setLayout(gridbag); |
365 |
< |
displayQueue = new JCheckBox("Display server queue information"); |
365 |
> |
_displayQueue = new JCheckBox("Display server queue information"); |
366 |
|
c.gridy = 0; |
367 |
< |
gridbag.setConstraints(displayQueue, c); |
368 |
< |
dataPanel.add(displayQueue); |
369 |
< |
displayExtra = new JCheckBox("Display extra data found in packets"); |
367 |
> |
gridbag.setConstraints(_displayQueue, c); |
368 |
> |
dataPanel.add(_displayQueue); |
369 |
> |
_displayExtra = new JCheckBox("Display extra data found in packets"); |
370 |
|
c.gridy = 1; |
371 |
< |
gridbag.setConstraints(displayExtra, c); |
372 |
< |
dataPanel.add(displayExtra); |
373 |
< |
packetDump = new JCheckBox("Dump raw packet data to the console"); |
371 |
> |
gridbag.setConstraints(_displayExtra, c); |
372 |
> |
dataPanel.add(_displayExtra); |
373 |
> |
_packetDump = new JCheckBox("Dump raw packet data to the console"); |
374 |
|
c.gridy = 2; |
375 |
< |
gridbag.setConstraints(packetDump, c); |
376 |
< |
dataPanel.add(packetDump); |
375 |
> |
gridbag.setConstraints(_packetDump, c); |
376 |
> |
dataPanel.add(_packetDump); |
377 |
> |
|
378 |
> |
JLabel queueLimitLabel = new JLabel("Maximum data queue size:"); |
379 |
> |
queueLimitLabel.setHorizontalAlignment(JLabel.RIGHT); |
380 |
> |
_queueLimit = new JTextField(4); |
381 |
> |
JPanel queueBox = new JPanel(); |
382 |
> |
queueBox.setLayout(new GridLayout(1,2)); |
383 |
> |
queueBox.add(queueLimitLabel); |
384 |
> |
queueBox.add(_queueLimit); |
385 |
> |
c.gridy = 3; |
386 |
> |
gridbag.setConstraints(queueBox, c); |
387 |
> |
dataPanel.add(queueBox); |
388 |
|
return dataPanel; |
389 |
|
} |
390 |
|
|
391 |
+ |
/** |
392 |
+ |
* Reads in the current settings from the loaded configuration |
393 |
+ |
*/ |
394 |
|
private void getCurrentSettings() { |
395 |
< |
name.setText(config.getProperty("clientname")); |
396 |
< |
server.setText(config.getProperty("control.server")); |
397 |
< |
port.setText(config.getProperty("control.port")); |
398 |
< |
connectControl.setSelected(config.getProperty("control.onstartconnect").equals("1")); |
399 |
< |
connectData.setSelected(config.getProperty("data.onstartconnect").equals("1")); |
400 |
< |
firewallCommand.setText(config.getProperty("firewall.command")); |
401 |
< |
firewallCommand.moveCaretPosition(0); |
402 |
< |
firewallWait.setText(config.getProperty("firewall.commandwait")); |
403 |
< |
firewallServer.setText(config.getProperty("firewall.server")); |
404 |
< |
displayQueue.setSelected(config.getProperty("displayQueueInformation").equals("1")); |
405 |
< |
displayExtra.setSelected(config.getProperty("displayExtraData").equals("1")); |
406 |
< |
packetDump.setSelected(config.getProperty("packetDump").equals("1")); |
407 |
< |
useFirewall.setSelected(config.getProperty("useFirewall").equals("1")); |
408 |
< |
hostDiscoveryMode.setSelected(config.getProperty("hostDiscoveryMode").equals("1")); |
409 |
< |
useHostList.setSelected(config.getProperty("useHostList").equals("1")); |
395 |
> |
_name.setText(_config.getProperty("clientname")); |
396 |
> |
_server.setText(_config.getProperty("control.server")); |
397 |
> |
_port.setText(_config.getProperty("control.port")); |
398 |
> |
_connectControl.setSelected(_config.getProperty("control.onstartconnect").equals("1")); |
399 |
> |
_connectData.setSelected(_config.getProperty("data.onstartconnect").equals("1")); |
400 |
> |
_firewallCommand.setText(_config.getProperty("firewall.command")); |
401 |
> |
_firewallCommand.moveCaretPosition(0); |
402 |
> |
_firewallWait.setText(_config.getProperty("firewall.commandwait")); |
403 |
> |
_firewallServer.setText(_config.getProperty("firewall.server")); |
404 |
> |
_displayQueue.setSelected(_config.getProperty("displayQueueInformation").equals("1")); |
405 |
> |
_displayExtra.setSelected(_config.getProperty("displayExtraData").equals("1")); |
406 |
> |
_packetDump.setSelected(_config.getProperty("packetDump").equals("1")); |
407 |
> |
_useFirewall.setSelected(_config.getProperty("useFirewall").equals("1")); |
408 |
> |
_hostDiscoveryMode.setSelected(_config.getProperty("hostDiscoveryMode").equals("1")); |
409 |
> |
_useHostList.setSelected(_config.getProperty("useHostList").equals("1")); |
410 |
> |
_queueLimit.setText(_config.getProperty("dataQueueSize")); |
411 |
|
prepareLists(); |
412 |
|
} |
413 |
|
|
414 |
< |
|
414 |
> |
/** |
415 |
> |
* Displays the host lists in the host windows |
416 |
> |
* in alphabetical order |
417 |
> |
*/ |
418 |
|
private void prepareLists() { |
419 |
< |
knownHostsModel = new DefaultListModel(); |
420 |
< |
hostListModel = new DefaultListModel(); |
421 |
< |
String configKnownHostsList = config.getProperty("knownHostsList"); |
422 |
< |
String configHostList = config.getProperty("hostList"); |
419 |
> |
_knownHostsData = new ArrayList(); |
420 |
> |
_hostListData = new ArrayList(); |
421 |
> |
String _configKnownHostsList = _config.getProperty("knownHostsList"); |
422 |
> |
String _configHostList = _config.getProperty("hostList"); |
423 |
|
StringTokenizer st; |
424 |
< |
st = new StringTokenizer(configKnownHostsList, ";"); |
424 |
> |
st = new StringTokenizer(_configKnownHostsList, ";"); |
425 |
|
while(st.hasMoreTokens()) { |
426 |
|
// check its not in the other list...as we only want one entry in the two |
427 |
|
String knownHost = st.nextToken(); |
428 |
< |
if(configHostList.indexOf(knownHost) == -1) knownHostsModel.addElement(knownHost); |
428 |
> |
if(_configHostList.indexOf(knownHost) == -1) _knownHostsData.add(knownHost); |
429 |
|
} |
430 |
< |
st = new StringTokenizer(configHostList, ";"); |
430 |
> |
st = new StringTokenizer(_configHostList, ";"); |
431 |
|
while(st.hasMoreTokens()) { |
432 |
< |
hostListModel.addElement(st.nextToken()); |
432 |
> |
_hostListData.add(st.nextToken()); |
433 |
|
} |
434 |
< |
knownHosts.setModel(knownHostsModel); |
370 |
< |
hostList.setModel(hostListModel); |
434 |
> |
setListDisplay(); |
435 |
|
} |
436 |
|
|
437 |
+ |
/** |
438 |
+ |
* Because of the limitation of the existing |
439 |
+ |
* data model for lists, ArrayLists are used. |
440 |
+ |
* Whenever the data in these lists is changed, |
441 |
+ |
* this method is called to re-sort the lists |
442 |
+ |
* and reset the display. |
443 |
+ |
*/ |
444 |
+ |
private void setListDisplay() { |
445 |
+ |
// ensure the order |
446 |
+ |
Collections.sort(_hostListData); |
447 |
+ |
Collections.sort(_knownHostsData); |
448 |
+ |
|
449 |
+ |
_knownHosts.setListData(_knownHostsData.toArray()); |
450 |
+ |
_hostList.setListData(_hostListData.toArray()); |
451 |
+ |
} |
452 |
+ |
|
453 |
+ |
/** |
454 |
+ |
* Writes the changes back to the loaded configuration |
455 |
+ |
* Then closes the windows |
456 |
+ |
*/ |
457 |
|
private void setNewSettingsAndClose() { |
458 |
|
|
459 |
< |
config.setProperty("clientname", name.getText().trim()); |
460 |
< |
config.setProperty("control.server", server.getText().trim()); |
461 |
< |
config.setProperty("control.port", port.getText().trim()); |
462 |
< |
config.setProperty("firewall.command", firewallCommand.getText().trim()); |
463 |
< |
config.setProperty("firewall.commandwait", firewallWait.getText().trim()); |
464 |
< |
config.setProperty("firewall.server", firewallServer.getText().trim()); |
465 |
< |
if (useFirewall.isSelected()) { |
466 |
< |
config.setProperty("useFirewall", "1"); |
459 |
> |
_config.setProperty("clientname", _name.getText().trim()); |
460 |
> |
_config.setProperty("control.server", _server.getText().trim()); |
461 |
> |
_config.setProperty("control.port", _port.getText().trim()); |
462 |
> |
_config.setProperty("firewall.command", _firewallCommand.getText().trim()); |
463 |
> |
_config.setProperty("firewall.commandwait", _firewallWait.getText().trim()); |
464 |
> |
_config.setProperty("firewall.server", _firewallServer.getText().trim()); |
465 |
> |
_config.setProperty("dataQueueSize", _queueLimit.getText().trim()); |
466 |
> |
if (_useFirewall.isSelected()) { |
467 |
> |
_config.setProperty("useFirewall", "1"); |
468 |
|
} else { |
469 |
< |
config.setProperty("useFirewall", "0"); |
469 |
> |
_config.setProperty("useFirewall", "0"); |
470 |
|
} |
471 |
< |
if (connectControl.isSelected()) { |
472 |
< |
config.setProperty("control.onstartconnect", "1"); |
471 |
> |
if (_connectControl.isSelected()) { |
472 |
> |
_config.setProperty("control.onstartconnect", "1"); |
473 |
|
} else { |
474 |
< |
config.setProperty("control.onstartconnect", "0"); |
474 |
> |
_config.setProperty("control.onstartconnect", "0"); |
475 |
|
} |
476 |
< |
if (connectData.isSelected()) { |
477 |
< |
config.setProperty("data.onstartconnect", "1"); |
476 |
> |
if (_connectData.isSelected()) { |
477 |
> |
_config.setProperty("data.onstartconnect", "1"); |
478 |
|
} else { |
479 |
< |
config.setProperty("data.onstartconnect", "0"); |
479 |
> |
_config.setProperty("data.onstartconnect", "0"); |
480 |
|
} |
481 |
< |
if (packetDump.isSelected()) { |
482 |
< |
config.setProperty("packetDump", "1"); |
481 |
> |
if (_packetDump.isSelected()) { |
482 |
> |
_config.setProperty("packetDump", "1"); |
483 |
|
} else { |
484 |
< |
config.setProperty("packetDump", "0"); |
484 |
> |
_config.setProperty("packetDump", "0"); |
485 |
|
} |
486 |
< |
if (displayExtra.isSelected()) { |
487 |
< |
config.setProperty("displayExtraData", "1"); |
486 |
> |
if (_displayExtra.isSelected()) { |
487 |
> |
_config.setProperty("displayExtraData", "1"); |
488 |
|
} else { |
489 |
< |
config.setProperty("displayExtraData", "0"); |
489 |
> |
_config.setProperty("displayExtraData", "0"); |
490 |
|
} |
491 |
< |
if (displayQueue.isSelected()) { |
492 |
< |
config.setProperty("displayQueueInformation", "1"); |
491 |
> |
if (_displayQueue.isSelected()) { |
492 |
> |
_config.setProperty("displayQueueInformation", "1"); |
493 |
|
} else { |
494 |
< |
config.setProperty("displayQueueInformation", "0"); |
494 |
> |
_config.setProperty("displayQueueInformation", "0"); |
495 |
|
} |
496 |
< |
if (useHostList.isSelected()) { |
497 |
< |
config.setProperty("useHostList", "1"); |
496 |
> |
if (_useHostList.isSelected()) { |
497 |
> |
_config.setProperty("useHostList", "1"); |
498 |
|
} else { |
499 |
< |
config.setProperty("useHostList", "0"); |
499 |
> |
_config.setProperty("useHostList", "0"); |
500 |
|
} |
501 |
< |
if (hostDiscoveryMode.isSelected()) { |
502 |
< |
config.setProperty("hostDiscoveryMode", "1"); |
501 |
> |
if (_hostDiscoveryMode.isSelected()) { |
502 |
> |
_config.setProperty("hostDiscoveryMode", "1"); |
503 |
|
} else { |
504 |
< |
config.setProperty("hostDiscoveryMode", "0"); |
504 |
> |
_config.setProperty("hostDiscoveryMode", "0"); |
505 |
|
} |
506 |
|
|
507 |
|
// sort out the hosts lists |
508 |
|
|
509 |
|
// known hosts are both the known hosts list AND the host list |
510 |
< |
// first the hostlist... |
511 |
< |
Object[] hostListSaveArray = hostListModel.toArray(); |
512 |
< |
String hostListSave = ""; |
513 |
< |
for(int x = 0; x < hostListSaveArray.length; x++) { |
514 |
< |
hostListSave += (String) hostListSaveArray[x] + ";"; |
510 |
> |
// first the hostList... |
511 |
> |
Iterator i; |
512 |
> |
i = _hostListData.iterator(); |
513 |
> |
String _hostListSave = ""; |
514 |
> |
while(i.hasNext()) { |
515 |
> |
_hostListSave += (String) i.next() + ";"; |
516 |
|
} |
517 |
< |
Object[] knownHostsListSaveArray = knownHostsModel.toArray(); |
518 |
< |
String knownHostsListSave = ""; |
519 |
< |
for(int x = 0; x < knownHostsListSaveArray.length; x++) { |
520 |
< |
knownHostsListSave += (String) knownHostsListSaveArray[x] + ";"; |
517 |
> |
|
518 |
> |
i = _knownHostsData.iterator(); |
519 |
> |
String _knownHostsListSave = ""; |
520 |
> |
while(i.hasNext()) { |
521 |
> |
_knownHostsListSave += (String) i.next() + ";"; |
522 |
|
} |
523 |
< |
knownHostsListSave += hostListSave; |
524 |
< |
config.setProperty("hostList", hostListSave); |
525 |
< |
config.setProperty("knownHostsList", knownHostsListSave); |
523 |
> |
|
524 |
> |
_knownHostsListSave += _hostListSave; |
525 |
> |
_config.setProperty("hostList", _hostListSave); |
526 |
> |
_config.setProperty("knownHostsList", _knownHostsListSave); |
527 |
|
dispose(); |
528 |
|
} |
529 |
|
|
531 |
|
|
532 |
|
//---ATTRIBUTES--- |
533 |
|
|
534 |
< |
Configuration config = Configuration.getInstance(); |
535 |
< |
|
536 |
< |
private JTextField newHost; |
534 |
> |
/** |
535 |
> |
* A reference to the configuration in use |
536 |
> |
*/ |
537 |
> |
Configuration _config = Configuration.getInstance(); |
538 |
|
|
539 |
< |
private JList knownHosts; |
540 |
< |
private JList hostList; |
541 |
< |
private JCheckBox hostDiscoveryMode; |
542 |
< |
private JCheckBox useHostList; |
543 |
< |
private JTextField name; |
544 |
< |
private JTextField port; |
545 |
< |
private JTextField server; |
546 |
< |
private JCheckBox connectControl; |
547 |
< |
private JCheckBox connectData; |
548 |
< |
private JCheckBox useFirewall; |
549 |
< |
private JTextField firewallCommand; |
550 |
< |
private JTextField firewallWait; |
551 |
< |
private JTextField firewallServer; |
552 |
< |
private JCheckBox displayQueue; |
553 |
< |
private JCheckBox displayExtra; |
554 |
< |
private JCheckBox packetDump; |
555 |
< |
|
556 |
< |
private DefaultListModel knownHostsModel; |
557 |
< |
private DefaultListModel hostListModel; |
539 |
> |
/** |
540 |
> |
* Used to add a new host to the known host list |
541 |
> |
*/ |
542 |
> |
private JTextField _newHost; |
543 |
> |
|
544 |
> |
/** |
545 |
> |
* Lists the known hosts (less the ones we're monitoring) |
546 |
> |
*/ |
547 |
> |
private JList _knownHosts; |
548 |
> |
|
549 |
> |
/** |
550 |
> |
* The list of hosts we're monitoring |
551 |
> |
*/ |
552 |
> |
private JList _hostList; |
553 |
> |
|
554 |
> |
/** |
555 |
> |
* If we are making a note of the hosts the server |
556 |
> |
* sends us. |
557 |
> |
*/ |
558 |
> |
private JCheckBox _hostDiscoveryMode; |
559 |
> |
|
560 |
> |
/** |
561 |
> |
* If we are using the host list setting to only view data |
562 |
> |
* from certain hosts |
563 |
> |
*/ |
564 |
> |
private JCheckBox _useHostList; |
565 |
> |
|
566 |
> |
/** |
567 |
> |
* The name to identify this client to the server |
568 |
> |
*/ |
569 |
> |
private JTextField _name; |
570 |
> |
|
571 |
> |
/** |
572 |
> |
* The _port the i-scream _server is running on |
573 |
> |
*/ |
574 |
> |
private JTextField _port; |
575 |
> |
|
576 |
> |
/** |
577 |
> |
* The host_name of the i-scream server |
578 |
> |
*/ |
579 |
> |
private JTextField _server; |
580 |
> |
|
581 |
> |
/** |
582 |
> |
* If we want to start the control channel on startup |
583 |
> |
*/ |
584 |
> |
private JCheckBox _connectControl; |
585 |
> |
|
586 |
> |
/** |
587 |
> |
* If we want to start the data channel on startup |
588 |
> |
*/ |
589 |
> |
private JCheckBox _connectData; |
590 |
> |
|
591 |
> |
/** |
592 |
> |
* If we want to use the firewall command to connect |
593 |
> |
*/ |
594 |
> |
private JCheckBox _useFirewall; |
595 |
> |
|
596 |
> |
/** |
597 |
> |
* The command to run to open a pipe to the iscream server |
598 |
> |
*/ |
599 |
> |
private JTextField _firewallCommand; |
600 |
> |
|
601 |
> |
/** |
602 |
> |
* How long to wait for the firewall command to execute |
603 |
> |
*/ |
604 |
> |
private JTextField _firewallWait; |
605 |
> |
|
606 |
> |
/** |
607 |
> |
* The name of the machine to locally connect through to |
608 |
> |
* reach the i-scream server |
609 |
> |
*/ |
610 |
> |
private JTextField _firewallServer; |
611 |
> |
|
612 |
> |
/** |
613 |
> |
* Whether to display server queue debugging information |
614 |
> |
*/ |
615 |
> |
private JCheckBox _displayQueue; |
616 |
> |
|
617 |
> |
/** |
618 |
> |
* Whether to display extra data contained in packets |
619 |
> |
*/ |
620 |
> |
private JCheckBox _displayExtra; |
621 |
> |
|
622 |
> |
/** |
623 |
> |
* Whether to dump raw packet data to the console |
624 |
> |
*/ |
625 |
> |
private JCheckBox _packetDump; |
626 |
> |
|
627 |
> |
/** |
628 |
> |
* The limit on the data queue size |
629 |
> |
*/ |
630 |
> |
private JTextField _queueLimit; |
631 |
> |
|
632 |
> |
/** |
633 |
> |
* holds the known hosts |
634 |
> |
*/ |
635 |
> |
private ArrayList _knownHostsData; |
636 |
> |
|
637 |
> |
/** |
638 |
> |
* holds the monitored hosts |
639 |
> |
*/ |
640 |
> |
private ArrayList _hostListData; |
641 |
|
|
642 |
|
//---STATIC ATTRIBUTES--- |
643 |
|
|