1 |
ajm |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
ajm |
1.7 |
package uk.org.iscream.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 |
ajm |
1.11 |
* @version $Id: ConfigurationDialog.java,v 1.10 2001/03/22 01:19:04 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 |
ajm |
1.11 |
public static final String REVISION = "$Revision: 1.10 $"; |
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 |
|
|
center.addTab("Server Options", create_serverOptions()); |
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.11 |
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 |
ajm |
1.8 |
|
122 |
|
|
c.gridy = 0; |
123 |
ajm |
1.11 |
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.11 |
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 |
ajm |
1.8 |
|
142 |
ajm |
1.11 |
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.11 |
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.11 |
buttonPanel.add(_newHostButton); |
167 |
ajm |
1.8 |
buttonPanel.add(removeHostButton); |
168 |
ajm |
1.11 |
_knownHostsPanel.add(buttonPanel); |
169 |
|
|
_knownHostsPanel.add(_newHostBox); |
170 |
ajm |
1.8 |
|
171 |
|
|
|
172 |
|
|
c.gridy = 0; |
173 |
|
|
c.gridx = 0; |
174 |
ajm |
1.11 |
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.11 |
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 |
ajm |
1.8 |
|
224 |
|
|
c.gridy = 0; |
225 |
|
|
c.gridx = 2; |
226 |
ajm |
1.11 |
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.11 |
private JPanel create_serverOptions() { |
242 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
243 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
244 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
245 |
ajm |
1.11 |
JPanel _serverPanel = new JPanel(); |
246 |
|
|
_serverPanel.setLayout(gridbag); |
247 |
|
|
_connectControl = new JCheckBox("Automatically connect the control channel"); |
248 |
ajm |
1.9 |
c.gridy = 0; |
249 |
ajm |
1.11 |
gridbag.setConstraints(_connectControl, c); |
250 |
|
|
_serverPanel.add(_connectControl); |
251 |
|
|
_connectData = new JCheckBox("Automatically connect the data channel"); |
252 |
ajm |
1.9 |
c.gridy = 1; |
253 |
ajm |
1.11 |
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 |
ajm |
1.9 |
c.gridy = 2; |
263 |
ajm |
1.11 |
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 |
ajm |
1.9 |
c.gridy = 3; |
273 |
ajm |
1.11 |
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 |
|
|
|
290 |
ajm |
1.4 |
|
291 |
ajm |
1.11 |
_useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
292 |
ajm |
1.8 |
c.gridy = 0; |
293 |
ajm |
1.11 |
gridbag.setConstraints(_useFirewall, c); |
294 |
|
|
firewallPanel.add(_useFirewall); |
295 |
ajm |
1.8 |
|
296 |
ajm |
1.3 |
JLabel commandLabel = new JLabel("Firewall command:"); |
297 |
ajm |
1.4 |
commandLabel.setHorizontalAlignment(JLabel.RIGHT); |
298 |
ajm |
1.11 |
_firewallCommand = new JTextField(20); |
299 |
ajm |
1.4 |
JPanel commandBox = new JPanel(); |
300 |
|
|
commandBox.setLayout(new GridLayout(1,2)); |
301 |
ajm |
1.3 |
commandBox.add(commandLabel); |
302 |
ajm |
1.11 |
commandBox.add(_firewallCommand); |
303 |
ajm |
1.5 |
|
304 |
ajm |
1.8 |
c.gridy = 1; |
305 |
|
|
gridbag.setConstraints(commandBox, c); |
306 |
ajm |
1.3 |
firewallPanel.add(commandBox); |
307 |
|
|
|
308 |
|
|
JLabel waitLabel = new JLabel("Firewall wait time:"); |
309 |
ajm |
1.4 |
waitLabel.setHorizontalAlignment(JLabel.RIGHT); |
310 |
ajm |
1.11 |
_firewallWait = new JTextField(2); |
311 |
ajm |
1.4 |
JPanel waitBox = new JPanel(); |
312 |
|
|
waitBox.setLayout(new GridLayout(1,2)); |
313 |
ajm |
1.3 |
waitBox.add(waitLabel); |
314 |
ajm |
1.11 |
waitBox.add(_firewallWait); |
315 |
ajm |
1.8 |
|
316 |
|
|
c.gridy = 2; |
317 |
|
|
gridbag.setConstraints(waitBox, c); |
318 |
ajm |
1.3 |
firewallPanel.add(waitBox); |
319 |
|
|
|
320 |
ajm |
1.11 |
JLabel fServerLabel = new JLabel("Firewall server:"); |
321 |
|
|
fServerLabel.setHorizontalAlignment(JLabel.RIGHT); |
322 |
|
|
_firewallServer = new JTextField(20); |
323 |
|
|
JPanel fServerBox = new JPanel(); |
324 |
|
|
fServerBox.setLayout(new GridLayout(1,2)); |
325 |
|
|
fServerBox.add(fServerLabel); |
326 |
|
|
fServerBox.add(_firewallServer); |
327 |
ajm |
1.5 |
|
328 |
ajm |
1.8 |
c.gridy = 3; |
329 |
ajm |
1.11 |
gridbag.setConstraints(fServerBox, c); |
330 |
|
|
firewallPanel.add(fServerBox); |
331 |
ajm |
1.8 |
|
332 |
ajm |
1.4 |
return firewallPanel; |
333 |
|
|
} |
334 |
|
|
|
335 |
ajm |
1.9 |
/** |
336 |
|
|
* creates a JPanel for the data options |
337 |
|
|
* |
338 |
|
|
* @return the build panel with the options |
339 |
|
|
*/ |
340 |
ajm |
1.4 |
private JPanel createDataOptions() { |
341 |
ajm |
1.8 |
GridBagLayout gridbag = new GridBagLayout(); |
342 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
343 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
344 |
ajm |
1.4 |
JPanel dataPanel = new JPanel(); |
345 |
ajm |
1.8 |
dataPanel.setLayout(gridbag); |
346 |
ajm |
1.11 |
_displayQueue = new JCheckBox("Display server queue information"); |
347 |
ajm |
1.8 |
c.gridy = 0; |
348 |
ajm |
1.11 |
gridbag.setConstraints(_displayQueue, c); |
349 |
|
|
dataPanel.add(_displayQueue); |
350 |
|
|
_displayExtra = new JCheckBox("Display extra data found in packets"); |
351 |
ajm |
1.8 |
c.gridy = 1; |
352 |
ajm |
1.11 |
gridbag.setConstraints(_displayExtra, c); |
353 |
|
|
dataPanel.add(_displayExtra); |
354 |
|
|
_packetDump = new JCheckBox("Dump raw packet data to the console"); |
355 |
ajm |
1.8 |
c.gridy = 2; |
356 |
ajm |
1.11 |
gridbag.setConstraints(_packetDump, c); |
357 |
|
|
dataPanel.add(_packetDump); |
358 |
ajm |
1.10 |
|
359 |
ajm |
1.11 |
JLabel _queueLimitLabel = new JLabel("Maximum data queue size:"); |
360 |
|
|
_queueLimitLabel.setHorizontalAlignment(JLabel.RIGHT); |
361 |
|
|
_queueLimit = new JTextField(4); |
362 |
ajm |
1.10 |
JPanel queueBox = new JPanel(); |
363 |
|
|
queueBox.setLayout(new GridLayout(1,2)); |
364 |
ajm |
1.11 |
queueBox.add(_queueLimitLabel); |
365 |
|
|
queueBox.add(_queueLimit); |
366 |
ajm |
1.10 |
c.gridy = 3; |
367 |
|
|
gridbag.setConstraints(queueBox, c); |
368 |
|
|
dataPanel.add(queueBox); |
369 |
ajm |
1.4 |
return dataPanel; |
370 |
|
|
} |
371 |
|
|
|
372 |
ajm |
1.9 |
/** |
373 |
|
|
* Reads in the current settings from the loaded configuration |
374 |
|
|
*/ |
375 |
ajm |
1.4 |
private void getCurrentSettings() { |
376 |
ajm |
1.11 |
_name.setText(_config.getProperty("clientname")); |
377 |
|
|
_server.setText(_config.getProperty("control.server")); |
378 |
|
|
_port.setText(_config.getProperty("control.port")); |
379 |
|
|
_connectControl.setSelected(_config.getProperty("control.onstartconnect").equals("1")); |
380 |
|
|
_connectData.setSelected(_config.getProperty("data.onstartconnect").equals("1")); |
381 |
|
|
_firewallCommand.setText(_config.getProperty("firewall.command")); |
382 |
|
|
_firewallCommand.moveCaretPosition(0); |
383 |
|
|
_firewallWait.setText(_config.getProperty("firewall.commandwait")); |
384 |
|
|
_firewallServer.setText(_config.getProperty("firewall.server")); |
385 |
|
|
_displayQueue.setSelected(_config.getProperty("displayQueueInformation").equals("1")); |
386 |
|
|
_displayExtra.setSelected(_config.getProperty("displayExtraData").equals("1")); |
387 |
|
|
_packetDump.setSelected(_config.getProperty("packetDump").equals("1")); |
388 |
|
|
_useFirewall.setSelected(_config.getProperty("useFirewall").equals("1")); |
389 |
|
|
_hostDiscoveryMode.setSelected(_config.getProperty("hostDiscoveryMode").equals("1")); |
390 |
|
|
_useHostList.setSelected(_config.getProperty("useHostList").equals("1")); |
391 |
|
|
_queueLimit.setText(_config.getProperty("dataQueueSize")); |
392 |
ajm |
1.5 |
prepareLists(); |
393 |
|
|
} |
394 |
|
|
|
395 |
ajm |
1.9 |
/** |
396 |
|
|
* Displays the host lists in the host windows |
397 |
ajm |
1.11 |
* in alphabetical order |
398 |
ajm |
1.9 |
*/ |
399 |
ajm |
1.5 |
private void prepareLists() { |
400 |
ajm |
1.11 |
_knownHostsData = new ArrayList(); |
401 |
|
|
_hostListData = new ArrayList(); |
402 |
|
|
String _configKnownHostsList = _config.getProperty("knownHostsList"); |
403 |
|
|
String _configHostList = _config.getProperty("hostList"); |
404 |
ajm |
1.5 |
StringTokenizer st; |
405 |
ajm |
1.11 |
st = new StringTokenizer(_configKnownHostsList, ";"); |
406 |
ajm |
1.5 |
while(st.hasMoreTokens()) { |
407 |
ajm |
1.6 |
// check its not in the other list...as we only want one entry in the two |
408 |
|
|
String knownHost = st.nextToken(); |
409 |
ajm |
1.11 |
if(_configHostList.indexOf(knownHost) == -1) _knownHostsData.add(knownHost); |
410 |
ajm |
1.5 |
} |
411 |
ajm |
1.11 |
st = new StringTokenizer(_configHostList, ";"); |
412 |
ajm |
1.5 |
while(st.hasMoreTokens()) { |
413 |
ajm |
1.11 |
_hostListData.add(st.nextToken()); |
414 |
ajm |
1.5 |
} |
415 |
ajm |
1.11 |
setListDisplay(); |
416 |
|
|
} |
417 |
|
|
|
418 |
|
|
/** |
419 |
|
|
* Because of the limitation of the existing |
420 |
|
|
* data model for lists, ArrayLists are used. |
421 |
|
|
* Whenever the data in these lists is changed, |
422 |
|
|
* this method is called to re-sort the lists |
423 |
|
|
* and reset the display. |
424 |
|
|
*/ |
425 |
|
|
private void setListDisplay() { |
426 |
|
|
// ensure the order |
427 |
|
|
Collections.sort(_hostListData); |
428 |
|
|
Collections.sort(_knownHostsData); |
429 |
|
|
|
430 |
|
|
_knownHosts.setListData(_knownHostsData.toArray()); |
431 |
|
|
_hostList.setListData(_hostListData.toArray()); |
432 |
ajm |
1.4 |
} |
433 |
|
|
|
434 |
ajm |
1.9 |
/** |
435 |
|
|
* Writes the changes back to the loaded configuration |
436 |
|
|
* Then closes the windows |
437 |
|
|
*/ |
438 |
ajm |
1.4 |
private void setNewSettingsAndClose() { |
439 |
ajm |
1.5 |
|
440 |
ajm |
1.11 |
_config.setProperty("clientname", _name.getText().trim()); |
441 |
|
|
_config.setProperty("control.server", _server.getText().trim()); |
442 |
|
|
_config.setProperty("control.port", _port.getText().trim()); |
443 |
|
|
_config.setProperty("firewall.command", _firewallCommand.getText().trim()); |
444 |
|
|
_config.setProperty("firewall.commandwait", _firewallWait.getText().trim()); |
445 |
|
|
_config.setProperty("firewall.server", _firewallServer.getText().trim()); |
446 |
|
|
_config.setProperty("dataQueueSize", _queueLimit.getText().trim()); |
447 |
|
|
if (_useFirewall.isSelected()) { |
448 |
|
|
_config.setProperty("useFirewall", "1"); |
449 |
ajm |
1.4 |
} else { |
450 |
ajm |
1.11 |
_config.setProperty("useFirewall", "0"); |
451 |
ajm |
1.4 |
} |
452 |
ajm |
1.11 |
if (_connectControl.isSelected()) { |
453 |
|
|
_config.setProperty("control.onstartconnect", "1"); |
454 |
ajm |
1.4 |
} else { |
455 |
ajm |
1.11 |
_config.setProperty("control.onstartconnect", "0"); |
456 |
ajm |
1.4 |
} |
457 |
ajm |
1.11 |
if (_connectData.isSelected()) { |
458 |
|
|
_config.setProperty("data.onstartconnect", "1"); |
459 |
ajm |
1.4 |
} else { |
460 |
ajm |
1.11 |
_config.setProperty("data.onstartconnect", "0"); |
461 |
ajm |
1.4 |
} |
462 |
ajm |
1.11 |
if (_packetDump.isSelected()) { |
463 |
|
|
_config.setProperty("packetDump", "1"); |
464 |
ajm |
1.4 |
} else { |
465 |
ajm |
1.11 |
_config.setProperty("packetDump", "0"); |
466 |
ajm |
1.4 |
} |
467 |
ajm |
1.11 |
if (_displayExtra.isSelected()) { |
468 |
|
|
_config.setProperty("displayExtraData", "1"); |
469 |
ajm |
1.4 |
} else { |
470 |
ajm |
1.11 |
_config.setProperty("displayExtraData", "0"); |
471 |
ajm |
1.4 |
} |
472 |
ajm |
1.11 |
if (_displayQueue.isSelected()) { |
473 |
|
|
_config.setProperty("displayQueueInformation", "1"); |
474 |
ajm |
1.4 |
} else { |
475 |
ajm |
1.11 |
_config.setProperty("displayQueueInformation", "0"); |
476 |
ajm |
1.4 |
} |
477 |
ajm |
1.11 |
if (_useHostList.isSelected()) { |
478 |
|
|
_config.setProperty("useHostList", "1"); |
479 |
ajm |
1.5 |
} else { |
480 |
ajm |
1.11 |
_config.setProperty("useHostList", "0"); |
481 |
ajm |
1.5 |
} |
482 |
ajm |
1.11 |
if (_hostDiscoveryMode.isSelected()) { |
483 |
|
|
_config.setProperty("hostDiscoveryMode", "1"); |
484 |
ajm |
1.5 |
} else { |
485 |
ajm |
1.11 |
_config.setProperty("hostDiscoveryMode", "0"); |
486 |
ajm |
1.5 |
} |
487 |
ajm |
1.6 |
|
488 |
|
|
// sort out the hosts lists |
489 |
|
|
|
490 |
|
|
// known hosts are both the known hosts list AND the host list |
491 |
ajm |
1.11 |
// first the hostList... |
492 |
|
|
Iterator i; |
493 |
|
|
i = _hostListData.iterator(); |
494 |
|
|
String _hostListSave = ""; |
495 |
|
|
while(i.hasNext()) { |
496 |
|
|
_hostListSave += (String) i.next() + ";"; |
497 |
|
|
} |
498 |
|
|
|
499 |
|
|
i = _knownHostsData.iterator(); |
500 |
|
|
String _knownHostsListSave = ""; |
501 |
|
|
while(i.hasNext()) { |
502 |
|
|
_knownHostsListSave += (String) i.next() + ";"; |
503 |
|
|
} |
504 |
|
|
|
505 |
|
|
_knownHostsListSave += _hostListSave; |
506 |
|
|
_config.setProperty("hostList", _hostListSave); |
507 |
|
|
_config.setProperty("knownHostsList", _knownHostsListSave); |
508 |
ajm |
1.4 |
dispose(); |
509 |
ajm |
1.1 |
} |
510 |
|
|
|
511 |
ajm |
1.4 |
//---ACCESSOR/MUTATOR METHODS--- |
512 |
ajm |
1.1 |
|
513 |
ajm |
1.4 |
//---ATTRIBUTES--- |
514 |
ajm |
1.1 |
|
515 |
ajm |
1.9 |
/** |
516 |
|
|
* A reference to the configuration in use |
517 |
|
|
*/ |
518 |
ajm |
1.11 |
Configuration _config = Configuration.getInstance(); |
519 |
ajm |
1.9 |
|
520 |
|
|
/** |
521 |
|
|
* Used to add a new host to the known host list |
522 |
|
|
*/ |
523 |
ajm |
1.11 |
private JTextField _newHost; |
524 |
ajm |
1.5 |
|
525 |
ajm |
1.9 |
/** |
526 |
|
|
* Lists the known hosts (less the ones we're monitoring) |
527 |
|
|
*/ |
528 |
ajm |
1.11 |
private JList _knownHosts; |
529 |
ajm |
1.9 |
|
530 |
|
|
/** |
531 |
|
|
* The list of hosts we're monitoring |
532 |
|
|
*/ |
533 |
ajm |
1.11 |
private JList _hostList; |
534 |
ajm |
1.9 |
|
535 |
|
|
/** |
536 |
ajm |
1.11 |
* If we are making a note of the hosts the _server |
537 |
ajm |
1.9 |
* sends us. |
538 |
|
|
*/ |
539 |
ajm |
1.11 |
private JCheckBox _hostDiscoveryMode; |
540 |
ajm |
1.9 |
|
541 |
|
|
/** |
542 |
|
|
* If we are using the host list setting to only view data |
543 |
|
|
* from certain hosts |
544 |
|
|
*/ |
545 |
ajm |
1.11 |
private JCheckBox _useHostList; |
546 |
ajm |
1.9 |
|
547 |
|
|
/** |
548 |
ajm |
1.11 |
* The _name to identify this client to the _server |
549 |
ajm |
1.9 |
*/ |
550 |
ajm |
1.11 |
private JTextField _name; |
551 |
ajm |
1.9 |
|
552 |
|
|
/** |
553 |
ajm |
1.11 |
* The _port the i-scream _server is running on |
554 |
ajm |
1.9 |
*/ |
555 |
ajm |
1.11 |
private JTextField _port; |
556 |
ajm |
1.9 |
|
557 |
|
|
/** |
558 |
ajm |
1.11 |
* The host_name of the i-scream server |
559 |
ajm |
1.9 |
*/ |
560 |
ajm |
1.11 |
private JTextField _server; |
561 |
ajm |
1.9 |
|
562 |
|
|
/** |
563 |
|
|
* If we want to start the control channel on startup |
564 |
|
|
*/ |
565 |
ajm |
1.11 |
private JCheckBox _connectControl; |
566 |
ajm |
1.9 |
|
567 |
|
|
/** |
568 |
|
|
* If we want to start the data channel on startup |
569 |
|
|
*/ |
570 |
ajm |
1.11 |
private JCheckBox _connectData; |
571 |
ajm |
1.9 |
|
572 |
|
|
/** |
573 |
|
|
* If we want to use the firewall command to connect |
574 |
|
|
*/ |
575 |
ajm |
1.11 |
private JCheckBox _useFirewall; |
576 |
ajm |
1.9 |
|
577 |
|
|
/** |
578 |
|
|
* The command to run to open a pipe to the iscream server |
579 |
|
|
*/ |
580 |
ajm |
1.11 |
private JTextField _firewallCommand; |
581 |
ajm |
1.9 |
|
582 |
|
|
/** |
583 |
|
|
* How long to wait for the firewall command to execute |
584 |
|
|
*/ |
585 |
ajm |
1.11 |
private JTextField _firewallWait; |
586 |
ajm |
1.9 |
|
587 |
|
|
/** |
588 |
|
|
* The name of the machine to locally connect through to |
589 |
|
|
* reach the i-scream server |
590 |
|
|
*/ |
591 |
ajm |
1.11 |
private JTextField _firewallServer; |
592 |
ajm |
1.9 |
|
593 |
|
|
/** |
594 |
|
|
* Whether to display server queue debugging information |
595 |
|
|
*/ |
596 |
ajm |
1.11 |
private JCheckBox _displayQueue; |
597 |
ajm |
1.9 |
|
598 |
|
|
/** |
599 |
|
|
* Whether to display extra data contained in packets |
600 |
|
|
*/ |
601 |
ajm |
1.11 |
private JCheckBox _displayExtra; |
602 |
ajm |
1.9 |
|
603 |
|
|
/** |
604 |
|
|
* Whether to dump raw packet data to the console |
605 |
|
|
*/ |
606 |
ajm |
1.11 |
private JCheckBox _packetDump; |
607 |
ajm |
1.10 |
|
608 |
|
|
/** |
609 |
|
|
* The limit on the data queue size |
610 |
|
|
*/ |
611 |
ajm |
1.11 |
private JTextField _queueLimit; |
612 |
ajm |
1.9 |
|
613 |
|
|
/** |
614 |
|
|
* holds the known hosts |
615 |
|
|
*/ |
616 |
ajm |
1.11 |
private ArrayList _knownHostsData; |
617 |
ajm |
1.9 |
|
618 |
|
|
/** |
619 |
|
|
* holds the monitored hosts |
620 |
|
|
*/ |
621 |
ajm |
1.11 |
private ArrayList _hostListData; |
622 |
ajm |
1.1 |
|
623 |
|
|
//---STATIC ATTRIBUTES--- |
624 |
|
|
|
625 |
|
|
} |