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.5 by ajm, Tue Feb 27 23:31:32 2001 UTC vs.
Revision 1.6 by ajm, Thu Mar 1 02:00:02 2001 UTC

# Line 123 | Line 123 | public class ConfigurationDialog extends JDialog {
123          newHostLabel.setHorizontalAlignment(JLabel.RIGHT);
124          newHost = new JTextField(20);
125          JButton newHostButton = new JButton("Add to known hosts");
126 +        newHostButton.addActionListener(new ActionListener() {
127 +            public void actionPerformed(ActionEvent e) {
128 +                knownHostsModel.addElement(newHost.getText());
129 +                newHost.setText("");
130 +            }
131 +        });
132          JPanel newHostBox = new JPanel();
133          newHostBox.setLayout(new GridLayout(1,3));
134          newHostBox.add(newHostLabel);
# Line 137 | Line 143 | public class ConfigurationDialog extends JDialog {
143          addRemoveBox.setLayout(new BoxLayout(addRemoveBox, BoxLayout.Y_AXIS));
144          addRemoveBox.add(Box.createGlue());
145          JButton add = new JButton(">>>");
146 +        add.addActionListener(new ActionListener() {
147 +            public void actionPerformed(ActionEvent e) {
148 +                Object[] selected = knownHosts.getSelectedValues();
149 +                for(int x = 0; x < selected.length; x++) {
150 +                    knownHostsModel.removeElement(selected[x]);
151 +                    hostListModel.addElement(selected[x]);
152 +                }
153 +            }
154 +        });
155 +        
156          addRemoveBox.add(add);
157          addRemoveBox.add(Box.createGlue());
158          JButton remove = new JButton("<<<");
159 +        remove.addActionListener(new ActionListener() {
160 +            public void actionPerformed(ActionEvent e) {
161 +                Object[] selected = hostList.getSelectedValues();
162 +                for(int x = 0; x < selected.length; x++) {
163 +                    hostListModel.removeElement(selected[x]);
164 +                    knownHostsModel.addElement(selected[x]);
165 +                }
166 +            }
167 +        });
168          addRemoveBox.add(remove);
169          addRemoveBox.add(Box.createGlue());
170          lists.add(addRemoveBox);
# Line 270 | Line 295 | public class ConfigurationDialog extends JDialog {
295          StringTokenizer st;
296          st = new StringTokenizer(configKnownHostsList, ";");
297          while(st.hasMoreTokens()) {
298 <            knownHostsModel.addElement(st.nextToken());
298 >            // check its not in the other list...as we only want one entry in the two
299 >            String knownHost = st.nextToken();
300 >            if(configHostList.indexOf(knownHost) == -1) knownHostsModel.addElement(knownHost);
301          }
302          st = new StringTokenizer(configHostList, ";");
303          while(st.hasMoreTokens()) {
# Line 328 | Line 355 | public class ConfigurationDialog extends JDialog {
355          } else {
356              config.setProperty("hostDiscoveryMode", "0");
357          }
358 +        
359 +        // sort out the hosts lists
360 +        
361 +        // known hosts are both the known hosts list AND the host list
362 +        // first the hostlist...
363 +        Object[] hostListSaveArray =  hostListModel.toArray();
364 +        String hostListSave = "";
365 +        for(int x = 0; x < hostListSaveArray.length; x++) {
366 +            hostListSave += (String) hostListSaveArray[x] + ";";
367 +        }
368 +        Object[] knownHostsListSaveArray = knownHostsModel.toArray();
369 +        String knownHostsListSave = "";
370 +        for(int x = 0; x < knownHostsListSaveArray.length; x++) {
371 +            knownHostsListSave += (String) knownHostsListSaveArray[x] + ";";
372 +        }
373 +        knownHostsListSave += hostListSave;
374 +        config.setProperty("hostList", hostListSave);
375 +        config.setProperty("knownHostsList", knownHostsListSave);
376          dispose();
377      }
378  
# Line 358 | Line 403 | public class ConfigurationDialog extends JDialog {
403  
404      private DefaultListModel knownHostsModel;
405      private DefaultListModel hostListModel;
361    
406  
407   //---STATIC ATTRIBUTES---
408  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines