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.12 by tdb, Sat May 18 18:15:56 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   //---PACKAGE DECLARATION---
21 < package uk.ac.ukc.iscream.conient.datacomponents;
21 > package uk.org.iscream.cms.conient.datacomponents;
22  
23   //---IMPORTS---
24   import javax.swing.JLabel;
25   import java.awt.GridLayout;
26   import javax.swing.JProgressBar;
27   import javax.swing.SwingUtilities;
28 + import uk.org.iscream.cms.server.util.XMLPacket;
29  
30   /**
31   * This is DataComponent specifically for
# Line 42 | Line 62 | public class CPUDataComponent extends VisibleDataCompo
62          _label = new JLabel(_name + ": ");
63          _label.setHorizontalAlignment(JLabel.RIGHT);
64          setLayout(new GridLayout(1, 2));
65 <        _item.setString("-uninitialised-");
65 >            _item.setString("-uninitialised-");
66          add(_label);
67          add(_item);
68 +        setVisible(false);
69      }
70  
71   //---PUBLIC METHODS---
# Line 56 | Line 77 | public class CPUDataComponent extends VisibleDataCompo
77       * run this method.
78       */
79      public void run() {
80 +        if(!isVisible()) {
81 +            setVisible(true);
82 +        }
83          _item.setString(_cache + "%");
84          _item.setValue(new Double(_cache).intValue());
85      }
# Line 75 | Line 99 | public class CPUDataComponent extends VisibleDataCompo
99   //---ACCESSOR/MUTATOR METHODS---
100  
101      /**
102 <     * This takes the String value of the parameter that this component
79 <     * is monitoring direct from the packet, it then performs all
102 >     * This takes the packet to obtain the value from, it then performs all
103       * approriate conversions and adds this class to the Swing Event
104       * Dispatching queue.
105       *
106 <     * @param value the value for this data component
106 >     * @param packet the XMLPacket to get the data from
107       * @throws DataFormatException if there was a problem converting the data for display
108       */
109 <    public void setValue(String value) throws DataFormatException {
109 >    public void setValue(XMLPacket packet) throws DataFormatException {
110 >        String value = packet.getParam(_attribute);
111          try {
112              if(!_cache.equals(value)) {
113                  _cache = value;
# Line 92 | Line 116 | public class CPUDataComponent extends VisibleDataCompo
116          } catch (Exception e) {
117              throw new DataFormatException(value + " is an invalid data type for " + toString());
118          }
119 <    }        
119 >    }
120 >    
121 >    /**
122 >     * Returns the string showing the packet
123 >     * attribute that the component is looking after
124 >     *
125 >     * @return the packet reference
126 >     */
127 >    public String getPacketAttribute() {
128 >        return _attribute;
129 >    }
130  
131   //---ATTRIBUTES---
132  
# Line 107 | Line 141 | public class CPUDataComponent extends VisibleDataCompo
141      private String _attribute;
142      
143      /**
144 <     * Remebers what the last value was, so we
144 >     * Remembers what the last value was, so we
145       * only update if we have to.
146       */    
147 <    String _cache = "";
147 >    protected String _cache = "";
148      
149      /**
150       * The minimum value for the percentage

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines