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 |
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()); |
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 |
|
|