1 |
ajm |
1.1 |
import javax.swing.*; |
2 |
|
|
import javax.swing.border.*; |
3 |
|
|
import java.awt.Color; |
4 |
|
|
import uk.ac.ukc.iscream.util.*; |
5 |
|
|
|
6 |
|
|
import java.awt.*; |
7 |
|
|
import java.awt.event.*; |
8 |
|
|
import java.net.*; |
9 |
|
|
import java.io.*; |
10 |
ajm |
1.2 |
|
11 |
ajm |
1.1 |
import java.util.Locale; |
12 |
|
|
import java.util.HashMap; |
13 |
|
|
import javax.swing.border.*; |
14 |
|
|
|
15 |
|
|
public class DataPanel extends JPanel implements Runnable { |
16 |
|
|
|
17 |
|
|
public void run() { |
18 |
ajm |
1.2 |
add(_tabbedPane); |
19 |
ajm |
1.1 |
HashMap hostList = new HashMap(); |
20 |
|
|
try { |
21 |
|
|
while(true) { |
22 |
|
|
|
23 |
|
|
String xml = (String) _dataQueue.get(_myQueue); |
24 |
ajm |
1.3 |
SwingClient.setQueueStatus(_dataQueue.queueSize(_myQueue), _dataQueue.elementCount()); |
25 |
ajm |
1.1 |
if (xml == null) { |
26 |
|
|
// shouldn't really happen...but not sure |
27 |
|
|
//_status.insert("No XML to update...",0); |
28 |
|
|
} else { |
29 |
|
|
|
30 |
|
|
// Get a string without any null characters in it. |
31 |
|
|
// -- maybe String.trim() would be better ? |
32 |
|
|
if (xml.indexOf(0) != -1) { |
33 |
|
|
xml = xml.substring(0, xml.indexOf(0)); |
34 |
|
|
} |
35 |
|
|
else { |
36 |
|
|
xml = xml.substring(0, xml.length()); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
// Use XMLPacketMaker to make an XMLPacket object. |
40 |
|
|
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
41 |
|
|
XMLPacket packet = xmlPacketMaker.createXMLPacket(); |
42 |
|
|
String hostName = packet.getParam("packet.attributes.machine_name"); |
43 |
|
|
if(!hostList.containsKey(hostName)) { |
44 |
|
|
|
45 |
|
|
HostDisplayPanel host = new HostDisplayPanel(); |
46 |
|
|
_tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName); |
47 |
|
|
hostList.put(hostName, host); |
48 |
|
|
//_status.insert("New Host added: " + hostName + "\n", 0); |
49 |
|
|
} |
50 |
|
|
((HostDisplayPanel) hostList.get(hostName)).updateHost(packet); |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
} catch (Exception e) { |
54 |
|
|
System.err.println("ERROR RUN: " + e); |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
public void setQueue(Queue queue) { |
59 |
|
|
_dataQueue = queue; |
60 |
|
|
_myQueue = _dataQueue.getQueue(); |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
JTabbedPane _tabbedPane = new JTabbedPane(); |
64 |
|
|
Queue _dataQueue; |
65 |
|
|
int _myQueue; |
66 |
|
|
ImageIcon _serverIcon = new ImageIcon("server.gif"); |
67 |
|
|
} |