KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > elements > DateDE


1 /*
2  * (c) Rob Gordon 2005.
3  */

4 package org.oddjob.designer.elements;
5
6 import org.oddjob.arooa.ArooaRuntime;
7 import org.oddjob.arooa.ArooaContext;
8 import org.oddjob.arooa.ArooaConstants;
9 import org.oddjob.arooa.RuntimeConfiguration;
10 import org.oddjob.arooa.handlers.DocumentStartHandler;
11 import org.oddjob.arooa.handlers.MainHandler;
12 import org.oddjob.designer.arooa.DesignParser;
13 import org.oddjob.designer.elements.date.DateTimeAttribute;
14 import org.oddjob.designer.elements.date.TimeZoneAttribute;
15 import org.oddjob.designer.model.DesignDefinition;
16 import org.oddjob.designer.model.DesignElementAttribute;
17 import org.oddjob.designer.model.ElementField;
18 import org.oddjob.designer.model.FieldGroup;
19 import org.oddjob.values.types.DateType;
20 import org.xml.sax.SAXParseException JavaDoc;
21
22 /**
23  *
24  */

25 public class DateDE extends DesignElementAttribute {
26
27     private DateTimeAttribute dateTime;
28     private TimeZoneAttribute timeZone;
29     
30     public DateDE() {
31         setDate(new DateTimeAttribute());
32         setTimeZone(new TimeZoneAttribute());
33     }
34     
35     public DesignDefinition detail() {
36         return new FieldGroup("Date")
37             .add(new ElementField("Date ", dateTime))
38             .add(new ElementField("Time Zone", timeZone));
39     }
40
41     public void clear() {
42         dateTime.clear();
43         timeZone.clear();
44         super.clear();
45     }
46     
47     /**
48      * @return Returns the date.
49      */

50     public DateTimeAttribute getDate() {
51         return dateTime;
52     }
53     /**
54      * @param date The date to set.
55      */

56     public void setDate(DateTimeAttribute dateTime) {
57         dateTime.addObserver(detailObserver);
58         this.dateTime = dateTime;
59     }
60     
61     public TimeZoneAttribute getTimeZone() {
62         return timeZone;
63     }
64     
65     public void setTimeZone(TimeZoneAttribute timeZone) {
66         timeZone.addObserver(detailObserver);
67         this.timeZone = timeZone;
68     }
69     
70     public DateType toType()
71     throws SAXParseException JavaDoc {
72         DateType dateType = new DateType();
73
74         ArooaContext context = new ArooaContext();
75         RuntimeConfiguration rtc = new ArooaRuntime(
76                         dateType, "date", context);
77
78         context.set(ArooaConstants.CURRENTLY_CONFIGURING, rtc);
79
80         DesignParser dp = new DesignParser(context);
81         dp.parse("date", this, new MainHandler(
82                     new DocumentStartHandler(dateType)));
83             
84         rtc.configure();
85
86         return dateType;
87     }
88     
89 }
90
Popular Tags