001    // ---------- Attention: Generated code, please do not modify! -----------  
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    package org.apache.myfaces.tobago.component;
021    
022    import javax.faces.context.FacesContext;
023    import org.apache.myfaces.tobago.context.Markup;
024    import org.apache.myfaces.tobago.internal.component.AbstractUITree;
025    import org.apache.myfaces.tobago.layout.Display;
026    import org.apache.myfaces.tobago.layout.Measure;
027    import org.apache.commons.lang.ArrayUtils;
028    import org.apache.commons.lang.StringUtils;
029    import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
030    import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
031    import org.apache.myfaces.tobago.internal.util.Deprecation;
032    import org.apache.myfaces.tobago.renderkit.MarginValues;
033    import org.apache.myfaces.tobago.renderkit.SpacingValues;
034    import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
035    import javax.el.ELException;
036    import javax.faces.FacesException;
037    import java.util.ArrayList;
038    import java.util.List;
039    import javax.el.MethodExpression;
040    import javax.el.ValueExpression;
041    
042    /** 
043     A tree which will be displayed like a flat menu.
044      This menu is often used for navigation on the left side of an application.
045      * UIComponent class, generated from template {@code component1.2.stg} with class
046      * {@link org.apache.myfaces.tobago.internal.taglib.component.TreeMenuTagDeclaration}.
047     */
048    public class UITreeMenu
049        extends AbstractUITree implements SupportsMarkup {
050    
051      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeMenu";
052    
053      private org.apache.myfaces.tobago.context.Markup markup;
054      private org.apache.myfaces.tobago.layout.Measure marginLeft;
055      private java.lang.Object state;
056      private org.apache.myfaces.tobago.layout.Measure minimumHeight;
057      private org.apache.myfaces.tobago.layout.Measure height;
058      private java.lang.Boolean showRoot;
059      private org.apache.myfaces.tobago.layout.Measure minimumWidth;
060      private java.lang.Integer rowSpan;
061      private org.apache.myfaces.tobago.layout.Measure left;
062      private java.lang.Integer columnSpan;
063      private org.apache.myfaces.tobago.layout.Measure maximumHeight;
064      private org.apache.myfaces.tobago.layout.Measure top;
065      private org.apache.myfaces.tobago.layout.Measure currentWidth;
066      private org.apache.myfaces.tobago.layout.Measure marginTop;
067      private org.apache.myfaces.tobago.layout.Measure marginRight;
068      private org.apache.myfaces.tobago.layout.Measure width;
069      private org.apache.myfaces.tobago.layout.Measure currentHeight;
070      private org.apache.myfaces.tobago.layout.Measure preferredHeight;
071      private org.apache.myfaces.tobago.layout.Display display;
072      private org.apache.myfaces.tobago.layout.Measure maximumWidth;
073      private org.apache.myfaces.tobago.layout.Measure preferredWidth;
074      private org.apache.myfaces.tobago.layout.Measure marginBottom;
075      private java.lang.Integer verticalIndex;
076      private org.apache.myfaces.tobago.context.Markup currentMarkup;
077      private java.lang.Integer horizontalIndex;
078    
079    
080      public org.apache.myfaces.tobago.context.Markup getMarkup() {
081        if (markup != null) {
082          return markup;
083        }
084        ValueExpression ve = getValueExpression("markup");
085        if (ve != null) {
086          try {
087            Object object = ve.getValue(getFacesContext().getELContext());
088            return Markup.valueOf(object);
089          } catch (ELException e) {
090                      throw new FacesException(e);
091              }
092        }
093        return null;
094      }
095    
096      public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
097        this.markup = markup;
098      }
099    
100      public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
101        if (marginLeft != null) {
102          return marginLeft;
103        }
104        ValueExpression ve = getValueExpression("marginLeft");
105        if (ve != null) {
106          try {
107            Object object = ve.getValue(getFacesContext().getELContext());
108            return Measure.valueOf(object);
109          } catch (ELException e) {
110                      throw new FacesException(e);
111              }
112        }
113        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
114      }
115    
116      public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
117        this.marginLeft = marginLeft;
118      }
119    
120      /**
121      <strong>ValueBindingExpression</strong> pointing to a object to save the
122       component's state.
123    
124      */
125      public java.lang.Object getState() {
126        if (state != null) {
127          return state;
128        }
129        ValueExpression ve = getValueExpression("state");
130        if (ve != null) {
131          try {
132            return (java.lang.Object) ve.getValue(getFacesContext().getELContext());
133          } catch (ELException e) {
134                      throw new FacesException(e);
135              }
136        }
137        return null;
138      }
139    
140      public void setState(java.lang.Object state) {
141        this.state = state;
142      }
143    
144      public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
145        if (minimumHeight != null) {
146          return minimumHeight;
147        }
148        ValueExpression ve = getValueExpression("minimumHeight");
149        if (ve != null) {
150          try {
151            Object object = ve.getValue(getFacesContext().getELContext());
152            return Measure.valueOf(object);
153          } catch (ELException e) {
154                      throw new FacesException(e);
155              }
156        }
157        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
158      }
159    
160      public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
161        this.minimumHeight = minimumHeight;
162      }
163    
164      /**
165      This value will usually be set by the layout manager.
166    
167      */
168      public org.apache.myfaces.tobago.layout.Measure getHeight() {
169        if (height != null) {
170          return height;
171        }
172        ValueExpression ve = getValueExpression("height");
173        if (ve != null) {
174          try {
175            Object object = ve.getValue(getFacesContext().getELContext());
176            return Measure.valueOf(object);
177          } catch (ELException e) {
178                      throw new FacesException(e);
179              }
180        }
181        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
182      }
183    
184      public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
185        this.height = height;
186      }
187    
188      /**
189      Indicates that the root node should be displayed or not.
190       Normally the root node of a menu will not be shown, because it has only technical significance.
191      <br />Default: <code>false</code>
192      */
193      public boolean isShowRoot() {
194        if (showRoot != null) {
195          return showRoot;
196        }
197        ValueExpression ve = getValueExpression("showRoot");
198        if (ve != null) {
199          try {
200            Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext());
201            if (bool != null) {
202              return bool;
203            }
204          } catch (ELException e) {
205                      throw new FacesException(e);
206              }
207        }
208        return false;
209      }
210    
211      public void setShowRoot(boolean showRoot) {
212        this.showRoot = showRoot;
213      }
214    
215      public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
216        if (minimumWidth != null) {
217          return minimumWidth;
218        }
219        ValueExpression ve = getValueExpression("minimumWidth");
220        if (ve != null) {
221          try {
222            Object object = ve.getValue(getFacesContext().getELContext());
223            return Measure.valueOf(object);
224          } catch (ELException e) {
225                      throw new FacesException(e);
226              }
227        }
228        return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
229      }
230    
231      public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
232        this.minimumWidth = minimumWidth;
233      }
234    
235      public java.lang.Integer getRowSpan() {
236        if (rowSpan != null) {
237          return rowSpan;
238        }
239        ValueExpression ve = getValueExpression("rowSpan");
240        if (ve != null) {
241          try {
242            Number number = (Number) ve.getValue(getFacesContext().getELContext());
243            if (number != null) {
244              return number.intValue();
245            }
246          } catch (ELException e) {
247                      throw new FacesException(e);
248              }
249        }
250        return 1;
251      }
252    
253      public void setRowSpan(java.lang.Integer rowSpan) {
254        this.rowSpan = rowSpan;
255      }
256    
257      /**
258      This value will usually be set by the layout manager.
259    
260      */
261      public org.apache.myfaces.tobago.layout.Measure getLeft() {
262        if (left != null) {
263          return left;
264        }
265        ValueExpression ve = getValueExpression("left");
266        if (ve != null) {
267          try {
268            Object object = ve.getValue(getFacesContext().getELContext());
269            return Measure.valueOf(object);
270          } catch (ELException e) {
271                      throw new FacesException(e);
272              }
273        }
274        return null;
275      }
276    
277      public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
278        this.left = left;
279      }
280    
281      public java.lang.Integer getColumnSpan() {
282        if (columnSpan != null) {
283          return columnSpan;
284        }
285        ValueExpression ve = getValueExpression("columnSpan");
286        if (ve != null) {
287          try {
288            Number number = (Number) ve.getValue(getFacesContext().getELContext());
289            if (number != null) {
290              return number.intValue();
291            }
292          } catch (ELException e) {
293                      throw new FacesException(e);
294              }
295        }
296        return 1;
297      }
298    
299      public void setColumnSpan(java.lang.Integer columnSpan) {
300        this.columnSpan = columnSpan;
301      }
302    
303      public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
304        if (maximumHeight != null) {
305          return maximumHeight;
306        }
307        ValueExpression ve = getValueExpression("maximumHeight");
308        if (ve != null) {
309          try {
310            Object object = ve.getValue(getFacesContext().getELContext());
311            return Measure.valueOf(object);
312          } catch (ELException e) {
313                      throw new FacesException(e);
314              }
315        }
316        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
317      }
318    
319      public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
320        this.maximumHeight = maximumHeight;
321      }
322    
323      /**
324      This value will usually be set by the layout manager.
325    
326      */
327      public org.apache.myfaces.tobago.layout.Measure getTop() {
328        if (top != null) {
329          return top;
330        }
331        ValueExpression ve = getValueExpression("top");
332        if (ve != null) {
333          try {
334            Object object = ve.getValue(getFacesContext().getELContext());
335            return Measure.valueOf(object);
336          } catch (ELException e) {
337                      throw new FacesException(e);
338              }
339        }
340        return null;
341      }
342    
343      public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
344        this.top = top;
345      }
346    
347      /**
348      This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
349    
350      */
351      public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
352        if (currentWidth != null) {
353          return currentWidth;
354        }
355        ValueExpression ve = getValueExpression("currentWidth");
356        if (ve != null) {
357          try {
358            Object object = ve.getValue(getFacesContext().getELContext());
359            return Measure.valueOf(object);
360          } catch (ELException e) {
361                      throw new FacesException(e);
362              }
363        }
364        return getWidth();
365      }
366    
367      public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
368        this.currentWidth = currentWidth;
369      }
370    
371      public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
372        if (marginTop != null) {
373          return marginTop;
374        }
375        ValueExpression ve = getValueExpression("marginTop");
376        if (ve != null) {
377          try {
378            Object object = ve.getValue(getFacesContext().getELContext());
379            return Measure.valueOf(object);
380          } catch (ELException e) {
381                      throw new FacesException(e);
382              }
383        }
384        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
385      }
386    
387      public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
388        this.marginTop = marginTop;
389      }
390    
391      public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
392        if (marginRight != null) {
393          return marginRight;
394        }
395        ValueExpression ve = getValueExpression("marginRight");
396        if (ve != null) {
397          try {
398            Object object = ve.getValue(getFacesContext().getELContext());
399            return Measure.valueOf(object);
400          } catch (ELException e) {
401                      throw new FacesException(e);
402              }
403        }
404        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
405      }
406    
407      public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
408        this.marginRight = marginRight;
409      }
410    
411      /**
412      This value will usually be set by the layout manager.
413    
414      */
415      public org.apache.myfaces.tobago.layout.Measure getWidth() {
416        if (width != null) {
417          return width;
418        }
419        ValueExpression ve = getValueExpression("width");
420        if (ve != null) {
421          try {
422            Object object = ve.getValue(getFacesContext().getELContext());
423            return Measure.valueOf(object);
424          } catch (ELException e) {
425                      throw new FacesException(e);
426              }
427        }
428        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
429      }
430    
431      public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
432        this.width = width;
433      }
434    
435      /**
436      This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
437    
438      */
439      public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
440        if (currentHeight != null) {
441          return currentHeight;
442        }
443        ValueExpression ve = getValueExpression("currentHeight");
444        if (ve != null) {
445          try {
446            Object object = ve.getValue(getFacesContext().getELContext());
447            return Measure.valueOf(object);
448          } catch (ELException e) {
449                      throw new FacesException(e);
450              }
451        }
452        return getHeight();
453      }
454    
455      public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
456        this.currentHeight = currentHeight;
457      }
458    
459      public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
460        if (preferredHeight != null) {
461          return preferredHeight;
462        }
463        ValueExpression ve = getValueExpression("preferredHeight");
464        if (ve != null) {
465          try {
466            Object object = ve.getValue(getFacesContext().getELContext());
467            return Measure.valueOf(object);
468          } catch (ELException e) {
469                      throw new FacesException(e);
470              }
471        }
472        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
473      }
474    
475      public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
476        this.preferredHeight = preferredHeight;
477      }
478    
479      /**
480      This attribute is for internal use only.
481    
482      */
483      public org.apache.myfaces.tobago.layout.Display getDisplay() {
484        if (display != null) {
485          return display;
486        }
487        ValueExpression ve = getValueExpression("display");
488        if (ve != null) {
489          try {
490            return (org.apache.myfaces.tobago.layout.Display) ve.getValue(getFacesContext().getELContext());
491          } catch (ELException e) {
492                      throw new FacesException(e);
493              }
494        }
495        return null;
496      }
497    
498      public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
499        this.display = display;
500      }
501    
502      public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
503        if (maximumWidth != null) {
504          return maximumWidth;
505        }
506        ValueExpression ve = getValueExpression("maximumWidth");
507        if (ve != null) {
508          try {
509            Object object = ve.getValue(getFacesContext().getELContext());
510            return Measure.valueOf(object);
511          } catch (ELException e) {
512                      throw new FacesException(e);
513              }
514        }
515        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
516      }
517    
518      public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
519        this.maximumWidth = maximumWidth;
520      }
521    
522      public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
523        if (preferredWidth != null) {
524          return preferredWidth;
525        }
526        ValueExpression ve = getValueExpression("preferredWidth");
527        if (ve != null) {
528          try {
529            Object object = ve.getValue(getFacesContext().getELContext());
530            return Measure.valueOf(object);
531          } catch (ELException e) {
532                      throw new FacesException(e);
533              }
534        }
535        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
536      }
537    
538      public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
539        this.preferredWidth = preferredWidth;
540      }
541    
542      public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
543        if (marginBottom != null) {
544          return marginBottom;
545        }
546        ValueExpression ve = getValueExpression("marginBottom");
547        if (ve != null) {
548          try {
549            Object object = ve.getValue(getFacesContext().getELContext());
550            return Measure.valueOf(object);
551          } catch (ELException e) {
552                      throw new FacesException(e);
553              }
554        }
555        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
556      }
557    
558      public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
559        this.marginBottom = marginBottom;
560      }
561    
562      /**
563      This attribute is for internal use only.
564    
565      */
566      public java.lang.Integer getVerticalIndex() {
567        if (verticalIndex != null) {
568          return verticalIndex;
569        }
570        ValueExpression ve = getValueExpression("verticalIndex");
571        if (ve != null) {
572          try {
573            Number number = (Number) ve.getValue(getFacesContext().getELContext());
574            if (number != null) {
575              return number.intValue();
576            }
577          } catch (ELException e) {
578                      throw new FacesException(e);
579              }
580        }
581        return null;
582      }
583    
584      public void setVerticalIndex(java.lang.Integer verticalIndex) {
585        this.verticalIndex = verticalIndex;
586      }
587    
588      public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
589        if (currentMarkup != null) {
590          return currentMarkup;
591        }
592        return null;
593      }
594    
595      public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
596        this.currentMarkup = currentMarkup;
597      }
598    
599      /**
600      This attribute is for internal use only.
601    
602      */
603      public java.lang.Integer getHorizontalIndex() {
604        if (horizontalIndex != null) {
605          return horizontalIndex;
606        }
607        ValueExpression ve = getValueExpression("horizontalIndex");
608        if (ve != null) {
609          try {
610            Number number = (Number) ve.getValue(getFacesContext().getELContext());
611            if (number != null) {
612              return number.intValue();
613            }
614          } catch (ELException e) {
615                      throw new FacesException(e);
616              }
617        }
618        return null;
619      }
620    
621      public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
622        this.horizontalIndex = horizontalIndex;
623      }
624    
625      public void restoreState(FacesContext context, Object componentState) {
626        Object[] values = (Object[]) componentState;
627        super.restoreState(context, values[0]);
628        markup = (org.apache.myfaces.tobago.context.Markup) values[1];
629        marginLeft = (org.apache.myfaces.tobago.layout.Measure) values[2];
630        state = (java.lang.Object) values[3];
631        minimumHeight = (org.apache.myfaces.tobago.layout.Measure) values[4];
632        height = (org.apache.myfaces.tobago.layout.Measure) values[5];
633        showRoot = (java.lang.Boolean) values[6];
634        minimumWidth = (org.apache.myfaces.tobago.layout.Measure) values[7];
635        rowSpan = (java.lang.Integer) values[8];
636        left = (org.apache.myfaces.tobago.layout.Measure) values[9];
637        columnSpan = (java.lang.Integer) values[10];
638        maximumHeight = (org.apache.myfaces.tobago.layout.Measure) values[11];
639        top = (org.apache.myfaces.tobago.layout.Measure) values[12];
640        currentWidth = (org.apache.myfaces.tobago.layout.Measure) values[13];
641        marginTop = (org.apache.myfaces.tobago.layout.Measure) values[14];
642        marginRight = (org.apache.myfaces.tobago.layout.Measure) values[15];
643        width = (org.apache.myfaces.tobago.layout.Measure) values[16];
644        currentHeight = (org.apache.myfaces.tobago.layout.Measure) values[17];
645        preferredHeight = (org.apache.myfaces.tobago.layout.Measure) values[18];
646        display = (org.apache.myfaces.tobago.layout.Display) values[19];
647        maximumWidth = (org.apache.myfaces.tobago.layout.Measure) values[20];
648        preferredWidth = (org.apache.myfaces.tobago.layout.Measure) values[21];
649        marginBottom = (org.apache.myfaces.tobago.layout.Measure) values[22];
650        verticalIndex = (java.lang.Integer) values[23];
651        horizontalIndex = (java.lang.Integer) values[24];
652      }
653    
654      public Object saveState(FacesContext context) {
655        Object[] values = new Object[25];
656        values[0] = super.saveState(context);
657        values[1] = markup;
658        values[2] = marginLeft;
659        values[3] = state;
660        values[4] = minimumHeight;
661        values[5] = height;
662        values[6] = showRoot;
663        values[7] = minimumWidth;
664        values[8] = rowSpan;
665        values[9] = left;
666        values[10] = columnSpan;
667        values[11] = maximumHeight;
668        values[12] = top;
669        values[13] = currentWidth;
670        values[14] = marginTop;
671        values[15] = marginRight;
672        values[16] = width;
673        values[17] = currentHeight;
674        values[18] = preferredHeight;
675        values[19] = display;
676        values[20] = maximumWidth;
677        values[21] = preferredWidth;
678        values[22] = marginBottom;
679        values[23] = verticalIndex;
680        values[24] = horizontalIndex;
681        currentMarkup = null;
682        return values;
683      }
684    
685    
686    }