ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/DataPanel.java
Revision: 1.2
Committed: Mon Jan 22 03:03:39 2001 UTC (23 years, 4 months ago) by ajm
Branch: MAIN
Changes since 1.1: +2 -19 lines
Log Message:
re-worked to be better OO... ;-)
added support for V1.0 client protocol
all still very messy....

File Contents

# Content
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
11 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 add(_tabbedPane);
19 HashMap hostList = new HashMap();
20 try {
21 while(true) {
22
23 String xml = (String) _dataQueue.get(_myQueue);
24 if (xml == null) {
25 // shouldn't really happen...but not sure
26 //_status.insert("No XML to update...",0);
27 } else {
28
29 // Get a string without any null characters in it.
30 // -- maybe String.trim() would be better ?
31 if (xml.indexOf(0) != -1) {
32 xml = xml.substring(0, xml.indexOf(0));
33 }
34 else {
35 xml = xml.substring(0, xml.length());
36 }
37
38 // Use XMLPacketMaker to make an XMLPacket object.
39 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
40 XMLPacket packet = xmlPacketMaker.createXMLPacket();
41 String hostName = packet.getParam("packet.attributes.machine_name");
42 if(!hostList.containsKey(hostName)) {
43
44 HostDisplayPanel host = new HostDisplayPanel();
45 _tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName);
46 hostList.put(hostName, host);
47 //_status.insert("New Host added: " + hostName + "\n", 0);
48 }
49 ((HostDisplayPanel) hostList.get(hostName)).updateHost(packet);
50 }
51 }
52 } catch (Exception e) {
53 System.err.println("ERROR RUN: " + e);
54 }
55 }
56
57 public void setQueue(Queue queue) {
58 _dataQueue = queue;
59 _myQueue = _dataQueue.getQueue();
60 }
61
62 JTabbedPane _tabbedPane = new JTabbedPane();
63 Queue _dataQueue;
64 int _myQueue;
65 ImageIcon _serverIcon = new ImageIcon("server.gif");
66 }