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.AbstractUIMediator;
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     Component to put other components from other frameworks into.
044      Gives the possibility, to interchange layout information.
045      * UIComponent class, generated from template {@code component1.2.stg} with class
046      * {@link org.apache.myfaces.tobago.internal.taglib.component.MediatorTagDeclaration}.
047     */
048    public class UIMediator
049        extends AbstractUIMediator implements SupportsMarkup {
050    
051      public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Mediator";
052    
053      private org.apache.myfaces.tobago.layout.Measure currentWidth;
054      private org.apache.myfaces.tobago.context.Markup markup;
055      private org.apache.myfaces.tobago.layout.Measure marginLeft;
056      private org.apache.myfaces.tobago.layout.Measure marginTop;
057      private org.apache.myfaces.tobago.layout.Measure width;
058      private org.apache.myfaces.tobago.layout.Measure marginRight;
059      private org.apache.myfaces.tobago.layout.Measure preferredHeight;
060      private org.apache.myfaces.tobago.layout.Measure currentHeight;
061      private org.apache.myfaces.tobago.layout.Display display;
062      private org.apache.myfaces.tobago.layout.Measure minimumHeight;
063      private org.apache.myfaces.tobago.layout.Measure maximumWidth;
064      private org.apache.myfaces.tobago.layout.Measure preferredWidth;
065      private org.apache.myfaces.tobago.layout.Measure marginBottom;
066      private org.apache.myfaces.tobago.layout.Measure height;
067      private java.lang.Integer verticalIndex;
068      private org.apache.myfaces.tobago.layout.Measure minimumWidth;
069      private org.apache.myfaces.tobago.context.Markup currentMarkup;
070      private java.lang.Integer rowSpan;
071      private java.lang.Integer horizontalIndex;
072      private org.apache.myfaces.tobago.layout.Measure left;
073      private java.lang.Integer columnSpan;
074      private org.apache.myfaces.tobago.layout.Measure top;
075      private org.apache.myfaces.tobago.layout.Measure maximumHeight;
076    
077    
078      /**
079      This value will usually be set by the layout manager. It holds the current width computed by the layout manager.
080    
081      */
082      public org.apache.myfaces.tobago.layout.Measure getCurrentWidth() {
083        if (currentWidth != null) {
084          return currentWidth;
085        }
086        ValueExpression ve = getValueExpression("currentWidth");
087        if (ve != null) {
088          try {
089            Object object = ve.getValue(getFacesContext().getELContext());
090            return Measure.valueOf(object);
091          } catch (ELException e) {
092                      throw new FacesException(e);
093              }
094        }
095        return getWidth();
096      }
097    
098      public void setCurrentWidth(org.apache.myfaces.tobago.layout.Measure currentWidth) {
099        this.currentWidth = currentWidth;
100      }
101    
102      public org.apache.myfaces.tobago.context.Markup getMarkup() {
103        if (markup != null) {
104          return markup;
105        }
106        ValueExpression ve = getValueExpression("markup");
107        if (ve != null) {
108          try {
109            Object object = ve.getValue(getFacesContext().getELContext());
110            return Markup.valueOf(object);
111          } catch (ELException e) {
112                      throw new FacesException(e);
113              }
114        }
115        return null;
116      }
117    
118      public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
119        this.markup = markup;
120      }
121    
122      public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
123        if (marginLeft != null) {
124          return marginLeft;
125        }
126        ValueExpression ve = getValueExpression("marginLeft");
127        if (ve != null) {
128          try {
129            Object object = ve.getValue(getFacesContext().getELContext());
130            return Measure.valueOf(object);
131          } catch (ELException e) {
132                      throw new FacesException(e);
133              }
134        }
135        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
136      }
137    
138      public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
139        this.marginLeft = marginLeft;
140      }
141    
142      public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
143        if (marginTop != null) {
144          return marginTop;
145        }
146        ValueExpression ve = getValueExpression("marginTop");
147        if (ve != null) {
148          try {
149            Object object = ve.getValue(getFacesContext().getELContext());
150            return Measure.valueOf(object);
151          } catch (ELException e) {
152                      throw new FacesException(e);
153              }
154        }
155        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
156      }
157    
158      public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
159        this.marginTop = marginTop;
160      }
161    
162      /**
163      This value will usually be set by the layout manager.
164    
165      */
166      public org.apache.myfaces.tobago.layout.Measure getWidth() {
167        if (width != null) {
168          return width;
169        }
170        ValueExpression ve = getValueExpression("width");
171        if (ve != null) {
172          try {
173            Object object = ve.getValue(getFacesContext().getELContext());
174            return Measure.valueOf(object);
175          } catch (ELException e) {
176                      throw new FacesException(e);
177              }
178        }
179        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getWidth(getFacesContext(), this);
180      }
181    
182      public void setWidth(org.apache.myfaces.tobago.layout.Measure width) {
183        this.width = width;
184      }
185    
186      public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
187        if (marginRight != null) {
188          return marginRight;
189        }
190        ValueExpression ve = getValueExpression("marginRight");
191        if (ve != null) {
192          try {
193            Object object = ve.getValue(getFacesContext().getELContext());
194            return Measure.valueOf(object);
195          } catch (ELException e) {
196                      throw new FacesException(e);
197              }
198        }
199        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
200      }
201    
202      public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
203        this.marginRight = marginRight;
204      }
205    
206      public org.apache.myfaces.tobago.layout.Measure getPreferredHeight() {
207        if (preferredHeight != null) {
208          return preferredHeight;
209        }
210        ValueExpression ve = getValueExpression("preferredHeight");
211        if (ve != null) {
212          try {
213            Object object = ve.getValue(getFacesContext().getELContext());
214            return Measure.valueOf(object);
215          } catch (ELException e) {
216                      throw new FacesException(e);
217              }
218        }
219        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredHeight(getFacesContext(), this);
220      }
221    
222      public void setPreferredHeight(org.apache.myfaces.tobago.layout.Measure preferredHeight) {
223        this.preferredHeight = preferredHeight;
224      }
225    
226      /**
227      This value will usually be set by the layout manager. It holds the current height computed by the layout manager.
228    
229      */
230      public org.apache.myfaces.tobago.layout.Measure getCurrentHeight() {
231        if (currentHeight != null) {
232          return currentHeight;
233        }
234        ValueExpression ve = getValueExpression("currentHeight");
235        if (ve != null) {
236          try {
237            Object object = ve.getValue(getFacesContext().getELContext());
238            return Measure.valueOf(object);
239          } catch (ELException e) {
240                      throw new FacesException(e);
241              }
242        }
243        return getHeight();
244      }
245    
246      public void setCurrentHeight(org.apache.myfaces.tobago.layout.Measure currentHeight) {
247        this.currentHeight = currentHeight;
248      }
249    
250      /**
251      This attribute is for internal use only.
252    
253      */
254      public org.apache.myfaces.tobago.layout.Display getDisplay() {
255        if (display != null) {
256          return display;
257        }
258        ValueExpression ve = getValueExpression("display");
259        if (ve != null) {
260          try {
261            return (org.apache.myfaces.tobago.layout.Display) ve.getValue(getFacesContext().getELContext());
262          } catch (ELException e) {
263                      throw new FacesException(e);
264              }
265        }
266        return null;
267      }
268    
269      public void setDisplay(org.apache.myfaces.tobago.layout.Display display) {
270        this.display = display;
271      }
272    
273      public org.apache.myfaces.tobago.layout.Measure getMinimumHeight() {
274        if (minimumHeight != null) {
275          return minimumHeight;
276        }
277        ValueExpression ve = getValueExpression("minimumHeight");
278        if (ve != null) {
279          try {
280            Object object = ve.getValue(getFacesContext().getELContext());
281            return Measure.valueOf(object);
282          } catch (ELException e) {
283                      throw new FacesException(e);
284              }
285        }
286        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMinimumHeight(getFacesContext(), this);
287      }
288    
289      public void setMinimumHeight(org.apache.myfaces.tobago.layout.Measure minimumHeight) {
290        this.minimumHeight = minimumHeight;
291      }
292    
293      public org.apache.myfaces.tobago.layout.Measure getMaximumWidth() {
294        if (maximumWidth != null) {
295          return maximumWidth;
296        }
297        ValueExpression ve = getValueExpression("maximumWidth");
298        if (ve != null) {
299          try {
300            Object object = ve.getValue(getFacesContext().getELContext());
301            return Measure.valueOf(object);
302          } catch (ELException e) {
303                      throw new FacesException(e);
304              }
305        }
306        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumWidth(getFacesContext(), this);
307      }
308    
309      public void setMaximumWidth(org.apache.myfaces.tobago.layout.Measure maximumWidth) {
310        this.maximumWidth = maximumWidth;
311      }
312    
313      public org.apache.myfaces.tobago.layout.Measure getPreferredWidth() {
314        if (preferredWidth != null) {
315          return preferredWidth;
316        }
317        ValueExpression ve = getValueExpression("preferredWidth");
318        if (ve != null) {
319          try {
320            Object object = ve.getValue(getFacesContext().getELContext());
321            return Measure.valueOf(object);
322          } catch (ELException e) {
323                      throw new FacesException(e);
324              }
325        }
326        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getPreferredWidth(getFacesContext(), this);
327      }
328    
329      public void setPreferredWidth(org.apache.myfaces.tobago.layout.Measure preferredWidth) {
330        this.preferredWidth = preferredWidth;
331      }
332    
333      public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
334        if (marginBottom != null) {
335          return marginBottom;
336        }
337        ValueExpression ve = getValueExpression("marginBottom");
338        if (ve != null) {
339          try {
340            Object object = ve.getValue(getFacesContext().getELContext());
341            return Measure.valueOf(object);
342          } catch (ELException e) {
343                      throw new FacesException(e);
344              }
345        }
346        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
347      }
348    
349      public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
350        this.marginBottom = marginBottom;
351      }
352    
353      /**
354      This value will usually be set by the layout manager.
355    
356      */
357      public org.apache.myfaces.tobago.layout.Measure getHeight() {
358        if (height != null) {
359          return height;
360        }
361        ValueExpression ve = getValueExpression("height");
362        if (ve != null) {
363          try {
364            Object object = ve.getValue(getFacesContext().getELContext());
365            return Measure.valueOf(object);
366          } catch (ELException e) {
367                      throw new FacesException(e);
368              }
369        }
370        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getHeight(getFacesContext(), this);
371      }
372    
373      public void setHeight(org.apache.myfaces.tobago.layout.Measure height) {
374        this.height = height;
375      }
376    
377      /**
378      This attribute is for internal use only.
379    
380      */
381      public java.lang.Integer getVerticalIndex() {
382        if (verticalIndex != null) {
383          return verticalIndex;
384        }
385        ValueExpression ve = getValueExpression("verticalIndex");
386        if (ve != null) {
387          try {
388            Number number = (Number) ve.getValue(getFacesContext().getELContext());
389            if (number != null) {
390              return number.intValue();
391            }
392          } catch (ELException e) {
393                      throw new FacesException(e);
394              }
395        }
396        return null;
397      }
398    
399      public void setVerticalIndex(java.lang.Integer verticalIndex) {
400        this.verticalIndex = verticalIndex;
401      }
402    
403      public org.apache.myfaces.tobago.layout.Measure getMinimumWidth() {
404        if (minimumWidth != null) {
405          return minimumWidth;
406        }
407        ValueExpression ve = getValueExpression("minimumWidth");
408        if (ve != null) {
409          try {
410            Object object = ve.getValue(getFacesContext().getELContext());
411            return Measure.valueOf(object);
412          } catch (ELException e) {
413                      throw new FacesException(e);
414              }
415        }
416        return ((LayoutComponentRenderer)getRenderer(getFacesContext())).getMinimumWidth(getFacesContext(), this);
417      }
418    
419      public void setMinimumWidth(org.apache.myfaces.tobago.layout.Measure minimumWidth) {
420        this.minimumWidth = minimumWidth;
421      }
422    
423      public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
424        if (currentMarkup != null) {
425          return currentMarkup;
426        }
427        ValueExpression ve = getValueExpression("currentMarkup");
428        if (ve != null) {
429          try {
430            Object object = ve.getValue(getFacesContext().getELContext());
431            return Markup.valueOf(object);
432          } catch (ELException e) {
433                      throw new FacesException(e);
434              }
435        }
436        return null;
437      }
438    
439      public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
440        this.currentMarkup = currentMarkup;
441      }
442    
443      public java.lang.Integer getRowSpan() {
444        if (rowSpan != null) {
445          return rowSpan;
446        }
447        ValueExpression ve = getValueExpression("rowSpan");
448        if (ve != null) {
449          try {
450            Number number = (Number) ve.getValue(getFacesContext().getELContext());
451            if (number != null) {
452              return number.intValue();
453            }
454          } catch (ELException e) {
455                      throw new FacesException(e);
456              }
457        }
458        return 1;
459      }
460    
461      public void setRowSpan(java.lang.Integer rowSpan) {
462        this.rowSpan = rowSpan;
463      }
464    
465      /**
466      This attribute is for internal use only.
467    
468      */
469      public java.lang.Integer getHorizontalIndex() {
470        if (horizontalIndex != null) {
471          return horizontalIndex;
472        }
473        ValueExpression ve = getValueExpression("horizontalIndex");
474        if (ve != null) {
475          try {
476            Number number = (Number) ve.getValue(getFacesContext().getELContext());
477            if (number != null) {
478              return number.intValue();
479            }
480          } catch (ELException e) {
481                      throw new FacesException(e);
482              }
483        }
484        return null;
485      }
486    
487      public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
488        this.horizontalIndex = horizontalIndex;
489      }
490    
491      /**
492      This value will usually be set by the layout manager.
493    
494      */
495      public org.apache.myfaces.tobago.layout.Measure getLeft() {
496        if (left != null) {
497          return left;
498        }
499        ValueExpression ve = getValueExpression("left");
500        if (ve != null) {
501          try {
502            Object object = ve.getValue(getFacesContext().getELContext());
503            return Measure.valueOf(object);
504          } catch (ELException e) {
505                      throw new FacesException(e);
506              }
507        }
508        return null;
509      }
510    
511      public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
512        this.left = left;
513      }
514    
515      public java.lang.Integer getColumnSpan() {
516        if (columnSpan != null) {
517          return columnSpan;
518        }
519        ValueExpression ve = getValueExpression("columnSpan");
520        if (ve != null) {
521          try {
522            Number number = (Number) ve.getValue(getFacesContext().getELContext());
523            if (number != null) {
524              return number.intValue();
525            }
526          } catch (ELException e) {
527                      throw new FacesException(e);
528              }
529        }
530        return 1;
531      }
532    
533      public void setColumnSpan(java.lang.Integer columnSpan) {
534        this.columnSpan = columnSpan;
535      }
536    
537      /**
538      This value will usually be set by the layout manager.
539    
540      */
541      public org.apache.myfaces.tobago.layout.Measure getTop() {
542        if (top != null) {
543          return top;
544        }
545        ValueExpression ve = getValueExpression("top");
546        if (ve != null) {
547          try {
548            Object object = ve.getValue(getFacesContext().getELContext());
549            return Measure.valueOf(object);
550          } catch (ELException e) {
551                      throw new FacesException(e);
552              }
553        }
554        return null;
555      }
556    
557      public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
558        this.top = top;
559      }
560    
561      public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
562        if (maximumHeight != null) {
563          return maximumHeight;
564        }
565        ValueExpression ve = getValueExpression("maximumHeight");
566        if (ve != null) {
567          try {
568            Object object = ve.getValue(getFacesContext().getELContext());
569            return Measure.valueOf(object);
570          } catch (ELException e) {
571                      throw new FacesException(e);
572              }
573        }
574        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
575      }
576    
577      public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
578        this.maximumHeight = maximumHeight;
579      }
580    
581      public void restoreState(FacesContext context, Object componentState) {
582        Object[] values = (Object[]) componentState;
583        super.restoreState(context, values[0]);
584        currentWidth = (org.apache.myfaces.tobago.layout.Measure) values[1];
585        markup = (org.apache.myfaces.tobago.context.Markup) values[2];
586        marginLeft = (org.apache.myfaces.tobago.layout.Measure) values[3];
587        marginTop = (org.apache.myfaces.tobago.layout.Measure) values[4];
588        width = (org.apache.myfaces.tobago.layout.Measure) values[5];
589        marginRight = (org.apache.myfaces.tobago.layout.Measure) values[6];
590        preferredHeight = (org.apache.myfaces.tobago.layout.Measure) values[7];
591        currentHeight = (org.apache.myfaces.tobago.layout.Measure) values[8];
592        display = (org.apache.myfaces.tobago.layout.Display) values[9];
593        minimumHeight = (org.apache.myfaces.tobago.layout.Measure) values[10];
594        maximumWidth = (org.apache.myfaces.tobago.layout.Measure) values[11];
595        preferredWidth = (org.apache.myfaces.tobago.layout.Measure) values[12];
596        marginBottom = (org.apache.myfaces.tobago.layout.Measure) values[13];
597        height = (org.apache.myfaces.tobago.layout.Measure) values[14];
598        verticalIndex = (java.lang.Integer) values[15];
599        minimumWidth = (org.apache.myfaces.tobago.layout.Measure) values[16];
600        currentMarkup = (org.apache.myfaces.tobago.context.Markup) values[17];
601        rowSpan = (java.lang.Integer) values[18];
602        horizontalIndex = (java.lang.Integer) values[19];
603        left = (org.apache.myfaces.tobago.layout.Measure) values[20];
604        columnSpan = (java.lang.Integer) values[21];
605        top = (org.apache.myfaces.tobago.layout.Measure) values[22];
606        maximumHeight = (org.apache.myfaces.tobago.layout.Measure) values[23];
607      }
608    
609      public Object saveState(FacesContext context) {
610        Object[] values = new Object[24];
611        values[0] = super.saveState(context);
612        values[1] = currentWidth;
613        values[2] = markup;
614        values[3] = marginLeft;
615        values[4] = marginTop;
616        values[5] = width;
617        values[6] = marginRight;
618        values[7] = preferredHeight;
619        values[8] = currentHeight;
620        values[9] = display;
621        values[10] = minimumHeight;
622        values[11] = maximumWidth;
623        values[12] = preferredWidth;
624        values[13] = marginBottom;
625        values[14] = height;
626        values[15] = verticalIndex;
627        values[16] = minimumWidth;
628        values[17] = currentMarkup;
629        values[18] = rowSpan;
630        values[19] = horizontalIndex;
631        values[20] = left;
632        values[21] = columnSpan;
633        values[22] = top;
634        values[23] = maximumHeight;
635        return values;
636      }
637    
638    
639    }