KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > elements > date > DayAttribute


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

4 package org.oddjob.designer.elements.date;
5
6 import java.text.SimpleDateFormat JavaDoc;
7 import java.util.Calendar JavaDoc;
8
9 import org.oddjob.designer.model.DesignDefinition;
10 import org.oddjob.designer.model.SelectionList;
11 import org.oddjob.designer.model.SimpleAttribute;
12
13 /**
14  *
15  */

16 public class DayAttribute extends SimpleAttribute {
17
18     class DaySL extends SelectionList {
19         DaySL(String JavaDoc title) {
20             super(title);
21         }
22         /* (non-Javadoc)
23          * @see org.oddjob.designer.model.SelectionList#getOptions()
24          */

25         public String JavaDoc[] getOptions() {
26             String JavaDoc[] options = new String JavaDoc[7];
27             Calendar JavaDoc calendar = Calendar.getInstance();
28             for (int i = 0; i < 7; ++i) {
29                 calendar.set(Calendar.DAY_OF_WEEK, i);
30                 String JavaDoc text = new SimpleDateFormat JavaDoc("EEE").format(calendar.getTime());
31                 options[i] = text;
32             }
33             return options;
34         }
35         
36         /* (non-Javadoc)
37          * @see org.oddjob.designer.model.SelectionList#getSelected()
38          */

39         public String JavaDoc getSelected() {
40             return attribute();
41         }
42         
43         /* (non-Javadoc)
44          * @see org.oddjob.designer.model.SelectionList#setSelected(java.lang.String)
45          */

46         public void setSelected(String JavaDoc selected) {
47             attribute(selected);
48         }
49         
50         /* (non-Javadoc)
51          * @see org.oddjob.designer.model.DesignDefinition#isPopulated()
52          */

53         public boolean isPopulated() {
54             return attribute() != null;
55         }
56         
57     }
58     
59     public DesignDefinition detail() {
60         return new DaySL("Day");
61     }
62     
63     
64 }
65
Popular Tags