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.1
Committed: Sun Jan 21 03:30:00 2001 UTC (23 years, 4 months ago) by ajm
Branch: MAIN
Log Message:
modified to have better support for threads and application layout.
all ready to start implementing a protocol too ;)

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 import java.util.Date;
11 import java.text.DateFormat;
12 import java.util.Locale;
13 import java.util.HashMap;
14 import javax.swing.border.*;
15
16 public class DataPanel extends JPanel implements Runnable {
17 public DataPanel() {
18 super();
19 add(_tabbedPane);
20 }
21
22 public void run() {
23 HashMap hostList = new HashMap();
24 try {
25 while(true) {
26
27 String xml = (String) _dataQueue.get(_myQueue);
28 if (xml == null) {
29 // shouldn't really happen...but not sure
30 //_status.insert("No XML to update...",0);
31 } else {
32
33 // Get a string without any null characters in it.
34 // -- maybe String.trim() would be better ?
35 if (xml.indexOf(0) != -1) {
36 xml = xml.substring(0, xml.indexOf(0));
37 }
38 else {
39 xml = xml.substring(0, xml.length());
40 }
41
42 // Use XMLPacketMaker to make an XMLPacket object.
43 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
44 XMLPacket packet = xmlPacketMaker.createXMLPacket();
45 String hostName = packet.getParam("packet.attributes.machine_name");
46 if(!hostList.containsKey(hostName)) {
47
48 HostDisplayPanel host = new HostDisplayPanel();
49 _tabbedPane.addTab(hostName, _serverIcon, host, "Monitor " + hostName);
50 hostList.put(hostName, host);
51 //_status.insert("New Host added: " + hostName + "\n", 0);
52 }
53 ((HostDisplayPanel) hostList.get(hostName)).updateHost(packet);
54 }
55 }
56 } catch (Exception e) {
57 System.err.println("ERROR RUN: " + e);
58 }
59 }
60
61
62 protected JPanel makeTextPanel(String text, java.awt.Component item) {
63 JPanel panel = new JPanel(false);
64 JLabel label = new JLabel(text);
65 label.setHorizontalAlignment(JLabel.RIGHT);
66 //item.setHorizontalAlignment(JLabel.LEFT);
67 panel.setLayout(new GridLayout(1, 2));
68 panel.add(label);
69 panel.add(item);
70 return panel;
71 }
72
73 public void setQueue(Queue queue) {
74 _dataQueue = queue;
75 _myQueue = _dataQueue.getQueue();
76 }
77
78 JTabbedPane _tabbedPane = new JTabbedPane();
79 Queue _dataQueue;
80 int _myQueue;
81 ImageIcon _serverIcon = new ImageIcon("server.gif");
82
83 }