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
Revision: 1.3
Committed: Wed Jan 24 01:54:43 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.2: +17 -6 lines
Log Message:
moved into the package
and restructed to allow non-visible components

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 uk.ac.ukc.iscream.conient.datacomponents;
3
4 //---IMPORTS---
5 import javax.swing.JLabel;
6 import java.awt.GridLayout;
7 import java.util.Date;
8 import java.text.DateFormat;
9
10 /**
11 * This is DataComponent specifically for converting
12 * time since epoc dates into a nice format.
13 *
14 * As this is essentially just string data we just
15 * extend StringDataComponent, intercepting the value
16 * to convert it.
17 *
18 * It uses the JProgressBar to display the value.
19 *
20 * @author $Author: ajm4 $
21 * @version $Id: DateDataComponent.java,v 1.2 2001/01/22 12:32:14 ajm4 Exp $
22 */
23 public class DateDataComponent extends StringDataComponent {
24
25 //---FINAL ATTRIBUTES---
26
27 //---STATIC METHODS---
28
29 //---CONSTRUCTORS---
30
31 /**
32 * Creates the component with a friendly name to be
33 * used as label, but as we're a very basic
34 * extension of StringDataComponent, we just construct
35 * that.
36 *
37 * @param name the friendly name
38 * @param attribute the data attribute we look after
39 */
40 public DateDataComponent(String name, String attribute) {
41 super(name, attribute);
42 }
43
44 //---PUBLIC METHODS---
45
46 //---PRIVATE METHODS---
47
48 //---ACCESSOR/MUTATOR METHODS---
49
50 /**
51 * This takes the String value of the parameter that this component
52 * is monitoring direct from the packet, it then performs all
53 * approriate conversions and displays the data.
54 *
55 * In this case all we do is change string and pass it to our
56 * super class for displaying.
57 *
58 * @param value the value for this data component
59 * @throws DataFormatException if there was a problem converting the data for display
60 */
61 public void setValue(String value) throws DataFormatException {
62 try {
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(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
83 }