39 |
|
JButton close = new JButton("Close Window"); |
40 |
|
close.addActionListener(new ActionListener() { |
41 |
|
public void actionPerformed(ActionEvent e) { |
42 |
< |
dispose(); |
42 |
> |
setVisible(false); |
43 |
|
} |
44 |
|
}); |
45 |
|
getContentPane().add(close, "South"); |
46 |
< |
setIconImage((new ImageIcon("./uk/ac/ukc/iscream/conient/server.gif")).getImage()); |
46 |
> |
setIconImage((new ImageIcon("./resources/server.gif")).getImage()); |
47 |
|
pack(); |
48 |
|
setVisible(true); |
49 |
|
} |
107 |
|
|
108 |
|
private void updateQueueInformation(XMLPacket packet) throws DataFormatException { |
109 |
|
String queueName = packet.getParam("packet.attributes.name"); |
110 |
< |
HashMap components = (HashMap) _queues.get(queueName); |
111 |
< |
Set packetSet = packet.getSet(); |
112 |
< |
Iterator i = packetSet.iterator(); |
113 |
< |
while (i.hasNext()) { |
114 |
< |
String dataKey = (String) i.next(); |
115 |
< |
// if there are no components looking after this data |
116 |
< |
// create a new StringDataComponent for it |
117 |
< |
if(!components.containsKey(dataKey)) { |
118 |
< |
// check if its a disk drive, if it is then we need to deal with it |
119 |
< |
if(dataKey.startsWith("packet.queue.attributes.queue")) { |
120 |
< |
VisibleDataComponent queue = new StringDataComponent("Current length of " + dataKey.substring(dataKey.lastIndexOf('.') + 1), dataKey); |
121 |
< |
components.put(dataKey, queue); |
122 |
< |
try { |
123 |
< |
SwingSafeAdd task = new SwingSafeAdd((JPanel)_queuesDisplays.get(queueName), queue); |
124 |
< |
SwingUtilities.invokeAndWait(task); |
125 |
< |
} catch (Exception e) { |
126 |
< |
// don't care |
110 |
> |
|
111 |
> |
// if it was a shutdown packet, remove the display |
112 |
> |
if (packet.getParam("packet.attributes.shutdown") != null) { |
113 |
> |
// *** !!! MAY NOT BE SWING SAFE !!! *** |
114 |
> |
JPanel temp = (JPanel)_queuesDisplays.get(queueName); |
115 |
> |
temp.setVisible(false); |
116 |
> |
_content.remove(temp); |
117 |
> |
_queuesDisplays.remove(temp); |
118 |
> |
pack(); |
119 |
> |
|
120 |
> |
// else update the display |
121 |
> |
} else { |
122 |
> |
HashMap components = (HashMap) _queues.get(queueName); |
123 |
> |
Set packetSet = packet.getSet(); |
124 |
> |
Iterator i = packetSet.iterator(); |
125 |
> |
while (i.hasNext()) { |
126 |
> |
String dataKey = (String) i.next(); |
127 |
> |
// if there are no components looking after this data |
128 |
> |
// create a new StringDataComponent for it |
129 |
> |
if(!components.containsKey(dataKey)) { |
130 |
> |
// check if its a disk drive, if it is then we need to deal with it |
131 |
> |
if(dataKey.startsWith("packet.queue.attributes.queue")) { |
132 |
> |
VisibleDataComponent queue = new StringDataComponent("Current length of " + dataKey.substring(dataKey.lastIndexOf('.') + 1), dataKey); |
133 |
> |
components.put(dataKey, queue); |
134 |
> |
try { |
135 |
> |
SwingSafeAdd task = new SwingSafeAdd((JPanel)_queuesDisplays.get(queueName), queue); |
136 |
> |
SwingUtilities.invokeAndWait(task); |
137 |
> |
} catch (Exception e) { |
138 |
> |
// don't care |
139 |
> |
} |
140 |
> |
pack(); |
141 |
|
} |
142 |
< |
pack(); |
142 |
> |
// note we ignore all other attributes |
143 |
|
} |
144 |
< |
// note we ignore all other attributes |
145 |
< |
} |
146 |
< |
if(components.containsKey(dataKey)) { |
133 |
< |
((DataComponent) components.get(dataKey)).setValue(packet.getParam(dataKey)); |
144 |
> |
if(components.containsKey(dataKey)) { |
145 |
> |
((DataComponent) components.get(dataKey)).setValue(packet.getParam(dataKey)); |
146 |
> |
} |
147 |
|
} |
148 |
|
} |
149 |
|
} |