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
Revision: 1.5
Committed: Tue May 29 17:41:32 2001 UTC (22 years, 11 months ago) by tdb
Branch: MAIN
Changes since 1.4: +4 -4 lines
Log Message:
The last of the central monitoring system packages to be changed to the newer
structure. It has changed from;

uk.org.iscream.conient.*

to;

uk.org.iscream.cms.conient.*

This is in keeping with the new style of packaging.

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2 tdb 1.5 package uk.org.iscream.cms.conient.datacomponents;
3 ajm 1.1
4     //---IMPORTS---
5     import javax.swing.JLabel;
6     import java.awt.GridLayout;
7     import java.util.Date;
8     import java.text.DateFormat;
9 ajm 1.4 import javax.swing.SwingUtilities;
10 tdb 1.5 import uk.org.iscream.cms.server.util.DateUtils;
11     import uk.org.iscream.cms.server.util.XMLPacket;
12 ajm 1.1
13     /**
14     * This is DataComponent specifically for converting
15     * uptime into a nice format.
16     *
17     * As this is essentially just string data we just
18     * extend StringDataComponent, intercepting the value
19     * to convert it.
20     *
21     * @author $Author: ajm4 $
22 tdb 1.5 * @version $Id: UptimeDataComponent.java,v 1.4 2001/03/18 14:43:39 ajm4 Exp $
23 ajm 1.1 */
24     public class UptimeDataComponent extends StringDataComponent {
25    
26     //---FINAL ATTRIBUTES---
27    
28     //---STATIC METHODS---
29    
30     //---CONSTRUCTORS---
31    
32     /**
33     * Creates the component with a friendly name to be
34     * used as label, but as we're a very basic
35     * extension of StringDataComponent, we just construct
36     * that.
37     *
38     * @param name the friendly name
39     * @param attribute the data attribute we look after
40     */
41     public UptimeDataComponent(String name, String attribute) {
42     super(name, attribute);
43     }
44    
45     //---PUBLIC METHODS---
46    
47     //---PRIVATE METHODS---
48    
49     //---ACCESSOR/MUTATOR METHODS---
50    
51     /**
52 ajm 1.4 * 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 ajm 1.1 *
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 ajm 1.4 * @param packet the XMLPacket to get the data from
62 ajm 1.1 * @throws DataFormatException if there was a problem converting the data for display
63     */
64 ajm 1.4 public void setValue(XMLPacket packet) throws DataFormatException {
65     String value = packet.getParam(_attribute);
66 ajm 1.1 try {
67 ajm 1.4 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 ajm 1.1 }
72     } catch (Exception e) {
73     throw new DataFormatException(value + " is an invalid data type for " + toString());
74     }
75     }
76    
77     //---ATTRIBUTES---
78    
79     /**
80 ajm 1.4 * Remembers what the last value was, so we
81 ajm 1.1 * only update if we have to.
82     */
83 ajm 1.4 String _ourCache = "";
84 ajm 1.1
85     //---STATIC ATTRIBUTES---
86    
87     }