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