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 |
|
*/ |
73 |
|
// client options |
74 |
|
center.addTab("Client Options", createClientOptions()); |
75 |
|
|
76 |
< |
// server options |
77 |
< |
center.addTab("Server Options", createServerOptions()); |
76 |
> |
// _server options |
77 |
> |
center.addTab("Server Options", create_serverOptions()); |
78 |
|
|
79 |
|
// firewall options |
80 |
|
center.addTab("Firewall Options", createFirewallOptions()); |
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(); |
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); |
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); |
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); |
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() { |
142 |
> |
JButton _newHostButton = new JButton("Add Host"); |
143 |
> |
_newHostButton.addActionListener(new ActionListener() { |
144 |
|
public void actionPerformed(ActionEvent e) { |
145 |
< |
knownHostsModel.addElement(newHost.getText()); |
146 |
< |
newHost.setText(""); |
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(); |
153 |
> |
Object[] selected = _knownHosts.getSelectedValues(); |
154 |
|
for(int x = 0; x < selected.length; x++) { |
155 |
< |
knownHostsModel.removeElement(selected[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); |
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); |
166 |
> |
buttonPanel.add(_newHostButton); |
167 |
|
buttonPanel.add(removeHostButton); |
168 |
< |
knownHostsPanel.add(buttonPanel); |
169 |
< |
knownHostsPanel.add(newHostBox); |
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); |
174 |
> |
gridbag.setConstraints(_knownHostsPanel, c); |
175 |
> |
lists.add(_knownHostsPanel); |
176 |
|
|
177 |
|
|
178 |
|
JPanel addRemoveBox = new JPanel(); |
181 |
|
JButton add = new JButton(">>>"); |
182 |
|
add.addActionListener(new ActionListener() { |
183 |
|
public void actionPerformed(ActionEvent e) { |
184 |
< |
Object[] selected = knownHosts.getSelectedValues(); |
184 |
> |
Object[] selected = _knownHosts.getSelectedValues(); |
185 |
|
for(int x = 0; x < selected.length; x++) { |
186 |
< |
knownHostsModel.removeElement(selected[x]); |
187 |
< |
hostListModel.addElement(selected[x]); |
186 |
> |
_knownHostsData.remove(_knownHostsData.indexOf(selected[x])); |
187 |
> |
_hostListData.add(selected[x]); |
188 |
> |
setListDisplay(); |
189 |
|
} |
190 |
|
} |
191 |
|
}); |
195 |
|
JButton remove = new JButton("<<<"); |
196 |
|
remove.addActionListener(new ActionListener() { |
197 |
|
public void actionPerformed(ActionEvent e) { |
198 |
< |
Object[] selected = hostList.getSelectedValues(); |
198 |
> |
Object[] selected = _hostList.getSelectedValues(); |
199 |
|
for(int x = 0; x < selected.length; x++) { |
200 |
< |
hostListModel.removeElement(selected[x]); |
201 |
< |
knownHostsModel.addElement(selected[x]); |
200 |
> |
_hostListData.remove(_hostListData.indexOf(selected[x])); |
201 |
> |
_knownHostsData.add(selected[x]); |
202 |
> |
setListDisplay(); |
203 |
|
} |
204 |
|
} |
205 |
|
}); |
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); |
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); |
226 |
> |
gridbag.setConstraints(_hostListPanel, c); |
227 |
> |
lists.add(_hostListPanel); |
228 |
|
|
229 |
|
c.gridy = 1; |
230 |
|
c.gridx = 0; |
232 |
|
clientPanel.add(lists); |
233 |
|
return clientPanel; |
234 |
|
} |
235 |
< |
|
236 |
< |
private JPanel createServerOptions() { |
235 |
> |
|
236 |
> |
/** |
237 |
> |
* creates a JPanel for the server options |
238 |
> |
* |
239 |
> |
* @return the build panel with the options |
240 |
> |
*/ |
241 |
> |
private JPanel create_serverOptions() { |
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 |
< |
JLabel serverLabel = new JLabel("i-scream Server:"); |
229 |
< |
serverLabel.setHorizontalAlignment(JLabel.RIGHT); |
230 |
< |
server = new JTextField(20); |
231 |
< |
JPanel serverBox = new JPanel(); |
232 |
< |
serverBox.setLayout(new GridLayout(1,2)); |
233 |
< |
serverBox.add(serverLabel); |
234 |
< |
serverBox.add(server); |
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(serverBox, c); |
250 |
< |
serverPanel.add(serverBox); |
251 |
< |
JLabel portLabel = new JLabel("Client interface port:"); |
239 |
< |
portLabel.setHorizontalAlignment(JLabel.RIGHT); |
240 |
< |
port = new JTextField(4); |
241 |
< |
JPanel portBox = new JPanel(); |
242 |
< |
portBox.setLayout(new GridLayout(1,2)); |
243 |
< |
portBox.add(portLabel); |
244 |
< |
portBox.add(port); |
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(portBox, c); |
254 |
< |
serverPanel.add(portBox); |
255 |
< |
connectControl = new JCheckBox("Automatically connect the control channel"); |
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(connectControl, c); |
264 |
< |
serverPanel.add(connectControl); |
265 |
< |
connectData = new JCheckBox("Automatically connect the data channel"); |
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(connectData, c); |
274 |
< |
serverPanel.add(connectData); |
275 |
< |
return serverPanel; |
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(); |
288 |
|
firewallPanel.setLayout(gridbag); |
289 |
|
|
290 |
|
|
291 |
< |
useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
291 |
> |
_useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
292 |
|
c.gridy = 0; |
293 |
< |
gridbag.setConstraints(useFirewall, c); |
294 |
< |
firewallPanel.add(useFirewall); |
293 |
> |
gridbag.setConstraints(_useFirewall, c); |
294 |
> |
firewallPanel.add(_useFirewall); |
295 |
|
|
296 |
|
JLabel commandLabel = new JLabel("Firewall command:"); |
297 |
|
commandLabel.setHorizontalAlignment(JLabel.RIGHT); |
298 |
< |
firewallCommand = new JTextField(20); |
275 |
< |
firewallCommand.setSize(new Dimension(1,10)); |
298 |
> |
_firewallCommand = new JTextField(20); |
299 |
|
JPanel commandBox = new JPanel(); |
300 |
|
commandBox.setLayout(new GridLayout(1,2)); |
301 |
|
commandBox.add(commandLabel); |
302 |
< |
commandBox.add(firewallCommand); |
302 |
> |
commandBox.add(_firewallCommand); |
303 |
|
|
304 |
|
c.gridy = 1; |
305 |
|
gridbag.setConstraints(commandBox, c); |
307 |
|
|
308 |
|
JLabel waitLabel = new JLabel("Firewall wait time:"); |
309 |
|
waitLabel.setHorizontalAlignment(JLabel.RIGHT); |
310 |
< |
firewallWait = new JTextField(2); |
310 |
> |
_firewallWait = new JTextField(2); |
311 |
|
JPanel waitBox = new JPanel(); |
312 |
|
waitBox.setLayout(new GridLayout(1,2)); |
313 |
|
waitBox.add(waitLabel); |
314 |
< |
waitBox.add(firewallWait); |
314 |
> |
waitBox.add(_firewallWait); |
315 |
|
|
316 |
|
c.gridy = 2; |
317 |
|
gridbag.setConstraints(waitBox, c); |
318 |
|
firewallPanel.add(waitBox); |
319 |
|
|
320 |
< |
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); |
320 |
> |
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 |
|
|
328 |
|
c.gridy = 3; |
329 |
< |
gridbag.setConstraints(fserverBox, c); |
330 |
< |
firewallPanel.add(fserverBox); |
329 |
> |
gridbag.setConstraints(fServerBox, c); |
330 |
> |
firewallPanel.add(fServerBox); |
331 |
|
|
332 |
|
return firewallPanel; |
333 |
|
} |
334 |
|
|
335 |
+ |
/** |
336 |
+ |
* creates a JPanel for the data options |
337 |
+ |
* |
338 |
+ |
* @return the build panel with the options |
339 |
+ |
*/ |
340 |
|
private JPanel createDataOptions() { |
341 |
|
GridBagLayout gridbag = new GridBagLayout(); |
342 |
|
GridBagConstraints c = new GridBagConstraints(); |
343 |
|
c.fill = GridBagConstraints.HORIZONTAL; |
344 |
|
JPanel dataPanel = new JPanel(); |
345 |
|
dataPanel.setLayout(gridbag); |
346 |
< |
displayQueue = new JCheckBox("Display server queue information"); |
346 |
> |
_displayQueue = new JCheckBox("Display server queue information"); |
347 |
|
c.gridy = 0; |
348 |
< |
gridbag.setConstraints(displayQueue, c); |
349 |
< |
dataPanel.add(displayQueue); |
350 |
< |
displayExtra = new JCheckBox("Display extra data found in packets"); |
348 |
> |
gridbag.setConstraints(_displayQueue, c); |
349 |
> |
dataPanel.add(_displayQueue); |
350 |
> |
_displayExtra = new JCheckBox("Display extra data found in packets"); |
351 |
|
c.gridy = 1; |
352 |
< |
gridbag.setConstraints(displayExtra, c); |
353 |
< |
dataPanel.add(displayExtra); |
354 |
< |
packetDump = new JCheckBox("Dump raw packet data to the console"); |
352 |
> |
gridbag.setConstraints(_displayExtra, c); |
353 |
> |
dataPanel.add(_displayExtra); |
354 |
> |
_packetDump = new JCheckBox("Dump raw packet data to the console"); |
355 |
|
c.gridy = 2; |
356 |
< |
gridbag.setConstraints(packetDump, c); |
357 |
< |
dataPanel.add(packetDump); |
356 |
> |
gridbag.setConstraints(_packetDump, c); |
357 |
> |
dataPanel.add(_packetDump); |
358 |
> |
|
359 |
> |
JLabel _queueLimitLabel = new JLabel("Maximum data queue size:"); |
360 |
> |
_queueLimitLabel.setHorizontalAlignment(JLabel.RIGHT); |
361 |
> |
_queueLimit = new JTextField(4); |
362 |
> |
JPanel queueBox = new JPanel(); |
363 |
> |
queueBox.setLayout(new GridLayout(1,2)); |
364 |
> |
queueBox.add(_queueLimitLabel); |
365 |
> |
queueBox.add(_queueLimit); |
366 |
> |
c.gridy = 3; |
367 |
> |
gridbag.setConstraints(queueBox, c); |
368 |
> |
dataPanel.add(queueBox); |
369 |
|
return dataPanel; |
370 |
|
} |
371 |
|
|
372 |
+ |
/** |
373 |
+ |
* Reads in the current settings from the loaded configuration |
374 |
+ |
*/ |
375 |
|
private void getCurrentSettings() { |
376 |
< |
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")); |
376 |
> |
_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 |
|
prepareLists(); |
393 |
|
} |
394 |
|
|
395 |
< |
|
395 |
> |
/** |
396 |
> |
* Displays the host lists in the host windows |
397 |
> |
* in alphabetical order |
398 |
> |
*/ |
399 |
|
private void prepareLists() { |
400 |
< |
knownHostsModel = new DefaultListModel(); |
401 |
< |
hostListModel = new DefaultListModel(); |
402 |
< |
String configKnownHostsList = config.getProperty("knownHostsList"); |
403 |
< |
String configHostList = config.getProperty("hostList"); |
400 |
> |
_knownHostsData = new ArrayList(); |
401 |
> |
_hostListData = new ArrayList(); |
402 |
> |
String _configKnownHostsList = _config.getProperty("knownHostsList"); |
403 |
> |
String _configHostList = _config.getProperty("hostList"); |
404 |
|
StringTokenizer st; |
405 |
< |
st = new StringTokenizer(configKnownHostsList, ";"); |
405 |
> |
st = new StringTokenizer(_configKnownHostsList, ";"); |
406 |
|
while(st.hasMoreTokens()) { |
407 |
|
// check its not in the other list...as we only want one entry in the two |
408 |
|
String knownHost = st.nextToken(); |
409 |
< |
if(configHostList.indexOf(knownHost) == -1) knownHostsModel.addElement(knownHost); |
409 |
> |
if(_configHostList.indexOf(knownHost) == -1) _knownHostsData.add(knownHost); |
410 |
|
} |
411 |
< |
st = new StringTokenizer(configHostList, ";"); |
411 |
> |
st = new StringTokenizer(_configHostList, ";"); |
412 |
|
while(st.hasMoreTokens()) { |
413 |
< |
hostListModel.addElement(st.nextToken()); |
413 |
> |
_hostListData.add(st.nextToken()); |
414 |
|
} |
415 |
< |
knownHosts.setModel(knownHostsModel); |
370 |
< |
hostList.setModel(hostListModel); |
415 |
> |
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 |
+ |
} |
433 |
+ |
|
434 |
+ |
/** |
435 |
+ |
* Writes the changes back to the loaded configuration |
436 |
+ |
* Then closes the windows |
437 |
+ |
*/ |
438 |
|
private void setNewSettingsAndClose() { |
439 |
|
|
440 |
< |
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 |
< |
if (useFirewall.isSelected()) { |
447 |
< |
config.setProperty("useFirewall", "1"); |
440 |
> |
_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 |
|
} else { |
450 |
< |
config.setProperty("useFirewall", "0"); |
450 |
> |
_config.setProperty("useFirewall", "0"); |
451 |
|
} |
452 |
< |
if (connectControl.isSelected()) { |
453 |
< |
config.setProperty("control.onstartconnect", "1"); |
452 |
> |
if (_connectControl.isSelected()) { |
453 |
> |
_config.setProperty("control.onstartconnect", "1"); |
454 |
|
} else { |
455 |
< |
config.setProperty("control.onstartconnect", "0"); |
455 |
> |
_config.setProperty("control.onstartconnect", "0"); |
456 |
|
} |
457 |
< |
if (connectData.isSelected()) { |
458 |
< |
config.setProperty("data.onstartconnect", "1"); |
457 |
> |
if (_connectData.isSelected()) { |
458 |
> |
_config.setProperty("data.onstartconnect", "1"); |
459 |
|
} else { |
460 |
< |
config.setProperty("data.onstartconnect", "0"); |
460 |
> |
_config.setProperty("data.onstartconnect", "0"); |
461 |
|
} |
462 |
< |
if (packetDump.isSelected()) { |
463 |
< |
config.setProperty("packetDump", "1"); |
462 |
> |
if (_packetDump.isSelected()) { |
463 |
> |
_config.setProperty("packetDump", "1"); |
464 |
|
} else { |
465 |
< |
config.setProperty("packetDump", "0"); |
465 |
> |
_config.setProperty("packetDump", "0"); |
466 |
|
} |
467 |
< |
if (displayExtra.isSelected()) { |
468 |
< |
config.setProperty("displayExtraData", "1"); |
467 |
> |
if (_displayExtra.isSelected()) { |
468 |
> |
_config.setProperty("displayExtraData", "1"); |
469 |
|
} else { |
470 |
< |
config.setProperty("displayExtraData", "0"); |
470 |
> |
_config.setProperty("displayExtraData", "0"); |
471 |
|
} |
472 |
< |
if (displayQueue.isSelected()) { |
473 |
< |
config.setProperty("displayQueueInformation", "1"); |
472 |
> |
if (_displayQueue.isSelected()) { |
473 |
> |
_config.setProperty("displayQueueInformation", "1"); |
474 |
|
} else { |
475 |
< |
config.setProperty("displayQueueInformation", "0"); |
475 |
> |
_config.setProperty("displayQueueInformation", "0"); |
476 |
|
} |
477 |
< |
if (useHostList.isSelected()) { |
478 |
< |
config.setProperty("useHostList", "1"); |
477 |
> |
if (_useHostList.isSelected()) { |
478 |
> |
_config.setProperty("useHostList", "1"); |
479 |
|
} else { |
480 |
< |
config.setProperty("useHostList", "0"); |
480 |
> |
_config.setProperty("useHostList", "0"); |
481 |
|
} |
482 |
< |
if (hostDiscoveryMode.isSelected()) { |
483 |
< |
config.setProperty("hostDiscoveryMode", "1"); |
482 |
> |
if (_hostDiscoveryMode.isSelected()) { |
483 |
> |
_config.setProperty("hostDiscoveryMode", "1"); |
484 |
|
} else { |
485 |
< |
config.setProperty("hostDiscoveryMode", "0"); |
485 |
> |
_config.setProperty("hostDiscoveryMode", "0"); |
486 |
|
} |
487 |
|
|
488 |
|
// sort out the hosts lists |
489 |
|
|
490 |
|
// known hosts are both the known hosts list AND the host list |
491 |
< |
// first the hostlist... |
492 |
< |
Object[] hostListSaveArray = hostListModel.toArray(); |
493 |
< |
String hostListSave = ""; |
494 |
< |
for(int x = 0; x < hostListSaveArray.length; x++) { |
495 |
< |
hostListSave += (String) hostListSaveArray[x] + ";"; |
491 |
> |
// first the hostList... |
492 |
> |
Iterator i; |
493 |
> |
i = _hostListData.iterator(); |
494 |
> |
String _hostListSave = ""; |
495 |
> |
while(i.hasNext()) { |
496 |
> |
_hostListSave += (String) i.next() + ";"; |
497 |
|
} |
498 |
< |
Object[] knownHostsListSaveArray = knownHostsModel.toArray(); |
499 |
< |
String knownHostsListSave = ""; |
500 |
< |
for(int x = 0; x < knownHostsListSaveArray.length; x++) { |
501 |
< |
knownHostsListSave += (String) knownHostsListSaveArray[x] + ";"; |
498 |
> |
|
499 |
> |
i = _knownHostsData.iterator(); |
500 |
> |
String _knownHostsListSave = ""; |
501 |
> |
while(i.hasNext()) { |
502 |
> |
_knownHostsListSave += (String) i.next() + ";"; |
503 |
|
} |
504 |
< |
knownHostsListSave += hostListSave; |
505 |
< |
config.setProperty("hostList", hostListSave); |
506 |
< |
config.setProperty("knownHostsList", knownHostsListSave); |
504 |
> |
|
505 |
> |
_knownHostsListSave += _hostListSave; |
506 |
> |
_config.setProperty("hostList", _hostListSave); |
507 |
> |
_config.setProperty("knownHostsList", _knownHostsListSave); |
508 |
|
dispose(); |
509 |
|
} |
510 |
|
|
512 |
|
|
513 |
|
//---ATTRIBUTES--- |
514 |
|
|
515 |
< |
Configuration config = Configuration.getInstance(); |
516 |
< |
|
517 |
< |
private JTextField newHost; |
515 |
> |
/** |
516 |
> |
* A reference to the configuration in use |
517 |
> |
*/ |
518 |
> |
Configuration _config = Configuration.getInstance(); |
519 |
|
|
520 |
< |
private JList knownHosts; |
521 |
< |
private JList hostList; |
522 |
< |
private JCheckBox hostDiscoveryMode; |
523 |
< |
private JCheckBox useHostList; |
524 |
< |
private JTextField name; |
525 |
< |
private JTextField port; |
526 |
< |
private JTextField server; |
527 |
< |
private JCheckBox connectControl; |
528 |
< |
private JCheckBox connectData; |
529 |
< |
private JCheckBox useFirewall; |
530 |
< |
private JTextField firewallCommand; |
531 |
< |
private JTextField firewallWait; |
532 |
< |
private JTextField firewallServer; |
533 |
< |
private JCheckBox displayQueue; |
534 |
< |
private JCheckBox displayExtra; |
535 |
< |
private JCheckBox packetDump; |
536 |
< |
|
537 |
< |
private DefaultListModel knownHostsModel; |
538 |
< |
private DefaultListModel hostListModel; |
520 |
> |
/** |
521 |
> |
* Used to add a new host to the known host list |
522 |
> |
*/ |
523 |
> |
private JTextField _newHost; |
524 |
> |
|
525 |
> |
/** |
526 |
> |
* Lists the known hosts (less the ones we're monitoring) |
527 |
> |
*/ |
528 |
> |
private JList _knownHosts; |
529 |
> |
|
530 |
> |
/** |
531 |
> |
* The list of hosts we're monitoring |
532 |
> |
*/ |
533 |
> |
private JList _hostList; |
534 |
> |
|
535 |
> |
/** |
536 |
> |
* If we are making a note of the hosts the _server |
537 |
> |
* sends us. |
538 |
> |
*/ |
539 |
> |
private JCheckBox _hostDiscoveryMode; |
540 |
> |
|
541 |
> |
/** |
542 |
> |
* If we are using the host list setting to only view data |
543 |
> |
* from certain hosts |
544 |
> |
*/ |
545 |
> |
private JCheckBox _useHostList; |
546 |
> |
|
547 |
> |
/** |
548 |
> |
* The _name to identify this client to the _server |
549 |
> |
*/ |
550 |
> |
private JTextField _name; |
551 |
> |
|
552 |
> |
/** |
553 |
> |
* The _port the i-scream _server is running on |
554 |
> |
*/ |
555 |
> |
private JTextField _port; |
556 |
> |
|
557 |
> |
/** |
558 |
> |
* The host_name of the i-scream server |
559 |
> |
*/ |
560 |
> |
private JTextField _server; |
561 |
> |
|
562 |
> |
/** |
563 |
> |
* If we want to start the control channel on startup |
564 |
> |
*/ |
565 |
> |
private JCheckBox _connectControl; |
566 |
> |
|
567 |
> |
/** |
568 |
> |
* If we want to start the data channel on startup |
569 |
> |
*/ |
570 |
> |
private JCheckBox _connectData; |
571 |
> |
|
572 |
> |
/** |
573 |
> |
* If we want to use the firewall command to connect |
574 |
> |
*/ |
575 |
> |
private JCheckBox _useFirewall; |
576 |
> |
|
577 |
> |
/** |
578 |
> |
* The command to run to open a pipe to the iscream server |
579 |
> |
*/ |
580 |
> |
private JTextField _firewallCommand; |
581 |
> |
|
582 |
> |
/** |
583 |
> |
* How long to wait for the firewall command to execute |
584 |
> |
*/ |
585 |
> |
private JTextField _firewallWait; |
586 |
> |
|
587 |
> |
/** |
588 |
> |
* The name of the machine to locally connect through to |
589 |
> |
* reach the i-scream server |
590 |
> |
*/ |
591 |
> |
private JTextField _firewallServer; |
592 |
> |
|
593 |
> |
/** |
594 |
> |
* Whether to display server queue debugging information |
595 |
> |
*/ |
596 |
> |
private JCheckBox _displayQueue; |
597 |
> |
|
598 |
> |
/** |
599 |
> |
* Whether to display extra data contained in packets |
600 |
> |
*/ |
601 |
> |
private JCheckBox _displayExtra; |
602 |
> |
|
603 |
> |
/** |
604 |
> |
* Whether to dump raw packet data to the console |
605 |
> |
*/ |
606 |
> |
private JCheckBox _packetDump; |
607 |
> |
|
608 |
> |
/** |
609 |
> |
* The limit on the data queue size |
610 |
> |
*/ |
611 |
> |
private JTextField _queueLimit; |
612 |
> |
|
613 |
> |
/** |
614 |
> |
* holds the known hosts |
615 |
> |
*/ |
616 |
> |
private ArrayList _knownHostsData; |
617 |
> |
|
618 |
> |
/** |
619 |
> |
* holds the monitored hosts |
620 |
> |
*/ |
621 |
> |
private ArrayList _hostListData; |
622 |
|
|
623 |
|
//---STATIC ATTRIBUTES--- |
624 |
|
|