1 28 29 package Jmc.plugins.calendar; 30 31 import Jmc.baseGui.*; 32 import Jmc.baseTools.*; 33 import Jmc.commonGui.*; 34 import Jmc.plugins.*; 35 36 import java.util.*; 37 38 45 public class Calendar extends base_aggregatedPlugin 46 { 47 private GregorianCalendar pem_cal = new GregorianCalendar(); 48 private ArrayList pem_days = new ArrayList(); 49 private int pem_year = 0; 50 private int pem_month = 0; 51 private int pem_day = 0; 52 53 56 class CallendarYearMonthSel_li implements base_guiListener 57 { 58 public void pcmf_execListener(base_guiObj xParam) throws Exception 59 { 60 base_comboBox_if l_mon = (base_comboBox_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Month"); 61 base_inputField_if l_year = (base_inputField_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Year"); 62 63 Calendar.this.pem_cal.set(java.util.Calendar.MONTH, Integer.parseInt(l_mon.pcmf_getValue().toString())); 64 Calendar.this.pem_cal.set(java.util.Calendar.YEAR, Integer.parseInt(l_year.pcmf_getValue().toString())); 65 66 Calendar.this.pcmf_loadMonth(false); 67 68 Calendar.this.pcmf_getPluginObject().pcmf_dispatchEvent(); 70 } 71 } 72 73 76 class CallendarDaySel_li implements base_guiListener 77 { 78 public void pcmf_execListener(base_guiObj xParam) throws Exception 79 { 80 base_comboBox_if l_mon = (base_comboBox_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Month"); 81 base_inputField_if l_year = (base_inputField_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Year"); 82 83 Calendar.this.pem_cal.set(java.util.Calendar.MONTH, Integer.parseInt(l_mon.pcmf_getValue().toString())); 84 Calendar.this.pem_cal.set(java.util.Calendar.YEAR, Integer.parseInt(l_year.pcmf_getValue().toString())); 85 Calendar.this.pem_cal.set(java.util.Calendar.DAY_OF_MONTH, Integer.parseInt(xParam.pcmf_getValue().toString())); 86 87 Calendar.this.pcmf_loadMonth(false); 88 89 Calendar.this.pcmf_getPluginObject().pcmf_dispatchEvent(); 91 } 92 } 93 94 99 public GregorianCalendar pcmf_getDate() 100 { 101 GregorianCalendar l_cal = new GregorianCalendar(); 102 103 base_comboBox_if l_mon = (base_comboBox_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Month"); 104 base_inputField_if l_year = (base_inputField_if)Calendar.this.pcmf_getPluginObject().pcmf_getSubNode("Year"); 105 106 l_cal.set(java.util.Calendar.MONTH, pem_month); 107 l_cal.set(java.util.Calendar.YEAR, pem_year); 108 l_cal.set(java.util.Calendar.DAY_OF_MONTH, pem_day); 109 110 return (l_cal); 111 } 112 113 118 public void pcmf_setDate(GregorianCalendar xDate) 119 { 120 Calendar.this.pem_cal.set(java.util.Calendar.MONTH, xDate.get(java.util.Calendar.MONTH)); 121 Calendar.this.pem_cal.set(java.util.Calendar.YEAR, xDate.get(java.util.Calendar.YEAR)); 122 Calendar.this.pem_cal.set(java.util.Calendar.DAY_OF_MONTH, xDate.get(java.util.Calendar.DAY_OF_MONTH)); 123 124 Calendar.this.pcmf_loadMonth(true); 125 } 126 127 128 134 public void pcmf_initPlugin(base_guiObj xPl, Object xParam, String xRoot) 135 { 136 super.pcmf_initPlugin(xPl, xParam, xRoot); 137 138 base_comboBox_if l_mon = (base_comboBox_if)this.pcmf_getPluginObject().pcmf_getSubNode("Month"); 139 base_inputField_if l_year = (base_inputField_if)this.pcmf_getPluginObject().pcmf_getSubNode("Year"); 140 141 l_mon.pcmf_addListener(new CallendarYearMonthSel_li()); 142 l_year.pcmf_addListener(new CallendarYearMonthSel_li()); 143 144 this.pcmf_loadMonth(true); 145 } 146 147 152 public void pcmf_setMonth(int xMon) 153 { 154 pem_cal.set(java.util.Calendar.MONTH, xMon); 155 this.pcmf_loadMonth(true); 156 } 157 158 163 public void pcmf_loadMonth(boolean xSetInput) 164 { 165 base_appl_if l_appl = this.pcmf_getPluginObject().pcmf_getAppl(); 166 167 base_form_if l_form = (base_form_if)this.pcmf_getPluginObject().pcmf_getSubNode("Day"); 168 base_comboBox_if l_mon = (base_comboBox_if)this.pcmf_getPluginObject().pcmf_getSubNode("Month"); 169 base_inputField_if l_year = (base_inputField_if)this.pcmf_getPluginObject().pcmf_getSubNode("Year"); 170 171 int l_currDay = pem_day = pem_cal.get(java.util.Calendar.DAY_OF_MONTH); 172 int l_currMon = pem_month = pem_cal.get(java.util.Calendar.MONTH); 173 pem_year = pem_cal.get(java.util.Calendar.YEAR); 174 175 pem_cal.roll(java.util.Calendar.DAY_OF_MONTH, 1-l_currDay); 176 177 GregorianCalendar l_cal = new GregorianCalendar(); 178 179 if (xSetInput) 180 { 181 l_mon.pcmf_setValue(Integer.toString(l_currMon)); 182 l_year.pcmf_setValue(Integer.toString(pem_cal.get(java.util.Calendar.YEAR))); 183 } 184 185 try 186 { 187 Iterator l_it = this.pem_days.iterator(); 188 while (l_it.hasNext()) 189 ((base_registredObject)l_it.next()).pcmf_delete(); 190 } 191 catch (Exception e) 192 { 193 base_log.pcmf_log("CalendarPlugin", "error during cleanup", this, base_log.ERROR); 194 } 195 int l_dayName = 0; 196 int l_dayCnt = 0; 197 base_link_if l_text = null; 198 while (true) 199 { 200 l_dayCnt = pem_cal.get(java.util.Calendar.DAY_OF_MONTH); 201 l_dayName = pem_cal.get(java.util.Calendar.DAY_OF_WEEK); 202 l_text = (base_link_if)l_appl.pcmf_getGuiObjFactory().pcmf_createLink(l_appl.pcmf_getApplType(), Integer.toString(l_dayCnt), l_appl); 203 l_text.pcmf_addListener(new CallendarDaySel_li()); 204 l_text.pcmf_enableSubmit(); 205 l_text.pcmf_setFixedSize(25,25, gui_fixedSize.FIX_SIZE); 206 207 if (l_cal.get(java.util.Calendar.DAY_OF_MONTH) == l_dayCnt && 208 l_cal.get(java.util.Calendar.MONTH) == pem_cal.get(java.util.Calendar.MONTH) && 209 l_cal.get(java.util.Calendar.YEAR) == pem_cal.get(java.util.Calendar.YEAR)) 210 l_text.pcmf_setFgColor("blue"); 211 212 if (l_dayCnt == l_currDay) 213 l_text.pcmf_setFgColor("red"); 214 215 this.pem_days.add(l_text); 216 switch (l_dayName) 217 { 218 case java.util.Calendar.MONDAY: 219 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 220 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 0, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 221 break; 222 case java.util.Calendar.TUESDAY: 223 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 224 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 1, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 225 break; 226 case java.util.Calendar.WEDNESDAY: 227 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 228 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 2, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 229 break; 230 case java.util.Calendar.THURSDAY: 231 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 232 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 3, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 233 break; 234 case java.util.Calendar.FRIDAY: 235 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 236 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 4, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 237 break; 238 case java.util.Calendar.SATURDAY: 239 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 240 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 5, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 241 break; 242 case java.util.Calendar.SUNDAY: 243 l_form.pcmf_addWidget("", l_text.pcmf_getGuiObj()); 244 l_form.pcmf_setGuiObjPosition(l_text.pcmf_getGuiObj(), 6, pem_cal.get(java.util.Calendar.WEEK_OF_MONTH) + 1, 1, 1, "CENTER"); 245 break; 246 } 247 pem_cal.roll(java.util.Calendar.DAY_OF_YEAR, 1); 248 if (pem_cal.get(java.util.Calendar.MONTH) != l_currMon) 249 break; 250 } 251 l_form.pcmf_repaint(); 252 } 253 } 254 | Popular Tags |