1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.internal.tools.ListenersTools1_2;
12 import org.rcfaces.core.internal.tools.ListenersTools;
13 import org.rcfaces.core.component.SchedulerColumnComponent;
14 import javax.faces.context.FacesContext;
15
16 public class SchedulerColumnTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(SchedulerColumnTag.class);
20
21 private ValueExpression text;
22 private ValueExpression textDirection;
23 private ValueExpression toolTipText;
24 private ValueExpression alignment;
25 private ValueExpression backgroundColor;
26 private ValueExpression foregroundColor;
27 private ValueExpression styleClass;
28 private ValueExpression width;
29 private ValueExpression height;
30 private ValueExpression verticalAlignment;
31 private ValueExpression selectionListeners;
32 private ValueExpression doubleClickListeners;
33 private ValueExpression userEventListeners;
34 private ValueExpression initListeners;
35 private ValueExpression value;
36 private ValueExpression converter;
37
38 public String getComponentType() {
39 return SchedulerColumnComponent.COMPONENT_TYPE;
40 }
41
42 public final void setText(ValueExpression text) {
43 this.text = text;
44 }
45
46 public final void setTextDirection(ValueExpression textDirection) {
47 this.textDirection = textDirection;
48 }
49
50 public final void setToolTipText(ValueExpression toolTipText) {
51 this.toolTipText = toolTipText;
52 }
53
54 public final void setAlignment(ValueExpression alignment) {
55 this.alignment = alignment;
56 }
57
58 public final void setBackgroundColor(ValueExpression backgroundColor) {
59 this.backgroundColor = backgroundColor;
60 }
61
62 public final void setForegroundColor(ValueExpression foregroundColor) {
63 this.foregroundColor = foregroundColor;
64 }
65
66 public final void setStyleClass(ValueExpression styleClass) {
67 this.styleClass = styleClass;
68 }
69
70 public final void setWidth(ValueExpression width) {
71 this.width = width;
72 }
73
74 public final void setHeight(ValueExpression height) {
75 this.height = height;
76 }
77
78 public final void setVerticalAlignment(ValueExpression verticalAlignment) {
79 this.verticalAlignment = verticalAlignment;
80 }
81
82 public final void setSelectionListener(ValueExpression selectionListeners) {
83 this.selectionListeners = selectionListeners;
84 }
85
86 public final void setDoubleClickListener(ValueExpression doubleClickListeners) {
87 this.doubleClickListeners = doubleClickListeners;
88 }
89
90 public final void setUserEventListener(ValueExpression userEventListeners) {
91 this.userEventListeners = userEventListeners;
92 }
93
94 public final void setInitListener(ValueExpression initListeners) {
95 this.initListeners = initListeners;
96 }
97
98 public final void setValue(ValueExpression value) {
99 this.value = value;
100 }
101
102 public final void setConverter(ValueExpression converter) {
103 this.converter=converter;
104 }
105
106 protected void setProperties(UIComponent uiComponent) {
107 if (LOG.isDebugEnabled()) {
108 if (SchedulerColumnComponent.COMPONENT_TYPE==getComponentType()) {
109 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
110 }
111 LOG.debug(" text='"+text+"'");
112 LOG.debug(" textDirection='"+textDirection+"'");
113 LOG.debug(" toolTipText='"+toolTipText+"'");
114 LOG.debug(" alignment='"+alignment+"'");
115 LOG.debug(" backgroundColor='"+backgroundColor+"'");
116 LOG.debug(" foregroundColor='"+foregroundColor+"'");
117 LOG.debug(" styleClass='"+styleClass+"'");
118 LOG.debug(" width='"+width+"'");
119 LOG.debug(" height='"+height+"'");
120 LOG.debug(" verticalAlignment='"+verticalAlignment+"'");
121 LOG.debug(" value='"+value+"'");
122 }
123 if ((uiComponent instanceof SchedulerColumnComponent)==false) {
124 if (uiComponent instanceof UIViewRoot) {
125 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
126 }
127 throw new IllegalStateException("Component specified by tag is not instanceof of 'SchedulerColumnComponent'.");
128 }
129
130 super.setProperties(uiComponent);
131
132 SchedulerColumnComponent component = (SchedulerColumnComponent) uiComponent;
133 FacesContext facesContext = getFacesContext();
134 Application application = facesContext.getApplication();
135
136 if (text != null) {
137 if (text.isLiteralText()==false) {
138 component.setValueExpression(Properties.TEXT, text);
139
140 } else {
141 component.setText(text.getExpressionString());
142 }
143 }
144
145 if (textDirection != null) {
146 if (textDirection.isLiteralText()==false) {
147 component.setValueExpression(Properties.TEXT_DIRECTION, textDirection);
148
149 } else {
150 component.setTextDirection(getInt(textDirection.getExpressionString()));
151 }
152 }
153
154 if (toolTipText != null) {
155 if (toolTipText.isLiteralText()==false) {
156 component.setValueExpression(Properties.TOOL_TIP_TEXT, toolTipText);
157
158 } else {
159 component.setToolTipText(toolTipText.getExpressionString());
160 }
161 }
162
163 if (alignment != null) {
164 if (alignment.isLiteralText()==false) {
165 component.setValueExpression(Properties.ALIGNMENT, alignment);
166
167 } else {
168 component.setAlignment(alignment.getExpressionString());
169 }
170 }
171
172 if (backgroundColor != null) {
173 if (backgroundColor.isLiteralText()==false) {
174 component.setValueExpression(Properties.BACKGROUND_COLOR, backgroundColor);
175
176 } else {
177 component.setBackgroundColor(backgroundColor.getExpressionString());
178 }
179 }
180
181 if (foregroundColor != null) {
182 if (foregroundColor.isLiteralText()==false) {
183 component.setValueExpression(Properties.FOREGROUND_COLOR, foregroundColor);
184
185 } else {
186 component.setForegroundColor(foregroundColor.getExpressionString());
187 }
188 }
189
190 if (styleClass != null) {
191 if (styleClass.isLiteralText()==false) {
192 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
193
194 } else {
195 component.setStyleClass(styleClass.getExpressionString());
196 }
197 }
198
199 if (width != null) {
200 if (width.isLiteralText()==false) {
201 component.setValueExpression(Properties.WIDTH, width);
202
203 } else {
204 component.setWidth(width.getExpressionString());
205 }
206 }
207
208 if (height != null) {
209 if (height.isLiteralText()==false) {
210 component.setValueExpression(Properties.HEIGHT, height);
211
212 } else {
213 component.setHeight(height.getExpressionString());
214 }
215 }
216
217 if (verticalAlignment != null) {
218 if (verticalAlignment.isLiteralText()==false) {
219 component.setValueExpression(Properties.VERTICAL_ALIGNMENT, verticalAlignment);
220
221 } else {
222 component.setVerticalAlignment(verticalAlignment.getExpressionString());
223 }
224 }
225
226 if (selectionListeners != null) {
227 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.SELECTION_LISTENER_TYPE, selectionListeners);
228 }
229
230 if (doubleClickListeners != null) {
231 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.DOUBLE_CLICK_LISTENER_TYPE, doubleClickListeners);
232 }
233
234 if (userEventListeners != null) {
235 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.USER_EVENT_LISTENER_TYPE, userEventListeners);
236 }
237
238 if (initListeners != null) {
239 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
240 }
241
242 if (value != null) {
243 if (value.isLiteralText()==false) {
244 component.setValueExpression(Properties.VALUE, value);
245
246 } else {
247 component.setValue(value.getExpressionString());
248 }
249 }
250 if (converter != null) {
251 if (converter.isLiteralText()==false) {
252 component.setValueExpression(Properties.CONVERTER, converter);
253 } else {
254 component.setConverter(application.createConverter(converter.getExpressionString()));
255 }
256 }
257 }
258
259 public void release() {
260 text = null;
261 textDirection = null;
262 toolTipText = null;
263 alignment = null;
264 backgroundColor = null;
265 foregroundColor = null;
266 styleClass = null;
267 width = null;
268 height = null;
269 verticalAlignment = null;
270 selectionListeners = null;
271 doubleClickListeners = null;
272 userEventListeners = null;
273 initListeners = null;
274 value = null;
275 converter = null;
276
277 super.release();
278 }
279
280 }