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

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

# Line 6 | Line 6 | import javax.swing.JLabel;
6   import java.awt.GridLayout;
7   import java.util.Date;
8   import java.text.DateFormat;
9 + import javax.swing.SwingUtilities;
10   import uk.org.iscream.util.DateUtils;
11 + import uk.org.iscream.util.XMLPacket;
12  
13   /**
14   * This is DataComponent specifically for converting
# Line 47 | Line 49 | public class UptimeDataComponent extends StringDataCom
49   //---ACCESSOR/MUTATOR METHODS---
50      
51      /**
52 <     * This takes the String value of the parameter that this component
53 <     * is monitoring direct from the packet, it then performs all
54 <     * approriate conversions and displays the data.
52 >     * This takes the packet to obtain the value from, it then performs all
53 >     * approriate conversions and adds this class to the Swing Event
54 >     * Dispatching queue.
55       *
56       * In this case all we do is change string and pass it to our
57       * super class for displaying.  Note that we need to *1000
58       * as the data standard is for time in seconds, but java likes
59       * milliseconds.
60       *
61 <     * @param value the value for this data component
61 >     * @param packet the XMLPacket to get the data from
62       * @throws DataFormatException if there was a problem converting the data for display
63       */
64 <    public void setValue(String value) throws DataFormatException {
64 >    public void setValue(XMLPacket packet) throws DataFormatException {
65 >        String value = packet.getParam(_attribute);
66          try {
67 <            if(!_cache.equals(value)) {
68 <                _cache = value;
69 <                value = DateUtils.formatTime(Long.parseLong(value), "%DAYS% days %HOURS% hours %MINS% mins");
70 <                super.setValue(value);
67 >            if(!_ourCache.equals(value)) {
68 >                _ourCache = value;
69 >                _cache = DateUtils.formatTime(Long.parseLong(value), "%DAYS% days %HOURS% hours %MINS% mins");
70 >                SwingUtilities.invokeLater(this);
71              }
72          } catch (Exception e) {
73              throw new DataFormatException(value + " is an invalid data type for " + toString());
# Line 74 | Line 77 | public class UptimeDataComponent extends StringDataCom
77   //---ATTRIBUTES---
78  
79      /**
80 <     * Remebers what the last value was, so we
80 >     * Remembers what the last value was, so we
81       * only update if we have to.
82       */    
83 <    String _cache = "";
83 >    String _ourCache = "";
84  
85   //---STATIC ATTRIBUTES---
86  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines