View Javadoc

1   package org.rcfaces.core.internal.taglib;
2   
3   import javax.faces.application.Application;
4   import org.rcfaces.core.component.SchedulerComponent;
5   import javax.faces.component.UIComponent;
6   import org.rcfaces.core.internal.component.Properties;
7   import javax.el.ValueExpression;
8   import javax.faces.component.UIViewRoot;
9   import org.apache.commons.logging.Log;
10  import javax.servlet.jsp.tagext.Tag;
11  import org.apache.commons.logging.LogFactory;
12  import org.rcfaces.core.internal.tools.ListenersTools1_2;
13  import org.rcfaces.core.internal.tools.ListenersTools;
14  import javax.faces.context.FacesContext;
15  
16  public class SchedulerTag extends CameliaTag implements Tag {
17  
18  
19  	private static final Log LOG=LogFactory.getLog(SchedulerTag.class);
20  
21  	private ValueExpression width;
22  	private ValueExpression height;
23  	private ValueExpression horizontalScrollPosition;
24  	private ValueExpression verticalScrollPosition;
25  	private ValueExpression literalLocale;
26  	private ValueExpression literalTimeZone;
27  	private ValueExpression styleClass;
28  	private ValueExpression tabIndex;
29  	private ValueExpression immediate;
30  	private ValueExpression selectionListeners;
31  	private ValueExpression dateBegin;
32  	private ValueExpression hourBegin;
33  	private ValueExpression hourEnd;
34  	private ValueExpression primaryTick;
35  	private ValueExpression secondaryTick;
36  	private ValueExpression showPrimaryTickLabel;
37  	private ValueExpression showSecondaryTickLabel;
38  	private ValueExpression periods;
39  	private ValueExpression periodBegin;
40  	private ValueExpression periodEnd;
41  	private ValueExpression periodLabel;
42  	private ValueExpression periodStyle;
43  	private ValueExpression periodSelectable;
44  	private ValueExpression periodToolTip;
45  	private ValueExpression periodValue;
46  	private ValueExpression periodType;
47  	private ValueExpression var;
48  	public String getComponentType() {
49  		return SchedulerComponent.COMPONENT_TYPE;
50  	}
51  
52  	public final void setWidth(ValueExpression width) {
53  		this.width = width;
54  	}
55  
56  	public final void setHeight(ValueExpression height) {
57  		this.height = height;
58  	}
59  
60  	public final void setHorizontalScrollPosition(ValueExpression horizontalScrollPosition) {
61  		this.horizontalScrollPosition = horizontalScrollPosition;
62  	}
63  
64  	public final void setVerticalScrollPosition(ValueExpression verticalScrollPosition) {
65  		this.verticalScrollPosition = verticalScrollPosition;
66  	}
67  
68  	public final void setLiteralLocale(ValueExpression literalLocale) {
69  		this.literalLocale = literalLocale;
70  	}
71  
72  	public final void setLiteralTimeZone(ValueExpression literalTimeZone) {
73  		this.literalTimeZone = literalTimeZone;
74  	}
75  
76  	public final void setStyleClass(ValueExpression styleClass) {
77  		this.styleClass = styleClass;
78  	}
79  
80  	public final void setTabIndex(ValueExpression tabIndex) {
81  		this.tabIndex = tabIndex;
82  	}
83  
84  	public final void setImmediate(ValueExpression immediate) {
85  		this.immediate = immediate;
86  	}
87  
88  	public final void setSelectionListener(ValueExpression selectionListeners) {
89  		this.selectionListeners = selectionListeners;
90  	}
91  
92  	public final void setDateBegin(ValueExpression dateBegin) {
93  		this.dateBegin = dateBegin;
94  	}
95  
96  	public final void setHourBegin(ValueExpression hourBegin) {
97  		this.hourBegin = hourBegin;
98  	}
99  
100 	public final void setHourEnd(ValueExpression hourEnd) {
101 		this.hourEnd = hourEnd;
102 	}
103 
104 	public final void setPrimaryTick(ValueExpression primaryTick) {
105 		this.primaryTick = primaryTick;
106 	}
107 
108 	public final void setSecondaryTick(ValueExpression secondaryTick) {
109 		this.secondaryTick = secondaryTick;
110 	}
111 
112 	public final void setShowPrimaryTickLabel(ValueExpression showPrimaryTickLabel) {
113 		this.showPrimaryTickLabel = showPrimaryTickLabel;
114 	}
115 
116 	public final void setShowSecondaryTickLabel(ValueExpression showSecondaryTickLabel) {
117 		this.showSecondaryTickLabel = showSecondaryTickLabel;
118 	}
119 
120 	public final void setPeriods(ValueExpression periods) {
121 		this.periods = periods;
122 	}
123 
124 	public final void setPeriodBegin(ValueExpression periodBegin) {
125 		this.periodBegin = periodBegin;
126 	}
127 
128 	public final void setPeriodEnd(ValueExpression periodEnd) {
129 		this.periodEnd = periodEnd;
130 	}
131 
132 	public final void setPeriodLabel(ValueExpression periodLabel) {
133 		this.periodLabel = periodLabel;
134 	}
135 
136 	public final void setPeriodStyle(ValueExpression periodStyle) {
137 		this.periodStyle = periodStyle;
138 	}
139 
140 	public final void setPeriodSelectable(ValueExpression periodSelectable) {
141 		this.periodSelectable = periodSelectable;
142 	}
143 
144 	public final void setPeriodToolTip(ValueExpression periodToolTip) {
145 		this.periodToolTip = periodToolTip;
146 	}
147 
148 	public final void setPeriodValue(ValueExpression periodValue) {
149 		this.periodValue = periodValue;
150 	}
151 
152 	public final void setPeriodType(ValueExpression periodType) {
153 		this.periodType = periodType;
154 	}
155 
156 	public final void setVar(ValueExpression var) {
157 		this.var = var;
158 	}
159 
160 	protected void setProperties(UIComponent uiComponent) {
161 		if (LOG.isDebugEnabled()) {
162 			if (SchedulerComponent.COMPONENT_TYPE==getComponentType()) {
163 				LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
164 			}
165 			LOG.debug("  width='"+width+"'");
166 			LOG.debug("  height='"+height+"'");
167 			LOG.debug("  horizontalScrollPosition='"+horizontalScrollPosition+"'");
168 			LOG.debug("  verticalScrollPosition='"+verticalScrollPosition+"'");
169 			LOG.debug("  literalLocale='"+literalLocale+"'");
170 			LOG.debug("  literalTimeZone='"+literalTimeZone+"'");
171 			LOG.debug("  styleClass='"+styleClass+"'");
172 			LOG.debug("  tabIndex='"+tabIndex+"'");
173 			LOG.debug("  immediate='"+immediate+"'");
174 			LOG.debug("  dateBegin='"+dateBegin+"'");
175 			LOG.debug("  hourBegin='"+hourBegin+"'");
176 			LOG.debug("  hourEnd='"+hourEnd+"'");
177 			LOG.debug("  primaryTick='"+primaryTick+"'");
178 			LOG.debug("  secondaryTick='"+secondaryTick+"'");
179 			LOG.debug("  showPrimaryTickLabel='"+showPrimaryTickLabel+"'");
180 			LOG.debug("  showSecondaryTickLabel='"+showSecondaryTickLabel+"'");
181 			LOG.debug("  periods='"+periods+"'");
182 			LOG.debug("  periodBegin='"+periodBegin+"'");
183 			LOG.debug("  periodEnd='"+periodEnd+"'");
184 			LOG.debug("  periodLabel='"+periodLabel+"'");
185 			LOG.debug("  periodStyle='"+periodStyle+"'");
186 			LOG.debug("  periodSelectable='"+periodSelectable+"'");
187 			LOG.debug("  periodToolTip='"+periodToolTip+"'");
188 			LOG.debug("  periodValue='"+periodValue+"'");
189 			LOG.debug("  periodType='"+periodType+"'");
190 			LOG.debug("  var='"+var+"'");
191 		}
192 		if ((uiComponent instanceof SchedulerComponent)==false) {
193 			if (uiComponent instanceof UIViewRoot) {
194 				throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
195 			}
196 			throw new IllegalStateException("Component specified by tag is not instanceof of 'SchedulerComponent'.");
197 		}
198 
199 		super.setProperties(uiComponent);
200 
201 		SchedulerComponent component = (SchedulerComponent) uiComponent;
202 		FacesContext facesContext = getFacesContext();
203 
204 		if (width != null) {
205 			if (width.isLiteralText()==false) {
206 				component.setValueExpression(Properties.WIDTH, width);
207 
208 			} else {
209 				component.setWidth(width.getExpressionString());
210 			}
211 		}
212 
213 		if (height != null) {
214 			if (height.isLiteralText()==false) {
215 				component.setValueExpression(Properties.HEIGHT, height);
216 
217 			} else {
218 				component.setHeight(height.getExpressionString());
219 			}
220 		}
221 
222 		if (horizontalScrollPosition != null) {
223 			if (horizontalScrollPosition.isLiteralText()==false) {
224 				component.setValueExpression(Properties.HORIZONTAL_SCROLL_POSITION, horizontalScrollPosition);
225 
226 			} else {
227 				component.setHorizontalScrollPosition(getInt(horizontalScrollPosition.getExpressionString()));
228 			}
229 		}
230 
231 		if (verticalScrollPosition != null) {
232 			if (verticalScrollPosition.isLiteralText()==false) {
233 				component.setValueExpression(Properties.VERTICAL_SCROLL_POSITION, verticalScrollPosition);
234 
235 			} else {
236 				component.setVerticalScrollPosition(getInt(verticalScrollPosition.getExpressionString()));
237 			}
238 		}
239 
240 		if (literalLocale != null) {
241 			if (literalLocale.isLiteralText()==false) {
242 				component.setValueExpression(Properties.LITERAL_LOCALE, literalLocale);
243 
244 			} else {
245 				component.setLiteralLocale(literalLocale.getExpressionString());
246 			}
247 		}
248 
249 		if (literalTimeZone != null) {
250 			if (literalTimeZone.isLiteralText()==false) {
251 				component.setValueExpression(Properties.LITERAL_TIME_ZONE, literalTimeZone);
252 
253 			} else {
254 				component.setLiteralTimeZone(literalTimeZone.getExpressionString());
255 			}
256 		}
257 
258 		if (styleClass != null) {
259 			if (styleClass.isLiteralText()==false) {
260 				component.setValueExpression(Properties.STYLE_CLASS, styleClass);
261 
262 			} else {
263 				component.setStyleClass(styleClass.getExpressionString());
264 			}
265 		}
266 
267 		if (tabIndex != null) {
268 			if (tabIndex.isLiteralText()==false) {
269 				component.setValueExpression(Properties.TAB_INDEX, tabIndex);
270 
271 			} else {
272 				component.setTabIndex(getInteger(tabIndex.getExpressionString()));
273 			}
274 		}
275 
276 		if (immediate != null) {
277 			if (immediate.isLiteralText()==false) {
278 				component.setValueExpression(Properties.IMMEDIATE, immediate);
279 
280 			} else {
281 				component.setImmediate(getBool(immediate.getExpressionString()));
282 			}
283 		}
284 
285 		if (selectionListeners != null) {
286 			ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
287 		}
288 
289 		if (dateBegin != null) {
290 			if (dateBegin.isLiteralText()==false) {
291 				component.setValueExpression(Properties.DATE_BEGIN, dateBegin);
292 
293 			} else {
294 				component.setDateBegin(dateBegin.getExpressionString());
295 			}
296 		}
297 
298 		if (hourBegin != null) {
299 			if (hourBegin.isLiteralText()==false) {
300 				component.setValueExpression(Properties.HOUR_BEGIN, hourBegin);
301 
302 			} else {
303 				component.setHourBegin(hourBegin.getExpressionString());
304 			}
305 		}
306 
307 		if (hourEnd != null) {
308 			if (hourEnd.isLiteralText()==false) {
309 				component.setValueExpression(Properties.HOUR_END, hourEnd);
310 
311 			} else {
312 				component.setHourEnd(hourEnd.getExpressionString());
313 			}
314 		}
315 
316 		if (primaryTick != null) {
317 			if (primaryTick.isLiteralText()==false) {
318 				component.setValueExpression(Properties.PRIMARY_TICK, primaryTick);
319 
320 			} else {
321 				component.setPrimaryTick(getInt(primaryTick.getExpressionString()));
322 			}
323 		}
324 
325 		if (secondaryTick != null) {
326 			if (secondaryTick.isLiteralText()==false) {
327 				component.setValueExpression(Properties.SECONDARY_TICK, secondaryTick);
328 
329 			} else {
330 				component.setSecondaryTick(getInt(secondaryTick.getExpressionString()));
331 			}
332 		}
333 
334 		if (showPrimaryTickLabel != null) {
335 			if (showPrimaryTickLabel.isLiteralText()==false) {
336 				component.setValueExpression(Properties.SHOW_PRIMARY_TICK_LABEL, showPrimaryTickLabel);
337 
338 			} else {
339 				component.setShowPrimaryTickLabel(getBool(showPrimaryTickLabel.getExpressionString()));
340 			}
341 		}
342 
343 		if (showSecondaryTickLabel != null) {
344 			if (showSecondaryTickLabel.isLiteralText()==false) {
345 				component.setValueExpression(Properties.SHOW_SECONDARY_TICK_LABEL, showSecondaryTickLabel);
346 
347 			} else {
348 				component.setShowSecondaryTickLabel(getBool(showSecondaryTickLabel.getExpressionString()));
349 			}
350 		}
351 
352 		if (periods != null) {
353 			if (periods.isLiteralText()==false) {
354 				component.setValueExpression(Properties.PERIODS, periods);
355 
356 			} else {
357 				component.setPeriods(periods.getExpressionString());
358 			}
359 		}
360 
361 		if (periodBegin != null) {
362 			if (periodBegin.isLiteralText()==false) {
363 				component.setValueExpression(Properties.PERIOD_BEGIN, periodBegin);
364 
365 			} else {
366 				component.setPeriodBegin(periodBegin.getExpressionString());
367 			}
368 		}
369 
370 		if (periodEnd != null) {
371 			if (periodEnd.isLiteralText()==false) {
372 				component.setValueExpression(Properties.PERIOD_END, periodEnd);
373 
374 			} else {
375 				component.setPeriodEnd(periodEnd.getExpressionString());
376 			}
377 		}
378 
379 		if (periodLabel != null) {
380 			if (periodLabel.isLiteralText()==false) {
381 				component.setValueExpression(Properties.PERIOD_LABEL, periodLabel);
382 
383 			} else {
384 				component.setPeriodLabel(periodLabel.getExpressionString());
385 			}
386 		}
387 
388 		if (periodStyle != null) {
389 			if (periodStyle.isLiteralText()==false) {
390 				component.setValueExpression(Properties.PERIOD_STYLE, periodStyle);
391 
392 			} else {
393 				component.setPeriodStyle(periodStyle.getExpressionString());
394 			}
395 		}
396 
397 		if (periodSelectable != null) {
398 			if (periodSelectable.isLiteralText()==false) {
399 				component.setValueExpression(Properties.PERIOD_SELECTABLE, periodSelectable);
400 
401 			} else {
402 				component.setPeriodSelectable(getBool(periodSelectable.getExpressionString()));
403 			}
404 		}
405 
406 		if (periodToolTip != null) {
407 			if (periodToolTip.isLiteralText()==false) {
408 				component.setValueExpression(Properties.PERIOD_TOOL_TIP, periodToolTip);
409 
410 			} else {
411 				component.setPeriodToolTip(periodToolTip.getExpressionString());
412 			}
413 		}
414 
415 		if (periodValue != null) {
416 			if (periodValue.isLiteralText()==false) {
417 				component.setValueExpression(Properties.PERIOD_VALUE, periodValue);
418 
419 			} else {
420 				component.setPeriodValue(periodValue.getExpressionString());
421 			}
422 		}
423 
424 		if (periodType != null) {
425 			if (periodType.isLiteralText()==false) {
426 				component.setValueExpression(Properties.PERIOD_TYPE, periodType);
427 
428 			} else {
429 				component.setPeriodType(periodType.getExpressionString());
430 			}
431 		}
432 
433 		if (var != null) {
434 			if (var.isLiteralText()==false) {
435 				component.setValueExpression(Properties.VAR, var);
436 
437 			} else {
438 				component.setVar(var.getExpressionString());
439 			}
440 		}
441 	}
442 
443 	public void release() {
444 		width = null;
445 		height = null;
446 		horizontalScrollPosition = null;
447 		verticalScrollPosition = null;
448 		literalLocale = null;
449 		literalTimeZone = null;
450 		styleClass = null;
451 		tabIndex = null;
452 		immediate = null;
453 		selectionListeners = null;
454 		dateBegin = null;
455 		hourBegin = null;
456 		hourEnd = null;
457 		primaryTick = null;
458 		secondaryTick = null;
459 		showPrimaryTickLabel = null;
460 		showSecondaryTickLabel = null;
461 		periods = null;
462 		periodBegin = null;
463 		periodEnd = null;
464 		periodLabel = null;
465 		periodStyle = null;
466 		periodSelectable = null;
467 		periodToolTip = null;
468 		periodValue = null;
469 		periodType = null;
470 		var = null;
471 
472 		super.release();
473 	}
474 
475 }