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        return null;
428      }
429    
430      public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
431        this.currentMarkup = currentMarkup;
432      }
433    
434      public java.lang.Integer getRowSpan() {
435        if (rowSpan != null) {
436          return rowSpan;
437        }
438        ValueExpression ve = getValueExpression("rowSpan");
439        if (ve != null) {
440          try {
441            Number number = (Number) ve.getValue(getFacesContext().getELContext());
442            if (number != null) {
443              return number.intValue();
444            }
445          } catch (ELException e) {
446                      throw new FacesException(e);
447              }
448        }
449        return 1;
450      }
451    
452      public void setRowSpan(java.lang.Integer rowSpan) {
453        this.rowSpan = rowSpan;
454      }
455    
456      /**
457      This attribute is for internal use only.
458    
459      */
460      public java.lang.Integer getHorizontalIndex() {
461        if (horizontalIndex != null) {
462          return horizontalIndex;
463        }
464        ValueExpression ve = getValueExpression("horizontalIndex");
465        if (ve != null) {
466          try {
467            Number number = (Number) ve.getValue(getFacesContext().getELContext());
468            if (number != null) {
469              return number.intValue();
470            }
471          } catch (ELException e) {
472                      throw new FacesException(e);
473              }
474        }
475        return null;
476      }
477    
478      public void setHorizontalIndex(java.lang.Integer horizontalIndex) {
479        this.horizontalIndex = horizontalIndex;
480      }
481    
482      /**
483      This value will usually be set by the layout manager.
484    
485      */
486      public org.apache.myfaces.tobago.layout.Measure getLeft() {
487        if (left != null) {
488          return left;
489        }
490        ValueExpression ve = getValueExpression("left");
491        if (ve != null) {
492          try {
493            Object object = ve.getValue(getFacesContext().getELContext());
494            return Measure.valueOf(object);
495          } catch (ELException e) {
496                      throw new FacesException(e);
497              }
498        }
499        return null;
500      }
501    
502      public void setLeft(org.apache.myfaces.tobago.layout.Measure left) {
503        this.left = left;
504      }
505    
506      public java.lang.Integer getColumnSpan() {
507        if (columnSpan != null) {
508          return columnSpan;
509        }
510        ValueExpression ve = getValueExpression("columnSpan");
511        if (ve != null) {
512          try {
513            Number number = (Number) ve.getValue(getFacesContext().getELContext());
514            if (number != null) {
515              return number.intValue();
516            }
517          } catch (ELException e) {
518                      throw new FacesException(e);
519              }
520        }
521        return 1;
522      }
523    
524      public void setColumnSpan(java.lang.Integer columnSpan) {
525        this.columnSpan = columnSpan;
526      }
527    
528      /**
529      This value will usually be set by the layout manager.
530    
531      */
532      public org.apache.myfaces.tobago.layout.Measure getTop() {
533        if (top != null) {
534          return top;
535        }
536        ValueExpression ve = getValueExpression("top");
537        if (ve != null) {
538          try {
539            Object object = ve.getValue(getFacesContext().getELContext());
540            return Measure.valueOf(object);
541          } catch (ELException e) {
542                      throw new FacesException(e);
543              }
544        }
545        return null;
546      }
547    
548      public void setTop(org.apache.myfaces.tobago.layout.Measure top) {
549        this.top = top;
550      }
551    
552      public org.apache.myfaces.tobago.layout.Measure getMaximumHeight() {
553        if (maximumHeight != null) {
554          return maximumHeight;
555        }
556        ValueExpression ve = getValueExpression("maximumHeight");
557        if (ve != null) {
558          try {
559            Object object = ve.getValue(getFacesContext().getELContext());
560            return Measure.valueOf(object);
561          } catch (ELException e) {
562                      throw new FacesException(e);
563              }
564        }
565        return ((LayoutComponentRenderer) getRenderer(getFacesContext())).getMaximumHeight(getFacesContext(), this);
566      }
567    
568      public void setMaximumHeight(org.apache.myfaces.tobago.layout.Measure maximumHeight) {
569        this.maximumHeight = maximumHeight;
570      }
571    
572      public void restoreState(FacesContext context, Object componentState) {
573        Object[] values = (Object[]) componentState;
574        super.restoreState(context, values[0]);
575        currentWidth = (org.apache.myfaces.tobago.layout.Measure) values[1];
576        markup = (org.apache.myfaces.tobago.context.Markup) values[2];
577        marginLeft = (org.apache.myfaces.tobago.layout.Measure) values[3];
578        marginTop = (org.apache.myfaces.tobago.layout.Measure) values[4];
579        width = (org.apache.myfaces.tobago.layout.Measure) values[5];
580        marginRight = (org.apache.myfaces.tobago.layout.Measure) values[6];
581        preferredHeight = (org.apache.myfaces.tobago.layout.Measure) values[7];
582        currentHeight = (org.apache.myfaces.tobago.layout.Measure) values[8];
583        display = (org.apache.myfaces.tobago.layout.Display) values[9];
584        minimumHeight = (org.apache.myfaces.tobago.layout.Measure) values[10];
585        maximumWidth = (org.apache.myfaces.tobago.layout.Measure) values[11];
586        preferredWidth = (org.apache.myfaces.tobago.layout.Measure) values[12];
587        marginBottom = (org.apache.myfaces.tobago.layout.Measure) values[13];
588        height = (org.apache.myfaces.tobago.layout.Measure) values[14];
589        verticalIndex = (java.lang.Integer) values[15];
590        minimumWidth = (org.apache.myfaces.tobago.layout.Measure) values[16];
591        rowSpan = (java.lang.Integer) values[17];
592        horizontalIndex = (java.lang.Integer) values[18];
593        left = (org.apache.myfaces.tobago.layout.Measure) values[19];
594        columnSpan = (java.lang.Integer) values[20];
595        top = (org.apache.myfaces.tobago.layout.Measure) values[21];
596        maximumHeight = (org.apache.myfaces.tobago.layout.Measure) values[22];
597      }
598    
599      public Object saveState(FacesContext context) {
600        Object[] values = new Object[23];
601        values[0] = super.saveState(context);
602        values[1] = currentWidth;
603        values[2] = markup;
604        values[3] = marginLeft;
605        values[4] = marginTop;
606        values[5] = width;
607        values[6] = marginRight;
608        values[7] = preferredHeight;
609        values[8] = currentHeight;
610        values[9] = display;
611        values[10] = minimumHeight;
612        values[11] = maximumWidth;
613        values[12] = preferredWidth;
614        values[13] = marginBottom;
615        values[14] = height;
616        values[15] = verticalIndex;
617        values[16] = minimumWidth;
618        values[17] = rowSpan;
619        values[18] = horizontalIndex;
620        values[19] = left;
621        values[20] = columnSpan;
622        values[21] = top;
623        values[22] = maximumHeight;
624        currentMarkup = null;
625        return values;
626      }
627    
628    
629    }