1 |
|
//---PACKAGE DECLARATION--- |
2 |
+ |
uk.ac.ukc.iscream.conient.datacomponents; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import javax.swing.JLabel; |
35 |
|
* that. |
36 |
|
* |
37 |
|
* @param name the friendly name |
38 |
+ |
* @param attribute the data attribute we look after |
39 |
|
*/ |
40 |
< |
public DateDataComponent(String name) { |
41 |
< |
super(name); |
40 |
> |
public DateDataComponent(String name, String attribute) { |
41 |
> |
super(name, attribute); |
42 |
|
} |
43 |
|
|
44 |
|
//---PUBLIC METHODS--- |
60 |
|
*/ |
61 |
|
public void setValue(String value) throws DataFormatException { |
62 |
|
try { |
63 |
< |
value = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(value))); |
64 |
< |
super.setValue(value); |
63 |
> |
if(!_cache.equals(value)) { |
64 |
> |
_cache = value; |
65 |
> |
value = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(value))); |
66 |
> |
super.setValue(value); |
67 |
> |
} |
68 |
|
} catch (Exception e) { |
69 |
< |
throw new DataFormatException("invalid data type for component"); |
69 |
> |
throw new DataFormatException(value + " is an invalid data type for " + toString()); |
70 |
|
} |
71 |
|
} |
72 |
|
|
73 |
|
//---ATTRIBUTES--- |
74 |
+ |
|
75 |
+ |
/** |
76 |
+ |
* Remebers what the last value was, so we |
77 |
+ |
* only update if we have to. |
78 |
+ |
*/ |
79 |
+ |
String _cache = ""; |
80 |
|
|
81 |
|
//---STATIC ATTRIBUTES--- |
82 |
|
|