1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.component;
21
22 import javax.faces.context.FacesContext;
23 import org.apache.myfaces.tobago.context.Markup;
24 import org.apache.myfaces.tobago.internal.component.AbstractUIMenu;
25 import org.apache.myfaces.tobago.layout.Display;
26 import org.apache.myfaces.tobago.layout.Measure;
27 import org.apache.commons.lang.ArrayUtils;
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.myfaces.tobago.internal.util.Deprecation;
30 import org.apache.myfaces.tobago.renderkit.MarginValues;
31 import org.apache.myfaces.tobago.renderkit.SpacingValues;
32 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
33 import javax.el.ELException;
34 import javax.faces.FacesException;
35 import java.util.ArrayList;
36 import java.util.List;
37 import javax.el.MethodExpression;
38 import javax.el.ValueExpression;
39
40
41
42
43
44
45 public class UIMenu
46 extends AbstractUIMenu implements SupportsMarkup {
47
48 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Menu";
49
50 public static final String COMPONENT_FAMILY = "javax.faces.Panel";
51
52 private org.apache.myfaces.tobago.context.Markup currentMarkup;
53
54 enum PropertyKeys {
55 markup,
56 accessKey,
57 marginLeft,
58 labelWithAccessKey,
59 minimumHeight,
60 height,
61 minimumWidth,
62 rowSpan,
63 left,
64 columnSpan,
65 maximumHeight,
66 top,
67 currentWidth,
68 marginTop,
69 marginRight,
70 width,
71 preferredHeight,
72 currentHeight,
73 image,
74 label,
75 display,
76 maximumWidth,
77 preferredWidth,
78 marginBottom,
79 verticalIndex,
80 horizontalIndex,
81 disabled,
82 }
83
84 public String getFamily() {
85 return COMPONENT_FAMILY;
86 }
87
88
89 public org.apache.myfaces.tobago.context.Markup getMarkup() {
90 Object object = getStateHelper().eval(PropertyKeys.markup);
91 if (object != null) {
92 return Markup.valueOf(object);
93 }
94 return null;
95 }
96
97 public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
98 getStateHelper().put(PropertyKeys.markup, markup);
99 }
100
101
102
103
104
105 @Deprecated
106 public java.lang.Character getAccessKey() {
107 Deprecation.LOG.error("The attribute 'accessKey' of 'UIMenu' is deprecated. "
108 + "Please refer the documentation for further information.");
109 return (java.lang.Character) getStateHelper().eval(PropertyKeys.accessKey);
110 }
111
112 @Deprecated
113 public void setAccessKey(java.lang.Character accessKey) {
114 getStateHelper().put(PropertyKeys.accessKey, accessKey);
115 }
116
117 public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
118 Object object = getStateHelper().eval(PropertyKeys.marginLeft);
119 if (object != null) {
120 return Measure.valueOf(object);
121 }
122 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
123 }
124
125 public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
126 getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
127 }
128
129
130
131
132
133
134
135 @Deprecated
136 public java.lang.String getLabelWithAccessKey() {
137 Deprecation.LOG.error("The attribute 'labelWithAccessKey' of 'UIMenu' is deprecated. "
138 + "Please refer the documentation for further information.");
139 return (java.lang.String) getStateHelper().eval(PropertyKeys.labelWithAccessKey);
140 }
141
142 @Deprecated
143 public void setLabelWithAccessKey(java.lang.String labelWithAccessKey) {
144 getStateHelper().put(PropertyKeys.labelWithAccessKey, labelWithAccessKey);
145 }
146
147 public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
148 Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
149 if (object != null) {
150 return Measure.valueOf(object);
151 }
152 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
153 }
154
155 public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
156 getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
157 }
158
159
160
161
162
163 public org.apache.myfaces.tobago.layout.Measure getHeight() {
164 Object object = getStateHelper().eval(PropertyKeys.height);
165 if (object != null) {
166 return Measure.valueOf(object);
167 }
168 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
169 }
170
171 public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
172 getStateHelper().put(PropertyKeys.height, height);
173 }
174
175 public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
176 Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
177 if (object != null) {
178 return Measure.valueOf(object);
179 }
180 return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
181 }
182
183 public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
184 getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
185 }
186
187 public java.lang.Integer getRowSpan() {
188 Number value = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
189 if (value != null) {
190 return value.intValue();
191 }
192 return 1;
193 }
194
195 public void setRowSpan(java.lang.Integer rowSpan) {
196 getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
197 }
198
199
200
201
202
203 public org.apache.myfaces.tobago.layout.Measure getLeft() {
204 Object object = getStateHelper().eval(PropertyKeys.left);
205 if (object != null) {
206 return Measure.valueOf(object);
207 }
208 return null;
209 }
210
211 public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
212 getStateHelper().put(PropertyKeys.left, left);
213 }
214
215 public java.lang.Integer getColumnSpan() {
216 Number value = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
217 if (value != null) {
218 return value.intValue();
219 }
220 return 1;
221 }
222
223 public void setColumnSpan(java.lang.Integer columnSpan) {
224 getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
225 }
226
227 public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
228 Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
229 if (object != null) {
230 return Measure.valueOf(object);
231 }
232 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
233 }
234
235 public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
236 getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
237 }
238
239
240
241
242
243 public org.apache.myfaces.tobago.layout.Measure getTop() {
244 Object object = getStateHelper().eval(PropertyKeys.top);
245 if (object != null) {
246 return Measure.valueOf(object);
247 }
248 return null;
249 }
250
251 public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
252 getStateHelper().put(PropertyKeys.top, top);
253 }
254
255
256
257
258
259 public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
260 Object object = getStateHelper().eval(PropertyKeys.currentWidth);
261 if (object != null) {
262 return Measure.valueOf(object);
263 }
264 return getWidth();
265 }
266
267 public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
268 getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
269 }
270
271 public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
272 Object object = getStateHelper().eval(PropertyKeys.marginTop);
273 if (object != null) {
274 return Measure.valueOf(object);
275 }
276 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
277 }
278
279 public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
280 getStateHelper().put(PropertyKeys.marginTop, marginTop);
281 }
282
283 public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
284 Object object = getStateHelper().eval(PropertyKeys.marginRight);
285 if (object != null) {
286 return Measure.valueOf(object);
287 }
288 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
289 }
290
291 public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
292 getStateHelper().put(PropertyKeys.marginRight, marginRight);
293 }
294
295
296
297
298
299 public org.apache.myfaces.tobago.layout.Measure getWidth() {
300 Object object = getStateHelper().eval(PropertyKeys.width);
301 if (object != null) {
302 return Measure.valueOf(object);
303 }
304 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
305 }
306
307 public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
308 getStateHelper().put(PropertyKeys.width, width);
309 }
310
311 public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
312 Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
313 if (object != null) {
314 return Measure.valueOf(object);
315 }
316 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
317 }
318
319 public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
320 getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
321 }
322
323
324
325
326
327 public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
328 Object object = getStateHelper().eval(PropertyKeys.currentHeight);
329 if (object != null) {
330 return Measure.valueOf(object);
331 }
332 return getHeight();
333 }
334
335 public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
336 getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
337 }
338
339
340
341
342
343 public java.lang.String getImage() {
344 return (java.lang.String) getStateHelper().eval(PropertyKeys.image);
345 }
346
347 public void setImage(java.lang.String image) {
348 getStateHelper().put(PropertyKeys.image, image);
349 }
350
351
352
353
354
355
356 public java.lang.String getLabel() {
357 return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
358 }
359
360 public void setLabel(java.lang.String label) {
361 getStateHelper().put(PropertyKeys.label, label);
362 }
363
364
365
366
367
368 public org.apache.myfaces.tobago.layout.Display getDisplay() {
369 return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
370 }
371
372 public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
373 getStateHelper().put(PropertyKeys.display, display);
374 }
375
376 public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
377 Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
378 if (object != null) {
379 return Measure.valueOf(object);
380 }
381 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
382 }
383
384 public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
385 getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
386 }
387
388 public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
389 Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
390 if (object != null) {
391 return Measure.valueOf(object);
392 }
393 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
394 }
395
396 public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
397 getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
398 }
399
400 public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
401 Object object = getStateHelper().eval(PropertyKeys.marginBottom);
402 if (object != null) {
403 return Measure.valueOf(object);
404 }
405 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
406 }
407
408 public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
409 getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
410 }
411
412
413
414
415
416 public java.lang.Integer getVerticalIndex() {
417 Number value = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
418 if (value != null) {
419 return value.intValue();
420 }
421 return null;
422 }
423
424 public void setVerticalIndex(java.lang.Integer verticalIndex) {
425 getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
426 }
427
428 public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
429 if (currentMarkup != null) {
430 return currentMarkup;
431 }
432 return null;
433 }
434
435 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
436 this.currentMarkup = currentMarkup;
437 }
438
439
440
441
442
443 public java.lang.Integer getHorizontalIndex() {
444 Number value = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
445 if (value != null) {
446 return value.intValue();
447 }
448 return null;
449 }
450
451 public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
452 getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
453 }
454
455
456
457
458
459 public boolean isDisabled() {
460 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.disabled);
461 if (bool != null) {
462 return bool;
463 }
464 return false;
465 }
466
467 public void setDisabled(boolean disabled) {
468 getStateHelper().put(PropertyKeys.disabled, disabled);
469 }
470
471 public Object saveState(FacesContext context) {
472 currentMarkup = null;
473 return super.saveState(context);
474 }
475
476
477 }