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 MonthAttribute extends SimpleAttribute { 17 18 class MonthSL extends SelectionList { 19 MonthSL(String title) { 20 super(title); 21 } 22 25 public String [] getOptions() { 26 String [] options = new String [12]; 27 Calendar calendar = Calendar.getInstance(); 28 for (int i = 0; i < 12; ++i) { 29 calendar.set(Calendar.DAY_OF_MONTH, 1); 30 calendar.set(Calendar.MONTH, i); 31 System.out.println(calendar.getTime()); 32 String text = new SimpleDateFormat ("MMM").format(calendar.getTime()); 33 options[i] = text; 34 } 35 return options; 36 } 37 38 41 public String getSelected() { 42 return attribute(); 43 } 44 45 48 public void setSelected(String selected) { 49 attribute(selected); 50 } 51 52 55 public boolean isPopulated() { 56 return attribute() != null; 57 } 58 59 } 60 61 public DesignDefinition detail() { 62 return new MonthSL("Month"); 63 } 64 65 66 } 67 | Popular Tags |