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

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/CPUDataComponent.java (file contents):
Revision 1.6 by ajm, Mon Jan 29 13:58:45 2001 UTC vs.
Revision 1.10 by ajm, Sun Mar 18 16:28:53 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.conient.datacomponents;
2 > package uk.org.iscream.conient.datacomponents;
3  
4   //---IMPORTS---
5   import javax.swing.JLabel;
6   import java.awt.GridLayout;
7   import javax.swing.JProgressBar;
8   import javax.swing.SwingUtilities;
9 + import uk.org.iscream.util.XMLPacket;
10  
11   /**
12   * This is DataComponent specifically for
# Line 42 | Line 43 | public class CPUDataComponent extends VisibleDataCompo
43          _label = new JLabel(_name + ": ");
44          _label.setHorizontalAlignment(JLabel.RIGHT);
45          setLayout(new GridLayout(1, 2));
46 <        _item.setString("-uninitialised-");
46 >            _item.setString("-uninitialised-");
47          add(_label);
48          add(_item);
49 +        setVisible(false);
50      }
51  
52   //---PUBLIC METHODS---
# Line 56 | Line 58 | public class CPUDataComponent extends VisibleDataCompo
58       * run this method.
59       */
60      public void run() {
61 +        if(!isVisible()) {
62 +            setVisible(true);
63 +        }
64          _item.setString(_cache + "%");
65          _item.setValue(new Double(_cache).intValue());
66      }
# Line 75 | Line 80 | public class CPUDataComponent extends VisibleDataCompo
80   //---ACCESSOR/MUTATOR METHODS---
81  
82      /**
83 <     * This takes the String value of the parameter that this component
79 <     * is monitoring direct from the packet, it then performs all
83 >     * This takes the packet to obtain the value from, it then performs all
84       * approriate conversions and adds this class to the Swing Event
85       * Dispatching queue.
86       *
87 <     * @param value the value for this data component
87 >     * @param packet the XMLPacket to get the data from
88       * @throws DataFormatException if there was a problem converting the data for display
89       */
90 <    public void setValue(String value) throws DataFormatException {
90 >    public void setValue(XMLPacket packet) throws DataFormatException {
91 >        String value = packet.getParam(_attribute);
92          try {
93              if(!_cache.equals(value)) {
94                  _cache = value;
# Line 92 | Line 97 | public class CPUDataComponent extends VisibleDataCompo
97          } catch (Exception e) {
98              throw new DataFormatException(value + " is an invalid data type for " + toString());
99          }
100 <    }        
100 >    }
101 >    
102 >    /**
103 >     * Returns the string showing the packet
104 >     * attribute that the component is looking after
105 >     *
106 >     * @return the packet reference
107 >     */
108 >    public String getPacketAttribute() {
109 >        return _attribute;
110 >    }
111  
112   //---ATTRIBUTES---
113  
# Line 107 | Line 122 | public class CPUDataComponent extends VisibleDataCompo
122      private String _attribute;
123      
124      /**
125 <     * Remebers what the last value was, so we
125 >     * Remembers what the last value was, so we
126       * only update if we have to.
127       */    
128 <    String _cache = "";
128 >    protected String _cache = "";
129      
130      /**
131       * The minimum value for the percentage

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines