185 |
|
_center.add(users); |
186 |
|
|
187 |
|
_center.add(new javax.swing.JLabel("--- Disks ---")); |
188 |
– |
_disks = new JPanel(); |
189 |
– |
_disks.setLayout(new BoxLayout(_disks, BoxLayout.Y_AXIS)); |
188 |
|
_center.add(_disks); |
189 |
|
|
190 |
+ |
_center.add(new javax.swing.JLabel("--- System Services ---")); |
191 |
+ |
_center.add(_services); |
192 |
+ |
|
193 |
|
// everything else we get is "extra", but we may still want to display it |
194 |
|
if (extraData) { |
195 |
|
_center.add(new javax.swing.JLabel("--- Extra Data ---")); |
196 |
+ |
_center.add(_extra); |
197 |
|
} |
198 |
|
} |
199 |
|
|
214 |
|
*/ |
215 |
|
public boolean updateHost(XMLPacket packet) { |
216 |
|
// set that everything is ok so far |
217 |
< |
displaySucessful = true; |
217 |
> |
boolean displaySucessful = true; |
218 |
|
|
219 |
|
// a simple way to handle heatbeats - this WILL change |
220 |
|
if ((packet.getParam("packet.attributes.type")).equals("heartbeat")) { |
223 |
|
_heartbeatTimerThread = new Thread(_heartbeatTimer); |
224 |
|
_heartbeatTimerThread.start(); |
225 |
|
} |
226 |
< |
// iterate over the packets data |
225 |
< |
Set packetSet = packet.getSet(); |
226 |
< |
Iterator i = packetSet.iterator(); |
227 |
< |
while (i.hasNext()) { |
228 |
< |
String dataKey = (String) i.next(); |
229 |
< |
|
230 |
< |
// if there are no components looking after this data |
231 |
< |
// create a new StringDataComponent for it |
232 |
< |
if(!_components.containsKey(dataKey)) { |
233 |
< |
addVisibleDataComponent(_center, new StringDataComponent(dataKey, dataKey)); |
234 |
< |
} |
235 |
< |
|
236 |
< |
// try and update the component, if it doesn't like what it gets |
237 |
< |
// warn the user and set that this was an unsucessful display |
238 |
< |
try { |
239 |
< |
((DataComponent) _components.get(dataKey)).setValue(packet.getParam(dataKey)); |
240 |
< |
} catch (DataFormatException e) { |
241 |
< |
Conient.addMessage("WARNING{host display}: " + e.getMessage()); |
242 |
< |
displaySucessful = false; |
243 |
< |
} |
244 |
< |
} |
226 |
> |
displaySucessful = processPacket(packet, _services, true); |
227 |
|
|
228 |
|
// must be a normal data packet, update the display |
229 |
|
} else if((packet.getParam("packet.attributes.type")).equals("data")) { |
230 |
+ |
displaySucessful = processPacket(packet, _extra, extraData); |
231 |
|
_dataTimer.reset(); |
232 |
|
if(_dataTimerThread == null){ |
233 |
|
_dataTimerThread = new Thread(_dataTimer); |
234 |
|
_dataTimerThread.start(); |
235 |
|
} |
236 |
< |
|
237 |
< |
// iterate over the packets data |
238 |
< |
Set packetSet = packet.getSet(); |
239 |
< |
Iterator i = packetSet.iterator(); |
240 |
< |
while (i.hasNext()) { |
258 |
< |
String dataKey = (String) i.next(); |
236 |
> |
} |
237 |
> |
return displaySucessful; |
238 |
> |
} |
239 |
> |
|
240 |
> |
//---PRIVATE METHODS--- |
241 |
|
|
242 |
< |
// if there are no components looking after this data |
243 |
< |
// create a new StringDataComponent for it |
244 |
< |
if(!_components.containsKey(dataKey)) { |
245 |
< |
// check if its a disk drive, if it is then we need to deal with it |
246 |
< |
if(dataKey.startsWith("packet.disk.p")) { |
247 |
< |
createDiskPanel(dataKey); |
248 |
< |
} else if (extraData) { |
249 |
< |
addVisibleDataComponent(_center, new StringDataComponent(dataKey, dataKey)); |
250 |
< |
} |
251 |
< |
} |
242 |
> |
/** |
243 |
> |
* Process an incoming packet, updates the components. |
244 |
> |
* If extra data is configured to be displayed, it will |
245 |
> |
* create a new StringDataComponent to display the data. |
246 |
> |
* |
247 |
> |
* @param packet the packet to process |
248 |
> |
* @param extraDataJPanel a panel to place any data that is found to be extra |
249 |
> |
* @param processUnknownData whether to process data that is not currently being handled |
250 |
> |
* |
251 |
> |
* @return if the proceesing was successful |
252 |
> |
*/ |
253 |
> |
private boolean processPacket(XMLPacket packet, JPanel extraDataJPanel, boolean processUnknownData) { |
254 |
> |
// iterate over the packets data |
255 |
> |
boolean displaySucessful = true; |
256 |
> |
Set packetSet = packet.getSet(); |
257 |
> |
Iterator i = packetSet.iterator(); |
258 |
> |
while (i.hasNext()) { |
259 |
> |
String dataKey = (String) i.next(); |
260 |
|
|
261 |
< |
// try and update the component, if it doesn't like what it gets |
262 |
< |
// warn the user and set that this was an unsucessful display |
263 |
< |
try { |
264 |
< |
((DataComponent) _components.get(dataKey)).setValue(packet.getParam(dataKey)); |
265 |
< |
} catch (DataFormatException e) { |
266 |
< |
Conient.addMessage("WARNING{host display}: " + e.getMessage()); |
267 |
< |
displaySucessful = false; |
261 |
> |
// if there are no components looking after this data |
262 |
> |
// create a new StringDataComponent for it |
263 |
> |
if(!_components.containsKey(dataKey)) { |
264 |
> |
// check if its a disk drive, if it is then we need to deal with it |
265 |
> |
if(dataKey.startsWith("packet.disk.p")) { |
266 |
> |
createDiskPanel(dataKey); |
267 |
> |
|
268 |
> |
// !check for services here! to display |
269 |
> |
|
270 |
> |
} else if (processUnknownData) { |
271 |
> |
addVisibleDataComponent(extraDataJPanel, new StringDataComponent(dataKey, dataKey)); |
272 |
|
} |
273 |
|
} |
274 |
+ |
|
275 |
+ |
// try and update the component, if it doesn't like what it gets |
276 |
+ |
// warn the user and set that this was an unsucessful display |
277 |
+ |
try { |
278 |
+ |
((DataComponent) _components.get(dataKey)).setValue(packet.getParam(dataKey)); |
279 |
+ |
} catch (DataFormatException e) { |
280 |
+ |
Conient.addMessage("WARNING{host display}: " + e.getMessage()); |
281 |
+ |
displaySucessful = false; |
282 |
+ |
} |
283 |
|
} |
284 |
< |
return displaySucessful; |
284 |
> |
return displaySucessful; |
285 |
|
} |
286 |
|
|
284 |
– |
//---PRIVATE METHODS--- |
285 |
– |
|
287 |
|
/** |
288 |
|
* Adds a DataComponent to the list of already |
289 |
|
* known data components. The list is aware of |
359 |
|
* are stored here. |
360 |
|
*/ |
361 |
|
private HashMap _components = new HashMap(); |
361 |
– |
|
362 |
– |
/** |
363 |
– |
* |
364 |
– |
*/ |
365 |
– |
private boolean displaySucessful = true; |
362 |
|
|
363 |
|
/** |
364 |
|
* The east panel, currently used for the heartbeat timer. |
411 |
|
/** |
412 |
|
* The disks panel |
413 |
|
*/ |
414 |
< |
private final JPanel _disks; |
414 |
> |
private final JPanel _disks = new JPanel(); |
415 |
> |
{ |
416 |
> |
_disks.setLayout(new BoxLayout(_disks, BoxLayout.Y_AXIS)); |
417 |
> |
} |
418 |
> |
|
419 |
> |
/** |
420 |
> |
* The extra panel, used to display unknown data in the packet |
421 |
> |
*/ |
422 |
> |
private final JPanel _extra = new JPanel(); |
423 |
> |
{ |
424 |
> |
_extra.setLayout(new BoxLayout(_extra, BoxLayout.Y_AXIS)); |
425 |
> |
} |
426 |
> |
|
427 |
> |
/** |
428 |
> |
* The services panel, currently used to display host service information |
429 |
> |
* from heartbeat packets. |
430 |
> |
*/ |
431 |
> |
private final JPanel _services = new JPanel(); |
432 |
> |
{ |
433 |
> |
_services.setLayout(new BoxLayout(_services, BoxLayout.Y_AXIS)); |
434 |
> |
} |
435 |
|
|
436 |
|
/** |
437 |
|
* Whether we a worrying about "extra" data |