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.AbstractUIBox;
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 UIBox
46 extends AbstractUIBox implements SupportsMarkup {
47
48 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Box";
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 marginLeft,
57 minimumHeight,
58 borderLeft,
59 tip,
60 height,
61 minimumWidth,
62 overflowX,
63 rowSpan,
64 overflowY,
65 left,
66 columnSpan,
67 borderRight,
68 paddingBottom,
69 maximumHeight,
70 top,
71 currentWidth,
72 paddingTop,
73 marginTop,
74 marginRight,
75 width,
76 preferredHeight,
77 currentHeight,
78 label,
79 display,
80 borderBottom,
81 maximumWidth,
82 paddingLeft,
83 collapsed,
84 paddingRight,
85 preferredWidth,
86 marginBottom,
87 verticalIndex,
88 borderTop,
89 horizontalIndex,
90 }
91
92 public String getFamily() {
93 return COMPONENT_FAMILY;
94 }
95
96
97 public org.apache.myfaces.tobago.context.Markup getMarkup() {
98 Object object = getStateHelper().eval(PropertyKeys.markup);
99 if (object != null) {
100 return Markup.valueOf(object);
101 }
102 return null;
103 }
104
105 public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
106 getStateHelper().put(PropertyKeys.markup, markup);
107 }
108
109 public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
110 Object object = getStateHelper().eval(PropertyKeys.marginLeft);
111 if (object != null) {
112 return Measure.valueOf(object);
113 }
114 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
115 }
116
117 public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
118 getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
119 }
120
121 public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
122 Object object = getStateHelper().eval(PropertyKeys.minimumHeight);
123 if (object != null) {
124 return Measure.valueOf(object);
125 }
126 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
127 }
128
129 public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
130 getStateHelper().put(PropertyKeys.minimumHeight, minimumHeight);
131 }
132
133
134
135
136
137 public org.apache.myfaces.tobago.layout.Measure getBorderLeft() {
138 Object object = getStateHelper().eval(PropertyKeys.borderLeft);
139 if (object != null) {
140 return Measure.valueOf(object);
141 }
142 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
143 getRenderer(getFacesContext())).getBorderLeft(getFacesContext(), this);
144 }
145
146 public void setBorderLeft(org.apache.myfaces.tobago.layout.Measure borderLeft) {
147 getStateHelper().put(PropertyKeys.borderLeft, borderLeft);
148 }
149
150
151
152
153
154 public java.lang.String getTip() {
155 return (java.lang.String) getStateHelper().eval(PropertyKeys.tip);
156 }
157
158 public void setTip(java.lang.String tip) {
159 getStateHelper().put(PropertyKeys.tip, tip);
160 }
161
162
163
164
165
166 public org.apache.myfaces.tobago.layout.Measure getHeight() {
167 Object object = getStateHelper().eval(PropertyKeys.height);
168 if (object != null) {
169 return Measure.valueOf(object);
170 }
171 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
172 }
173
174 public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
175 getStateHelper().put(PropertyKeys.height, height);
176 }
177
178 public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
179 Object object = getStateHelper().eval(PropertyKeys.minimumWidth);
180 if (object != null) {
181 return Measure.valueOf(object);
182 }
183 return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
184 }
185
186 public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
187 getStateHelper().put(PropertyKeys.minimumWidth, minimumWidth);
188 }
189
190
191
192
193
194 public boolean isOverflowX() {
195 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.overflowX);
196 if (bool != null) {
197 return bool;
198 }
199 return false;
200 }
201
202 public void setOverflowX(boolean overflowX) {
203 getStateHelper().put(PropertyKeys.overflowX, overflowX);
204 }
205
206 public java.lang.Integer getRowSpan() {
207 Number value = (Number) getStateHelper().eval(PropertyKeys.rowSpan);
208 if (value != null) {
209 return value.intValue();
210 }
211 return 1;
212 }
213
214 public void setRowSpan(java.lang.Integer rowSpan) {
215 getStateHelper().put(PropertyKeys.rowSpan, rowSpan);
216 }
217
218
219
220
221
222 public boolean isOverflowY() {
223 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.overflowY);
224 if (bool != null) {
225 return bool;
226 }
227 return false;
228 }
229
230 public void setOverflowY(boolean overflowY) {
231 getStateHelper().put(PropertyKeys.overflowY, overflowY);
232 }
233
234
235
236
237
238 public org.apache.myfaces.tobago.layout.Measure getLeft() {
239 Object object = getStateHelper().eval(PropertyKeys.left);
240 if (object != null) {
241 return Measure.valueOf(object);
242 }
243 return null;
244 }
245
246 public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
247 getStateHelper().put(PropertyKeys.left, left);
248 }
249
250 public java.lang.Integer getColumnSpan() {
251 Number value = (Number) getStateHelper().eval(PropertyKeys.columnSpan);
252 if (value != null) {
253 return value.intValue();
254 }
255 return 1;
256 }
257
258 public void setColumnSpan(java.lang.Integer columnSpan) {
259 getStateHelper().put(PropertyKeys.columnSpan, columnSpan);
260 }
261
262
263
264
265
266 public org.apache.myfaces.tobago.layout.Measure getBorderRight() {
267 Object object = getStateHelper().eval(PropertyKeys.borderRight);
268 if (object != null) {
269 return Measure.valueOf(object);
270 }
271 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
272 getRenderer(getFacesContext())).getBorderRight(getFacesContext(), this);
273 }
274
275 public void setBorderRight(org.apache.myfaces.tobago.layout.Measure borderRight) {
276 getStateHelper().put(PropertyKeys.borderRight, borderRight);
277 }
278
279
280
281
282
283 public org.apache.myfaces.tobago.layout.Measure getPaddingBottom() {
284 Object object = getStateHelper().eval(PropertyKeys.paddingBottom);
285 if (object != null) {
286 return Measure.valueOf(object);
287 }
288 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
289 getRenderer(getFacesContext())).getPaddingBottom(getFacesContext(), this);
290 }
291
292 public void setPaddingBottom(org.apache.myfaces.tobago.layout.Measure paddingBottom) {
293 getStateHelper().put(PropertyKeys.paddingBottom, paddingBottom);
294 }
295
296 public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
297 Object object = getStateHelper().eval(PropertyKeys.maximumHeight);
298 if (object != null) {
299 return Measure.valueOf(object);
300 }
301 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
302 }
303
304 public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
305 getStateHelper().put(PropertyKeys.maximumHeight, maximumHeight);
306 }
307
308
309
310
311
312 public org.apache.myfaces.tobago.layout.Measure getTop() {
313 Object object = getStateHelper().eval(PropertyKeys.top);
314 if (object != null) {
315 return Measure.valueOf(object);
316 }
317 return null;
318 }
319
320 public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
321 getStateHelper().put(PropertyKeys.top, top);
322 }
323
324
325
326
327
328 public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
329 Object object = getStateHelper().eval(PropertyKeys.currentWidth);
330 if (object != null) {
331 return Measure.valueOf(object);
332 }
333 return getWidth();
334 }
335
336 public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
337 getStateHelper().put(PropertyKeys.currentWidth, currentWidth);
338 }
339
340
341
342
343
344 public org.apache.myfaces.tobago.layout.Measure getPaddingTop() {
345 Object object = getStateHelper().eval(PropertyKeys.paddingTop);
346 if (object != null) {
347 return Measure.valueOf(object);
348 }
349 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
350 getRenderer(getFacesContext())).getPaddingTop(getFacesContext(), this);
351 }
352
353 public void setPaddingTop(org.apache.myfaces.tobago.layout.Measure paddingTop) {
354 getStateHelper().put(PropertyKeys.paddingTop, paddingTop);
355 }
356
357 public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
358 Object object = getStateHelper().eval(PropertyKeys.marginTop);
359 if (object != null) {
360 return Measure.valueOf(object);
361 }
362 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
363 }
364
365 public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
366 getStateHelper().put(PropertyKeys.marginTop, marginTop);
367 }
368
369 public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
370 Object object = getStateHelper().eval(PropertyKeys.marginRight);
371 if (object != null) {
372 return Measure.valueOf(object);
373 }
374 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
375 }
376
377 public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
378 getStateHelper().put(PropertyKeys.marginRight, marginRight);
379 }
380
381
382
383
384
385 public org.apache.myfaces.tobago.layout.Measure getWidth() {
386 Object object = getStateHelper().eval(PropertyKeys.width);
387 if (object != null) {
388 return Measure.valueOf(object);
389 }
390 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
391 }
392
393 public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
394 getStateHelper().put(PropertyKeys.width, width);
395 }
396
397 public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
398 Object object = getStateHelper().eval(PropertyKeys.preferredHeight);
399 if (object != null) {
400 return Measure.valueOf(object);
401 }
402 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
403 }
404
405 public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
406 getStateHelper().put(PropertyKeys.preferredHeight, preferredHeight);
407 }
408
409
410
411
412
413 public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
414 Object object = getStateHelper().eval(PropertyKeys.currentHeight);
415 if (object != null) {
416 return Measure.valueOf(object);
417 }
418 return getHeight();
419 }
420
421 public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
422 getStateHelper().put(PropertyKeys.currentHeight, currentHeight);
423 }
424
425
426
427
428
429
430 public java.lang.String getLabel() {
431 return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
432 }
433
434 public void setLabel(java.lang.String label) {
435 getStateHelper().put(PropertyKeys.label, label);
436 }
437
438
439
440
441
442 public org.apache.myfaces.tobago.layout.Display getDisplay() {
443 return (org.apache.myfaces.tobago.layout.Display) getStateHelper().eval(PropertyKeys.display);
444 }
445
446 public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
447 getStateHelper().put(PropertyKeys.display, display);
448 }
449
450
451
452
453
454 public org.apache.myfaces.tobago.layout.Measure getBorderBottom() {
455 Object object = getStateHelper().eval(PropertyKeys.borderBottom);
456 if (object != null) {
457 return Measure.valueOf(object);
458 }
459 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
460 getRenderer(getFacesContext())).getBorderBottom(getFacesContext(), this);
461 }
462
463 public void setBorderBottom(org.apache.myfaces.tobago.layout.Measure borderBottom) {
464 getStateHelper().put(PropertyKeys.borderBottom, borderBottom);
465 }
466
467 public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
468 Object object = getStateHelper().eval(PropertyKeys.maximumWidth);
469 if (object != null) {
470 return Measure.valueOf(object);
471 }
472 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
473 }
474
475 public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
476 getStateHelper().put(PropertyKeys.maximumWidth, maximumWidth);
477 }
478
479
480
481
482
483 public org.apache.myfaces.tobago.layout.Measure getPaddingLeft() {
484 Object object = getStateHelper().eval(PropertyKeys.paddingLeft);
485 if (object != null) {
486 return Measure.valueOf(object);
487 }
488 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
489 getRenderer(getFacesContext())).getPaddingLeft(getFacesContext(), this);
490 }
491
492 public void setPaddingLeft(org.apache.myfaces.tobago.layout.Measure paddingLeft) {
493 getStateHelper().put(PropertyKeys.paddingLeft, paddingLeft);
494 }
495
496
497
498
499
500 public boolean isCollapsed() {
501 Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.collapsed);
502 if (bool != null) {
503 return bool;
504 }
505 return false;
506 }
507
508 public void setCollapsed(boolean collapsed) {
509 getStateHelper().put(PropertyKeys.collapsed, collapsed);
510 }
511
512
513
514
515
516 public org.apache.myfaces.tobago.layout.Measure getPaddingRight() {
517 Object object = getStateHelper().eval(PropertyKeys.paddingRight);
518 if (object != null) {
519 return Measure.valueOf(object);
520 }
521 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
522 getRenderer(getFacesContext())).getPaddingRight(getFacesContext(), this);
523 }
524
525 public void setPaddingRight(org.apache.myfaces.tobago.layout.Measure paddingRight) {
526 getStateHelper().put(PropertyKeys.paddingRight, paddingRight);
527 }
528
529 public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
530 Object object = getStateHelper().eval(PropertyKeys.preferredWidth);
531 if (object != null) {
532 return Measure.valueOf(object);
533 }
534 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
535 }
536
537 public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
538 getStateHelper().put(PropertyKeys.preferredWidth, preferredWidth);
539 }
540
541 public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
542 Object object = getStateHelper().eval(PropertyKeys.marginBottom);
543 if (object != null) {
544 return Measure.valueOf(object);
545 }
546 return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
547 }
548
549 public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
550 getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
551 }
552
553
554
555
556
557 public java.lang.Integer getVerticalIndex() {
558 Number value = (Number) getStateHelper().eval(PropertyKeys.verticalIndex);
559 if (value != null) {
560 return value.intValue();
561 }
562 return null;
563 }
564
565 public void setVerticalIndex(java.lang.Integer verticalIndex) {
566 getStateHelper().put(PropertyKeys.verticalIndex, verticalIndex);
567 }
568
569
570
571
572
573 public org.apache.myfaces.tobago.layout.Measure getBorderTop() {
574 Object object = getStateHelper().eval(PropertyKeys.borderTop);
575 if (object != null) {
576 return Measure.valueOf(object);
577 }
578 return ((org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer)
579 getRenderer(getFacesContext())).getBorderTop(getFacesContext(), this);
580 }
581
582 public void setBorderTop(org.apache.myfaces.tobago.layout.Measure borderTop) {
583 getStateHelper().put(PropertyKeys.borderTop, borderTop);
584 }
585
586 public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
587 if (currentMarkup != null) {
588 return currentMarkup;
589 }
590 return null;
591 }
592
593 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
594 this.currentMarkup = currentMarkup;
595 }
596
597
598
599
600
601 public java.lang.Integer getHorizontalIndex() {
602 Number value = (Number) getStateHelper().eval(PropertyKeys.horizontalIndex);
603 if (value != null) {
604 return value.intValue();
605 }
606 return null;
607 }
608
609 public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
610 getStateHelper().put(PropertyKeys.horizontalIndex, horizontalIndex);
611 }
612
613 public Object saveState(FacesContext context) {
614 currentMarkup = null;
615 return super.saveState(context);
616 }
617
618
619 }