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.14 by ajm, Sun Feb 4 18:02:46 2001 UTC vs.
Revision 1.15 by ajm, Sun Feb 4 20:34:28 2001 UTC

# Line 18 | Line 18 | import javax.swing.JFrame;
18   import javax.swing.Box;
19   import java.awt.event.*;
20   import java.awt.Container;
21 + import javax.swing.SwingUtilities;
22  
23   /**
24   * A HostDisplayPanel is simply a JPanel containing
# Line 71 | Line 72 | public class HostDisplayPanel extends JPanel {
72          addDataComponent(ip);
73          final StringDataComponent uptime = new StringDataComponent("Uptime", "packet.os.uptime");
74          addDataComponent(uptime);
75 +        final StringDataComponent seq_no = new StringDataComponent("Packets since host started", "packet.attributes.seq_no");
76 +        addDataComponent(seq_no);
77          
78          final StringDataComponent osName = new StringDataComponent("Operating System", "packet.os.name");
79          addDataComponent(osName );
# Line 91 | Line 94 | public class HostDisplayPanel extends JPanel {
94                  content.add(machineName);
95                  content.add(ip);
96                  content.add(uptime);
97 +                content.add(seq_no);
98                  content.add(osName);
99                  content.add(osVer);
100                  content.add(osRelease);
# Line 217 | Line 221 | public class HostDisplayPanel extends JPanel {
221              Iterator i = packetSet.iterator();
222              while (i.hasNext()) {
223                  String dataKey = (String) i.next();
224 <                
224 >
225                  // if there are no components looking after this data
226                  // create a new StringDataComponent for it
227                  if(!_components.containsKey(dataKey)) {
228 <                    
229 <                    
230 <                    addVisibleDataComponent(_center, new StringDataComponent(dataKey, dataKey));
228 >                    // check if its a disk drive, if it is then we need to deal with it
229 >                    if(dataKey.startsWith("packet.disk.p")) {
230 >                        createDiskPanel(dataKey);
231 >                    } else {                    
232 >                        addVisibleDataComponent(_center, new StringDataComponent(dataKey, dataKey));
233 >                    }
234                  }
235 <                
235 >
236                  // try and update the component, if it doesn't like what it gets
237                  // warn the user and set that this was an unsucessful display
238                  try {
# Line 238 | Line 245 | public class HostDisplayPanel extends JPanel {
245          }
246          return displaySucessful;        
247      }
248 +    
249 + //---PRIVATE METHODS---
250  
251      /**
252       * Adds a DataComponent to the list of already
# Line 265 | Line 274 | public class HostDisplayPanel extends JPanel {
274       */
275      public void addVisibleDataComponent(Container holder, VisibleDataComponent dataComponent) {
276          _components.put(((DataComponent) dataComponent).getPacketAttribute(), (DataComponent) dataComponent);
277 <        holder.add(dataComponent);
277 >        SwingSafeAdd task = new SwingSafeAdd(holder, dataComponent);
278 >        SwingUtilities.invokeLater(task);
279      }
280 +
281 +    /**
282 +     * Creates the disk components and adds them
283 +     * do the list of components.  It also displays
284 +     * any relavant component.
285 +     *
286 +     * When a packet attribute is new to the system
287 +     * and when it starts "packet.disk.p" then this
288 +     * method is called.  Thus it then accounts for
289 +     * all attributes relating to that new disk.
290 +     *
291 +     * @param attribute the name of the attrivbute first encountered
292 +     */
293 +    private void createDiskPanel(String attribute) {
294 +        String diskNumber = "";
295 +        
296 +        // pos is after "packet.disk.p"
297 +        int pos = 13;
298 +        while (attribute.charAt(pos) != '.') {
299 +            diskNumber = diskNumber + attribute.charAt(pos);
300 +            pos++;
301 +        }
302 +        DiskInformationDataComponent device = new DiskInformationDataComponent("Disk device", "packet.disk.p" + diskNumber + ".name");
303 +        addDataComponent(device);
304 +        DiskInformationDataComponent mountPoint = new DiskInformationDataComponent("Disk mount point", "packet.disk.p" + diskNumber + ".mount");
305 +        addDataComponent(mountPoint);
306 +        StorageTotalDataComponent total = new StorageTotalDataComponent("Disk total", "packet.disk.p" + diskNumber + ".kbytes");
307 +        addDataComponent(total);
308 +        DiskFreeDataComponent free = new DiskFreeDataComponent("Space in use", "packet.disk.p" + diskNumber + ".avail", "Kb", total, mountPoint, device);
309 +        addVisibleDataComponent(_disks, free);
310 +        
311 +        // need to do something with this
312 +        addVisibleDataComponent(_center, new StringDataComponent("packet.disk.p" + diskNumber + ".used", "packet.disk.p" + diskNumber + ".used"));
313 +    }
314 +
315 + //---ACCESSOR/MUTATOR METHODS---
316  
317   //---ATTRIBUTES---
318          

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines