ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/HostDisplayPanel.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/HostDisplayPanel.java (file contents):
Revision 1.12 by ajm, Sat Feb 3 19:19:27 2001 UTC vs.
Revision 1.13 by ajm, Sun Feb 4 00:01:49 2001 UTC

# Line 12 | Line 12 | import java.awt.BorderLayout;
12   import javax.swing.BoxLayout;
13   import javax.swing.JPanel;
14   import javax.swing.JProgressBar;
15 + import javax.swing.JButton;
16 + import javax.swing.JLabel;
17 + import javax.swing.JFrame;
18 + import javax.swing.Box;
19 + import java.awt.event.*;
20 + import java.awt.Container;
21  
22   /**
23   * A HostDisplayPanel is simply a JPanel containing
# Line 42 | Line 48 | public class HostDisplayPanel extends JPanel {
48       * Creates a new Host Display Panel and adds
49       * all the appropriate DataComponents
50       */
51 <    public HostDisplayPanel() {
51 >    public HostDisplayPanel(String hostName) {
52          // set up the Panel
53          setLayout(new BorderLayout());
54 <
54 >        _hostName = hostName;
55 >        
56          _heartbeatTimer = new PacketTimer(Integer.parseInt(Configuration.getInstance().getProperty("Host.TCPUpdateTime")));
57          _dataTimer = new PacketTimer(Integer.parseInt(Configuration.getInstance().getProperty("Host.UDPUpdateTime")));
58          _east.add(_heartbeatTimer);
59          _west.add(_dataTimer);
60 <
60 >        
61          add(_east, "East");
62          add(_west, "West");
63          add(_center, "Center");
64 +        add(_north, "North");
65          
66 +        addDataComponent(new StringDataComponent("Packet Type", "packet.attributes.type"));
67 +        
68 +        final StringDataComponent machineName = new StringDataComponent("Host Name", "packet.attributes.machine_name");
69 +        addDataComponent(machineName );
70 +        final StringDataComponent ip = new StringDataComponent("IP Address", "packet.attributes.ip");
71 +        addDataComponent(ip);
72 +        final StringDataComponent uptime = new StringDataComponent("Uptime", "packet.os.uptime");
73 +        addDataComponent(uptime);
74 +        
75 +        final StringDataComponent osName = new StringDataComponent("Operating System", "packet.os.name");
76 +        addDataComponent(osName );
77 +        final StringDataComponent osVer = new StringDataComponent("Operating System Version", "packet.os.version");
78 +        addDataComponent(osVer);
79 +        final StringDataComponent osRelease = new StringDataComponent("Operating System Release", "packet.os.release");
80 +        addDataComponent(osRelease);
81 +        final StringDataComponent osSysName = new StringDataComponent("System Name", "packet.os.sysname");
82 +        addDataComponent(osSysName );
83 +        final StringDataComponent osPlatform = new StringDataComponent("System Architecture", "packet.os.platform");
84 +        addDataComponent(osPlatform );
85 +                
86 +        JButton info = new JButton("Platform Information");
87 +        info.addActionListener(new ActionListener() {
88 +            public void actionPerformed(ActionEvent e) {
89 +                final JFrame infoFrame = new JFrame("Host platform information for - " + _hostName);
90 +                Box content = Box.createVerticalBox();
91 +                content.add(machineName);
92 +                content.add(ip);
93 +                content.add(uptime);
94 +                content.add(osName);
95 +                content.add(osVer);
96 +                content.add(osRelease);
97 +                content.add(osSysName);
98 +                content.add(osPlatform);
99 +                infoFrame.getContentPane().add(content, "Center");
100 +                JButton close = new JButton("Close Window");
101 +                close.addActionListener(new ActionListener() {
102 +                    public void actionPerformed(ActionEvent e) {
103 +                        infoFrame.dispose();
104 +                    }
105 +                });
106 +                infoFrame.getContentPane().add(close, "South");
107 +                infoFrame.pack();
108 +                infoFrame.setVisible(true);
109 +            }
110 +        });
111 +        _north.add(info);
112 +
113 +        addVisibleDataComponent(_center, new DateDataComponent("Host Time", "packet.attributes.date"));
114 +        
115 +        _center.add(new javax.swing.JLabel("--- CPU ---"));
116 +        
117          // add all the DataComponents that we know about
118 <        addVisibleDataComponent("packet.attributes.date", new DateDataComponent("Host Time", "packet.attributes.date"));
119 <        addVisibleDataComponent("packet.cpu.idle", new CPUDataComponent("CPU Idle", "packet.cpu.idle"));
120 <        addVisibleDataComponent("packet.cpu.user", new CPUDataComponent("CPU User", "packet.cpu.user"));
121 <        addVisibleDataComponent("packet.cpu.kernel", new CPUDataComponent("CPU Kernel", "packet.cpu.kernel"));
122 <        addVisibleDataComponent("packet.cpu.iowait", new CPUDataComponent("CPU i/o wait", "packet.cpu.iowait"));
123 <        addVisibleDataComponent("packet.cpu.swap", new CPUDataComponent("CPU swapping", "packet.cpu.swap"));
118 >        JPanel cpu = new JPanel();
119 >        cpu.setLayout(new BoxLayout(cpu, BoxLayout.Y_AXIS));
120 >        addVisibleDataComponent(cpu, new CPUDataComponent("CPU Idle", "packet.cpu.idle"));
121 >        addVisibleDataComponent(cpu, new CPUDataComponent("CPU User", "packet.cpu.user"));
122 >        addVisibleDataComponent(cpu, new CPUDataComponent("CPU Kernel", "packet.cpu.kernel"));
123 >        addVisibleDataComponent(cpu, new CPUDataComponent("CPU i/o wait", "packet.cpu.iowait"));
124 >        addVisibleDataComponent(cpu, new CPUDataComponent("CPU swapping", "packet.cpu.swap"));
125 >        _center.add(cpu);
126          
127 +        _center.add(new javax.swing.JLabel("--- Load ---"));
128 +        
129 +        Box loadData = Box.createHorizontalBox();
130 +        loadData.add(Box.createGlue());
131 +        addVisibleDataComponent(loadData, new ProcessesDataComponent("1 minute", "packet.load.load1"));
132 +        addVisibleDataComponent(loadData, new ProcessesDataComponent("5 minutes", "packet.load.load5"));
133 +        addVisibleDataComponent(loadData, new ProcessesDataComponent("15 minutes", "packet.load.load15"));
134 +        loadData.add(Box.createGlue());
135 +        _center.add(loadData);
136 +        
137 +        _center.add(new javax.swing.JLabel("--- Processes ---"));
138 +        
139 +        Box processesData = Box.createHorizontalBox();
140 +        processesData.add(Box.createGlue());
141 +        addVisibleDataComponent(processesData, new ProcessesDataComponent("Total", "packet.processes.total"));
142 +        addVisibleDataComponent(processesData, new ProcessesDataComponent("Running", "packet.processes.cpu"));
143 +        addVisibleDataComponent(processesData, new ProcessesDataComponent("Sleeping", "packet.processes.sleeping"));
144 +        addVisibleDataComponent(processesData, new ProcessesDataComponent("Stopped", "packet.processes.stopped"));
145 +        addVisibleDataComponent(processesData, new ProcessesDataComponent("Zombie", "packet.processes.zombie"));
146 +        processesData.add(Box.createGlue());
147 +        _center.add(processesData);
148 +        
149 +        
150 +        
151          // theses next two are DataComponents, but not VisibleDataComponents
152          // this is because they hold the value but do NOT display it
153          MemoryTotalDataComponent totalMem = new MemoryTotalDataComponent("Total Memory", "packet.memory.total");
154 <        addDataComponent("packet.memory.total", totalMem);
154 >        addDataComponent(totalMem);
155          MemoryTotalDataComponent totalSwap = new MemoryTotalDataComponent("Total Swap", "packet.swap.total");
156 <        addDataComponent("packet.swap.total", totalSwap);
156 >        addDataComponent(totalSwap);
157          
158 +        _center.add(new javax.swing.JLabel("--- Memory ---"));
159 +        
160          // these next two are passed the non-visible datacomponents
161 <        addVisibleDataComponent("packet.memory.free", new MemoryFreeDataComponent("Memory in use", "packet.memory.free", totalMem));
162 <        addVisibleDataComponent("packet.swap.free", new MemoryFreeDataComponent("Swap in use", "packet.swap.free", totalSwap));
161 >        JPanel memory = new JPanel();
162 >        memory.setLayout(new BoxLayout(memory, BoxLayout.Y_AXIS));        
163 >        addVisibleDataComponent(memory, new MemoryFreeDataComponent("Memory in use", "packet.memory.free", totalMem));
164 >        addVisibleDataComponent(memory, new MemoryFreeDataComponent("Swap in use", "packet.swap.free", totalSwap));
165 >        _center.add(memory);
166 >        _center.add(new javax.swing.JLabel("--- Users ---"));
167 >        addVisibleDataComponent(_center, new StringDataComponent("Number of users", "packet.users.count"));
168 >        UsersDataComponent users = new UsersDataComponent("User List", "packet.users.list");
169 >        addVisibleDataComponent(_center, users);
170  
77        addVisibleDataComponent("packet.users.list", new UsersDataComponent("User List", "packet.users.list"));
78
171          // everything else we get is "extra", but we still want to display it        
172          _center.add(new javax.swing.JLabel("--- Extra Data ---"));
173      }
# Line 124 | Line 216 | public class HostDisplayPanel extends JPanel {
216                  // if there are no components looking after this data
217                  // create a new StringDataComponent for it
218                  if(!_components.containsKey(dataKey)) {
219 <                    addVisibleDataComponent(dataKey, new StringDataComponent(dataKey, dataKey));
219 >                    addVisibleDataComponent(_center, new StringDataComponent(dataKey, dataKey));
220                  }
221                  
222                  // try and update the component, if it doesn't like what it gets
# Line 149 | Line 241 | public class HostDisplayPanel extends JPanel {
241       * @param ref the packet attribute that this Component looks after
242       * @param dataComponent the actual DataComponent
243       */
244 <    private void addDataComponent(String ref, DataComponent dataComponent) {
245 <        _components.put(ref, dataComponent);
244 >    private void addDataComponent(DataComponent dataComponent) {
245 >        _components.put(dataComponent.getPacketAttribute(), dataComponent);
246      }
247  
248      /**
# Line 164 | Line 256 | public class HostDisplayPanel extends JPanel {
256       * @param ref the packet attribute that this Component looks after
257       * @param dataComponent the actual DataComponent
258       */
259 <    public void addVisibleDataComponent(String ref, VisibleDataComponent dataComponent) {
260 <        _components.put(ref, (DataComponent) dataComponent);
261 <        _center.add(dataComponent);
259 >    public void addVisibleDataComponent(Container holder, VisibleDataComponent dataComponent) {
260 >        _components.put(((DataComponent) dataComponent).getPacketAttribute(), (DataComponent) dataComponent);
261 >        holder.add(dataComponent);
262      }
263  
264   //---ATTRIBUTES---
# Line 189 | Line 281 | public class HostDisplayPanel extends JPanel {
281      private final JPanel _east = new JPanel();
282  
283      /**
284 +     * The north panel, currently used for the platform info button.
285 +     */
286 +    private final JPanel _north = new JPanel();
287 +
288 +    /**
289       * The west panel, currently used for the data timer.
290       */
291      private final JPanel _west = new JPanel();
# Line 205 | Line 302 | public class HostDisplayPanel extends JPanel {
302      private final PacketTimer _dataTimer;
303      private Thread _heartbeatTimerThread = null;
304      private Thread _dataTimerThread = null;
305 <    
305 >    private final String _hostName;
306   //---STATIC ATTRIBUTES---
307      
308   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines