1 package org.rcfaces.core.component;
2
3 import org.rcfaces.core.internal.converter.LiteralDateConverter;
4 import org.rcfaces.core.internal.component.Properties;
5 import org.rcfaces.core.internal.converter.CalendarLayoutConverter;
6 import org.rcfaces.core.component.familly.IContentAccessors;
7 import java.lang.String;
8 import org.apache.commons.logging.LogFactory;
9 import org.rcfaces.core.component.capability.ICalendarLayoutCapability;
10 import java.util.Date;
11 import org.rcfaces.core.component.capability.IForCapability;
12 import javax.faces.context.FacesContext;
13 import org.rcfaces.core.internal.tools.ImageAccessorTools;
14 import org.rcfaces.core.component.capability.IHorizontalTextPositionCapability;
15 import javax.faces.convert.Converter;
16 import org.rcfaces.core.component.AbstractCalendarComponent;
17 import javax.el.ValueExpression;
18 import java.util.HashSet;
19 import org.apache.commons.logging.Log;
20 import java.util.Set;
21 import java.util.Arrays;
22 import org.rcfaces.core.component.capability.IValueChangeEventCapability;
23 import org.rcfaces.core.component.familly.IImageButtonFamilly;
24 import org.rcfaces.core.internal.converter.TextPositionConverter;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 public class DateChooserComponent extends AbstractCalendarComponent implements
64 IImageButtonFamilly,
65 IValueChangeEventCapability,
66 IForCapability,
67 ICalendarLayoutCapability {
68
69 private static final Log LOG = LogFactory.getLog(DateChooserComponent.class);
70
71 public static final String COMPONENT_TYPE="org.rcfaces.core.dateChooser";
72
73 protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCalendarComponent.CAMELIA_ATTRIBUTES);
74 static {
75 CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"disabledImageURL","imageHeight","text","for","borderType","textPosition","hoverImageURL","tabIndex","popupStyleClass","defaultSelectedDate","calendarLayout","selectedImageURL","selectionListener","valueChangeListener","homeDate","readOnly","forValueFormat","border","homeDateLabel","imageURL","disabled","imageWidth"}));
76 }
77
78 public DateChooserComponent() {
79 setRendererType(COMPONENT_TYPE);
80 }
81
82 public DateChooserComponent(String componentId) {
83 this();
84 setId(componentId);
85 }
86
87 public void setHomeDate(String date) {
88
89
90 engine.setProperty(Properties.HOME_DATE, date);
91
92 }
93
94 public Date getHomeDate(FacesContext facesContext) {
95
96
97 Object value=engine.getProperty(Properties.HOME_DATE, facesContext);
98 if (value instanceof String) {
99 value=LiteralDateConverter.SINGLETON.getAsObject(facesContext, this, (String)value);
100 }
101
102 return (Date)value;
103
104 }
105
106 public void setDefaultSelectedDate(String date) {
107
108
109 engine.setProperty(Properties.DEFAULT_SELECTED_DATE, date);
110
111 }
112
113 public Date getDefaultSelectedDate(FacesContext facesContext) {
114
115
116 Object value=engine.getProperty(Properties.DEFAULT_SELECTED_DATE, facesContext);
117 if (value instanceof String) {
118 value=LiteralDateConverter.SINGLETON.getAsObject(facesContext, this, (String)value);
119 }
120
121 return (Date)value;
122
123 }
124
125 protected Converter getTextPositionConverter() {
126
127
128 return TextPositionConverter.SINGLETON;
129
130 }
131
132 public void setTextPosition(String textPosition) {
133
134
135 setTextPosition(((Integer)getTextPositionConverter().getAsObject(null, this, textPosition)).intValue());
136
137 }
138
139 public void setCalendarLayout(String layout) {
140
141
142 setCalendarLayout(((Integer)CalendarLayoutConverter.SINGLETON.getAsObject(null, this, layout)).intValue());
143
144 }
145
146 public java.lang.String getImageURL() {
147 return getImageURL(null);
148 }
149
150
151
152
153 public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
154 return engine.getStringProperty(Properties.IMAGE_URL, facesContext);
155 }
156
157
158
159
160
161 public final boolean isImageURLSetted() {
162 return engine.isPropertySetted(Properties.IMAGE_URL);
163 }
164
165 public void setImageURL(java.lang.String imageURL) {
166 engine.setProperty(Properties.IMAGE_URL, imageURL);
167 }
168
169 public java.lang.String getDisabledImageURL() {
170 return getDisabledImageURL(null);
171 }
172
173
174
175
176 public java.lang.String getDisabledImageURL(javax.faces.context.FacesContext facesContext) {
177 return engine.getStringProperty(Properties.DISABLED_IMAGE_URL, facesContext);
178 }
179
180
181
182
183
184 public final boolean isDisabledImageURLSetted() {
185 return engine.isPropertySetted(Properties.DISABLED_IMAGE_URL);
186 }
187
188 public void setDisabledImageURL(java.lang.String disabledImageURL) {
189 engine.setProperty(Properties.DISABLED_IMAGE_URL, disabledImageURL);
190 }
191
192 public java.lang.String getHoverImageURL() {
193 return getHoverImageURL(null);
194 }
195
196
197
198
199 public java.lang.String getHoverImageURL(javax.faces.context.FacesContext facesContext) {
200 return engine.getStringProperty(Properties.HOVER_IMAGE_URL, facesContext);
201 }
202
203
204
205
206
207 public final boolean isHoverImageURLSetted() {
208 return engine.isPropertySetted(Properties.HOVER_IMAGE_URL);
209 }
210
211 public void setHoverImageURL(java.lang.String hoverImageURL) {
212 engine.setProperty(Properties.HOVER_IMAGE_URL, hoverImageURL);
213 }
214
215 public java.lang.String getSelectedImageURL() {
216 return getSelectedImageURL(null);
217 }
218
219
220
221
222 public java.lang.String getSelectedImageURL(javax.faces.context.FacesContext facesContext) {
223 return engine.getStringProperty(Properties.SELECTED_IMAGE_URL, facesContext);
224 }
225
226
227
228
229
230 public final boolean isSelectedImageURLSetted() {
231 return engine.isPropertySetted(Properties.SELECTED_IMAGE_URL);
232 }
233
234 public void setSelectedImageURL(java.lang.String selectedImageURL) {
235 engine.setProperty(Properties.SELECTED_IMAGE_URL, selectedImageURL);
236 }
237
238 public boolean isBorder() {
239 return isBorder(null);
240 }
241
242
243
244
245 public boolean isBorder(javax.faces.context.FacesContext facesContext) {
246 return engine.getBoolProperty(Properties.BORDER, true, facesContext);
247 }
248
249
250
251
252
253 public final boolean isBorderSetted() {
254 return engine.isPropertySetted(Properties.BORDER);
255 }
256
257 public void setBorder(boolean border) {
258 engine.setProperty(Properties.BORDER, border);
259 }
260
261 public java.lang.String getBorderType() {
262 return getBorderType(null);
263 }
264
265
266
267
268 public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
269 return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
270 }
271
272
273
274
275
276 public final boolean isBorderTypeSetted() {
277 return engine.isPropertySetted(Properties.BORDER_TYPE);
278 }
279
280 public void setBorderType(java.lang.String borderType) {
281 engine.setProperty(Properties.BORDER_TYPE, borderType);
282 }
283
284 public java.lang.String getText() {
285 return getText(null);
286 }
287
288
289
290
291 public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
292 return engine.getStringProperty(Properties.TEXT, facesContext);
293 }
294
295
296
297
298
299 public final boolean isTextSetted() {
300 return engine.isPropertySetted(Properties.TEXT);
301 }
302
303 public void setText(java.lang.String text) {
304 engine.setProperty(Properties.TEXT, text);
305 }
306
307 public int getTextPosition() {
308 return getTextPosition(null);
309 }
310
311
312
313
314 public int getTextPosition(javax.faces.context.FacesContext facesContext) {
315 return engine.getIntProperty(Properties.TEXT_POSITION,IHorizontalTextPositionCapability.DEFAULT_POSITION, facesContext);
316 }
317
318
319
320
321
322 public final boolean isTextPositionSetted() {
323 return engine.isPropertySetted(Properties.TEXT_POSITION);
324 }
325
326 public void setTextPosition(int textPosition) {
327 engine.setProperty(Properties.TEXT_POSITION, textPosition);
328 }
329
330 public int getImageHeight() {
331 return getImageHeight(null);
332 }
333
334
335
336
337 public int getImageHeight(javax.faces.context.FacesContext facesContext) {
338 return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
339 }
340
341
342
343
344
345 public final boolean isImageHeightSetted() {
346 return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
347 }
348
349 public void setImageHeight(int imageHeight) {
350 engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
351 }
352
353 public int getImageWidth() {
354 return getImageWidth(null);
355 }
356
357
358
359
360 public int getImageWidth(javax.faces.context.FacesContext facesContext) {
361 return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
362 }
363
364
365
366
367
368 public final boolean isImageWidthSetted() {
369 return engine.isPropertySetted(Properties.IMAGE_WIDTH);
370 }
371
372 public void setImageWidth(int imageWidth) {
373 engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
374 }
375
376 public IContentAccessors getImageAccessors(FacesContext facesContext) {
377
378
379 return ImageAccessorTools.createImageAccessors(facesContext, this, engine);
380
381 }
382
383 public IContentAccessors getImageAccessors() {
384
385
386 return getImageAccessors(null);
387
388 }
389
390 public final void addValueChangeListener(javax.faces.event.ValueChangeListener listener) {
391 addFacesListener(listener);
392 }
393
394 public final void removeValueChangeListener(javax.faces.event.ValueChangeListener listener) {
395 removeFacesListener(listener);
396 }
397
398 public final javax.faces.event.FacesListener [] listValueChangeListeners() {
399 return getFacesListeners(javax.faces.event.ValueChangeListener.class);
400 }
401
402 public java.lang.String getFor() {
403 return getFor(null);
404 }
405
406
407
408
409 public java.lang.String getFor(javax.faces.context.FacesContext facesContext) {
410 return engine.getStringProperty(Properties.FOR, facesContext);
411 }
412
413
414
415
416
417 public final boolean isForSetted() {
418 return engine.isPropertySetted(Properties.FOR);
419 }
420
421 public void setFor(java.lang.String forValue) {
422 engine.setProperty(Properties.FOR, forValue);
423 }
424
425 public int getCalendarLayout() {
426 return getCalendarLayout(null);
427 }
428
429
430
431
432 public int getCalendarLayout(javax.faces.context.FacesContext facesContext) {
433 return engine.getIntProperty(Properties.CALENDAR_LAYOUT,ICalendarLayoutCapability.DEFAULT_LAYOUT, facesContext);
434 }
435
436
437
438
439
440 public final boolean isCalendarLayoutSetted() {
441 return engine.isPropertySetted(Properties.CALENDAR_LAYOUT);
442 }
443
444 public void setCalendarLayout(int calendarLayout) {
445 engine.setProperty(Properties.CALENDAR_LAYOUT, calendarLayout);
446 }
447
448
449
450
451
452 public String getForValueFormat() {
453 return getForValueFormat(null);
454 }
455
456
457
458
459
460 public String getForValueFormat(javax.faces.context.FacesContext facesContext) {
461 return engine.getStringProperty(Properties.FOR_VALUE_FORMAT, facesContext);
462 }
463
464
465
466
467
468 public void setForValueFormat(String forValueFormat) {
469 engine.setProperty(Properties.FOR_VALUE_FORMAT, forValueFormat);
470 }
471
472
473
474
475
476
477
478
479
480 public boolean isForValueFormatSetted() {
481 return engine.isPropertySetted(Properties.FOR_VALUE_FORMAT);
482 }
483
484 public java.util.Date getHomeDate() {
485 return getHomeDate(null);
486 }
487
488 public void setHomeDate(java.util.Date homeDate) {
489 engine.setProperty(Properties.HOME_DATE, homeDate);
490 }
491
492
493
494
495
496 public boolean isHomeDateSetted() {
497 return engine.isPropertySetted(Properties.HOME_DATE);
498 }
499
500 public java.util.Date getDefaultSelectedDate() {
501 return getDefaultSelectedDate(null);
502 }
503
504 public void setDefaultSelectedDate(java.util.Date defaultSelectedDate) {
505 engine.setProperty(Properties.DEFAULT_SELECTED_DATE, defaultSelectedDate);
506 }
507
508
509
510
511
512 public boolean isDefaultSelectedDateSetted() {
513 return engine.isPropertySetted(Properties.DEFAULT_SELECTED_DATE);
514 }
515
516
517
518
519
520 public String getHomeDateLabel() {
521 return getHomeDateLabel(null);
522 }
523
524
525
526
527
528 public String getHomeDateLabel(javax.faces.context.FacesContext facesContext) {
529 return engine.getStringProperty(Properties.HOME_DATE_LABEL, facesContext);
530 }
531
532
533
534
535
536 public void setHomeDateLabel(String homeDateLabel) {
537 engine.setProperty(Properties.HOME_DATE_LABEL, homeDateLabel);
538 }
539
540
541
542
543
544
545
546
547
548 public boolean isHomeDateLabelSetted() {
549 return engine.isPropertySetted(Properties.HOME_DATE_LABEL);
550 }
551
552 public String getPopupStyleClass() {
553 return getPopupStyleClass(null);
554 }
555
556 public String getPopupStyleClass(javax.faces.context.FacesContext facesContext) {
557 return engine.getStringProperty(Properties.POPUP_STYLE_CLASS, facesContext);
558 }
559
560 public void setPopupStyleClass(String popupStyleClass) {
561 engine.setProperty(Properties.POPUP_STYLE_CLASS, popupStyleClass);
562 }
563
564
565
566
567
568 public boolean isPopupStyleClassSetted() {
569 return engine.isPropertySetted(Properties.POPUP_STYLE_CLASS);
570 }
571
572 protected Set getCameliaFields() {
573 return CAMELIA_ATTRIBUTES;
574 }
575 }