1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.conient; |
2 |
> |
package uk.org.iscream.conient; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import java.awt.Frame; |
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); |
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); |
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()) { |
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 |
|
|
403 |
|
|
404 |
|
private DefaultListModel knownHostsModel; |
405 |
|
private DefaultListModel hostListModel; |
361 |
– |
|
406 |
|
|
407 |
|
//---STATIC ATTRIBUTES--- |
408 |
|
|