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.7 by ajm, Tue Feb 6 00:09:36 2001 UTC vs.
Revision 1.13 by tdb, Wed Feb 5 19:35:04 2003 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.ac.ukc.iscream.conient.datacomponents;
22 > package uk.org.iscream.cms.conient.datacomponents;
23  
24   //---IMPORTS---
25   import javax.swing.JLabel;
26   import java.awt.GridLayout;
27   import java.util.Date;
28   import java.text.DateFormat;
29 + import javax.swing.SwingUtilities;
30 + import uk.org.iscream.cms.util.XMLPacket;
31  
32   /**
33   * This is DataComponent specifically for converting
# Line 46 | Line 68 | public class DateDataComponent extends StringDataCompo
68   //---ACCESSOR/MUTATOR METHODS---
69      
70      /**
71 <     * This takes the String value of the parameter that this component
72 <     * is monitoring direct from the packet, it then performs all
73 <     * approriate conversions and displays the data.
71 >     * This takes the packet to obtain the value from, it then performs all
72 >     * approriate conversions and adds this class to the Swing Event
73 >     * Dispatching queue.
74       *
75       * In this case all we do is change string and pass it to our
76       * super class for displaying.  Note that we need to *1000
77       * as the data standard is for time in seconds, but java likes
78       * milliseconds.
79       *
80 <     * @param value the value for this data component
80 >     * @param packet the XMLPacket to get the data from
81       * @throws DataFormatException if there was a problem converting the data for display
82       */
83 <    public void setValue(String value) throws DataFormatException {
83 >    public void setValue(XMLPacket packet) throws DataFormatException {
84 >        String value = packet.getParam(_attribute);
85          try {
86 <            if(!_cache.equals(value)) {
87 <                _cache = value;
88 <                value = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(value) * 1000));
89 <                super.setValue(value);
86 >            if(!_ourCache.equals(value)) {
87 >                _ourCache = value;
88 >                _cache = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(Long.parseLong(value) * 1000));
89 >                SwingUtilities.invokeLater(this);
90              }
91          } catch (Exception e) {
92              throw new DataFormatException(value + " is an invalid data type for " + toString());
# Line 73 | Line 96 | public class DateDataComponent extends StringDataCompo
96   //---ATTRIBUTES---
97  
98      /**
99 <     * Remebers what the last value was, so we
99 >     * Remembers what the last value was, so we
100       * only update if we have to.
101       */    
102 <    String _cache = "";
102 >    String _ourCache = "";
103  
104   //---STATIC ATTRIBUTES---
105  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines