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