ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/ConfigurationDialog.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/ConfigurationDialog.java (file contents):
Revision 1.7 by ajm, Thu Mar 15 01:05:46 2001 UTC vs.
Revision 1.15 by tdb, Sat May 18 18:15:56 2002 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines