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