1 4 package org.oddjob.designer.elements.date; 5 6 import java.text.SimpleDateFormat ; 7 import java.util.Calendar ; 8 9 import org.oddjob.designer.model.DesignDefinition; 10 import org.oddjob.designer.model.SelectionList; 11 import org.oddjob.designer.model.SimpleAttribute; 12 13 16 public class DayAttribute extends SimpleAttribute { 17 18 class DaySL extends SelectionList { 19 DaySL(String title) { 20 super(title); 21 } 22 25 public String [] getOptions() { 26 String [] options = new String [7]; 27 Calendar calendar = Calendar.getInstance(); 28 for (int i = 0; i < 7; ++i) { 29 calendar.set(Calendar.DAY_OF_WEEK, i); 30 String text = new SimpleDateFormat ("EEE").format(calendar.getTime()); 31 options[i] = text; 32 } 33 return options; 34 } 35 36 39 public String getSelected() { 40 return attribute(); 41 } 42 43 46 public void setSelected(String selected) { 47 attribute(selected); 48 } 49 50 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 |