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/ServiceDataComponent.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/ServiceDataComponent.java (file contents):
Revision 1.2 by ajm, Thu Mar 15 01:05:46 2001 UTC vs.
Revision 1.3 by ajm, Sun Mar 18 14:43:39 2001 UTC

# Line 7 | Line 7 | import javax.swing.JTextField;
7   import java.awt.Color;
8   import java.awt.GridLayout;
9   import javax.swing.SwingUtilities;
10 + import uk.org.iscream.util.XMLPacket;
11  
12   /**
13   * This is the most basic of DataComponents.
# Line 42 | Line 43 | public class ServiceDataComponent extends VisibleDataC
43       * @param name the friendly name
44       * @param attribute the data attribute we look after
45       */
46 <    public ServiceDataComponent(String name, String attribute, StringDataComponent serviceStatus) {
46 >    public ServiceDataComponent(String name, String attribute, String statusAttribute) {
47          _name = name;
48 <        _serviceStatus = serviceStatus;
48 >        _statusAttribute = statusAttribute;
49          _attribute = attribute;
50          setLayout(new GridLayout(1,1));
51          _item = new JTextField("", DEFAULT_TEXT_LENGTH);
# Line 63 | Line 64 | public class ServiceDataComponent extends VisibleDataC
64       * run this method.
65       */
66      public void run() {
67 <        if (_serviceStatusValue.equals("0")) {
67 >        if (_statusCache.equals("0")) {
68              _item.setBackground(Color.green);
69              _item.setText(_name + "[OK] : " + _cache);
70          } else {
# Line 87 | Line 88 | public class ServiceDataComponent extends VisibleDataC
88   //---ACCESSOR/MUTATOR METHODS---
89  
90      /**
91 <     * This takes the String value of the parameter that this component
91 <     * is monitoring direct from the packet, it then performs all
91 >     * This takes the packet to obtain the value from, it then performs all
92       * approriate conversions and adds this class to the Swing Event
93       * Dispatching queue.
94       *
95 <     * @param value the value for this data component
95 >     * @param packet the XMLPacket to get the data from
96       * @throws DataFormatException if there was a problem converting the data for display
97       */
98 <    public void setValue(String value) throws DataFormatException {
98 >    public void setValue(XMLPacket packet) throws DataFormatException {
99 >        String value = packet.getParam(_attribute);
100 >        String statusvalue = packet.getParam(_statusAttribute);
101          try {
102 <            if((!_cache.equals(value) || !_serviceStatusValue.equals(_serviceStatus.getValue())) && !_serviceStatus.getValue().equals("")) {
102 >            if(!_cache.equals(value) || !_statusCache.equals(statusvalue)) {
103                  _cache = value;
104 <                _serviceStatusValue = _serviceStatus.getValue();
104 >                _statusCache = statusvalue;
105                  SwingUtilities.invokeLater(this);
106              }
107          } catch (Exception e) {
# Line 130 | Line 132 | public class ServiceDataComponent extends VisibleDataC
132      protected String _attribute;
133  
134      /**
135 +     * The service status attribute that this component is concerned with
136 +     */
137 +    protected String _statusAttribute;
138 +
139 +    /**
140       * The friendly label for this component
141       */
142      protected JLabel _label;
143      
144      /**
145 <     * Remebers what the last value was, so we
145 >     * Remembers what the last value was, so we
146       * only update if we have to.
147       */    
148 <    String _cache = "";
148 >    protected String _cache = "";
149      
150 +        /**
151 +     * Remembers what the last value was, so we
152 +     * only update if we have to.
153 +     */    
154 +    protected String _statusCache = "";
155 +    
156      /**
157       * The length of the JTextField
158       */
# Line 149 | Line 162 | public class ServiceDataComponent extends VisibleDataC
162       * Just a normal label to display our value as a String
163       */
164      protected JTextField _item;
152
153    private StringDataComponent _serviceStatus;
154    private String _serviceStatusValue = "";
155
156    
165  
166   //---STATIC ATTRIBUTES---
167  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines