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

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/datacomponents/DateDataComponent.java (file contents):
Revision 1.2 by ajm, Mon Jan 22 12:32:14 2001 UTC vs.
Revision 1.3 by ajm, Wed Jan 24 01:54:43 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + uk.ac.ukc.iscream.conient.datacomponents;
3  
4   //---IMPORTS---
5   import javax.swing.JLabel;
# Line 34 | Line 35 | public class DateDataComponent extends StringDataCompo
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---
# Line 58 | Line 60 | public class DateDataComponent extends StringDataCompo
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines