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.4
Committed: Mon Jan 22 19:35:36 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.3: +5 -1 lines
Log Message:
Mainly bug fixes and small features added.
eg, start data connects control link if not already there
eg, shows messages as new hosts are added
eg, scrolls the main central data panel
eg, cleans up old data panels when data is stopped and restarted

added more javadoc to some items

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 SwingClient.setQueueStatus(_dataQueue.queueSize(_myQueue), _dataQueue.elementCount());
25 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 SwingClient.addMessage("New Host added: " + hostName);
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 public void cleanUpTabs() {
64 _tabbedPane.removeAll();
65 }
66
67 JTabbedPane _tabbedPane = new JTabbedPane();
68 Queue _dataQueue;
69 int _myQueue;
70 ImageIcon _serverIcon = new ImageIcon("server.gif");
71 }