View Javadoc

1   // ---------- Attention: Generated code, please do not modify! -----------  
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
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.AbstractUIGridLayout;
25  import org.apache.myfaces.tobago.layout.Measure;
26  import org.apache.commons.lang.ArrayUtils;
27  import org.apache.commons.lang.StringUtils;
28  import org.apache.myfaces.tobago.internal.util.Deprecation;
29  import org.apache.myfaces.tobago.renderkit.MarginValues;
30  import org.apache.myfaces.tobago.renderkit.SpacingValues;
31  import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
32  import javax.el.ELException;
33  import javax.faces.FacesException;
34  import java.util.ArrayList;
35  import java.util.List;
36  import javax.el.MethodExpression;
37  import javax.el.ValueExpression;
38  
39  /** 
40   Renders a GridLayout.
41    <pre>
42    columns/rows ::= LAYOUT
43    LAYOUT       ::= TOKEN [";" TOKEN]+
44    TOKEN        ::= AUTO | PIXEL | PROPORTIONAL
45    AUTO         ::= "auto" | "fixed"
46    PIXEL        ::= NUMBER "px"
47    PROPORTIONAL ::= [NUMBER] "*"
48    </pre>
49    <p/>
50    <table border="1">
51    <tr>
52    <th>Parent</th>
53    <th>Child</th>
54    <th>Okay?</th>
55    <th>Remarks</th>
56    </tr>
57    <tr>
58    <td>AUTO</td>
59    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
60    <td>okay</td>
61    <td>-</td>
62    </tr>
63    <tr>
64    <td>AUTO</td>
65    <td>any combination with at least one PROPORTIONAL</td>
66    <td>wrong</td>
67    <td>LayoutManager cannot compute the auto value.</td>
68    </tr>
69    <tr>
70    <td>PIXEL</td>
71    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
72    <td>potentially wrong</td>
73    <td>The values depend on each other, the programmer has to keep consistency manually.</td>
74    </tr>
75    <tr>
76    <td>PIXEL</td>
77    <td>any combination with at least one PROPORTIONAL</td>
78    <td>okay</td>
79    <td>-</td>
80    </tr>
81    <tr>
82    <td>PROPORTIONAL</td>
83    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
84    <td>potentially wrong</td>
85    <td>No automatic matching:<ul><li>too little space: scroll bar</li>
86    <li>too much space: elements will be spread.</li></ul></td>
87    </tr>
88    <tr>
89    <td>PROPORTIONAL</td>
90    <td>any combination with at least one PROPORTIONAL</td>
91    <td>okay</td>
92    <td>-</td>
93    </tr>
94    </table>
95    * UIComponent class, generated from template {@code component2.0.stg} with class
96    * {@link org.apache.myfaces.tobago.internal.taglib.component.GridLayoutTagDeclaration}.
97   */
98  public class UIGridLayout
99      extends AbstractUIGridLayout implements SupportsMarkup {
100 
101   public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.GridLayout";
102 
103   public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.GridLayout";
104 
105   private org.apache.myfaces.tobago.context.Markup currentMarkup;
106 
107   enum PropertyKeys {
108     rowOverflow,
109     markup,
110     marginLeft,
111     marginTop,
112     marginRight,
113     columns,
114     cellspacing,
115     rows,
116     marginBottom,
117     columnOverflow,
118     rowSpacing,
119     margin,
120     border,
121     columnSpacing,
122   }
123 
124   public String getFamily() {
125     return COMPONENT_FAMILY;
126   }
127 
128 
129   /**
130   This attribute is a hint for the layout manager. Should not be used in most cases.
131 
132   */
133   public boolean isRowOverflow() {
134     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.rowOverflow);
135     if (bool != null) {
136       return bool;
137     }
138     return false;
139   }
140 
141   public void setRowOverflow(boolean rowOverflow) {
142     getStateHelper().put(PropertyKeys.rowOverflow, rowOverflow);
143   }
144 
145   public org.apache.myfaces.tobago.context.Markup getMarkup() {
146     Object object = getStateHelper().eval(PropertyKeys.markup);
147     if (object != null) {
148       return Markup.valueOf(object);
149     }
150     return null;
151   }
152 
153   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
154     getStateHelper().put(PropertyKeys.markup, markup);
155   }
156 
157   /**
158   Left margin between container component and the children.
159 
160   */
161   public org.apache.myfaces.tobago.layout.Measure getMarginLeft() {
162     Object object = getStateHelper().eval(PropertyKeys.marginLeft);
163     if (object != null) {
164        return Measure.valueOf(object);
165     }
166     return getMargin() != null
167    ? getMargin()
168    : ((MarginValues)getRenderer(getFacesContext())).getMarginLeft(getFacesContext(), this);
169   }
170 
171   public void setMarginLeft(org.apache.myfaces.tobago.layout.Measure marginLeft) {
172     getStateHelper().put(PropertyKeys.marginLeft, marginLeft);
173   }
174 
175   /**
176   Top margin between container component and the children.
177 
178   */
179   public org.apache.myfaces.tobago.layout.Measure getMarginTop() {
180     Object object = getStateHelper().eval(PropertyKeys.marginTop);
181     if (object != null) {
182        return Measure.valueOf(object);
183     }
184     return getMargin() != null
185    ? getMargin()
186    : ((MarginValues)getRenderer(getFacesContext())).getMarginTop(getFacesContext(), this);
187   }
188 
189   public void setMarginTop(org.apache.myfaces.tobago.layout.Measure marginTop) {
190     getStateHelper().put(PropertyKeys.marginTop, marginTop);
191   }
192 
193   /**
194   Right margin between container component and the children.
195 
196   */
197   public org.apache.myfaces.tobago.layout.Measure getMarginRight() {
198     Object object = getStateHelper().eval(PropertyKeys.marginRight);
199     if (object != null) {
200        return Measure.valueOf(object);
201     }
202     return getMargin() != null
203    ? getMargin()
204    : ((MarginValues)getRenderer(getFacesContext())).getMarginRight(getFacesContext(), this);
205   }
206 
207   public void setMarginRight(org.apache.myfaces.tobago.layout.Measure marginRight) {
208     getStateHelper().put(PropertyKeys.marginRight, marginRight);
209   }
210 
211   /**
212   This value defines the layout constraints for column layout.
213    It is a semicolon separated list of layout tokens '[&lt;n>]*', '&lt;n>px' or 'auto'.
214    Where &lt;n> is a non negative integer and the square brackets means optional.
215    Example: '2*;*;100px;auto'.
216   <br />Default: <code>1*</code>
217   */
218   public java.lang.String getColumns() {
219     java.lang.String columns = (java.lang.String) getStateHelper().eval(PropertyKeys.columns);
220     if (columns != null) {
221       return columns;
222     }
223     return "1*";
224   }
225 
226   public void setColumns(java.lang.String columns) {
227     getStateHelper().put(PropertyKeys.columns, columns);
228   }
229 
230   /**
231   Spacing between component and layout cell's.
232    Can be overwritten by columnSpacing and rowSpacing.
233 
234   @deprecated*/
235   @Deprecated
236   public org.apache.myfaces.tobago.layout.Measure getCellspacing() {
237     Object object = getStateHelper().eval(PropertyKeys.cellspacing);
238     if (object != null) {
239        return Measure.valueOf(object);
240     }
241     return null;
242   }
243 
244   @Deprecated
245   public void setCellspacing(org.apache.myfaces.tobago.layout.Measure cellspacing) {
246       Deprecation.LOG.error("The attribute 'cellspacing' of 'UIGridLayout' is deprecated. "
247           + "Please refer the documentation for further information.");
248     getStateHelper().put(PropertyKeys.cellspacing, cellspacing);
249   }
250 
251   /**
252   This value defines the layout constraints for column layout.
253    It is a semicolon separated list of layout tokens '[&lt;n>]*', '&lt;n>px' or 'auto'.
254    Where &lt;n> is a non negative integer and the square brackets means optional.
255    Example: '2*;*;100px;auto'.
256   <br />Default: <code>1*</code>
257   */
258   public java.lang.String getRows() {
259     java.lang.String rows = (java.lang.String) getStateHelper().eval(PropertyKeys.rows);
260     if (rows != null) {
261       return rows;
262     }
263     return "1*";
264   }
265 
266   public void setRows(java.lang.String rows) {
267     getStateHelper().put(PropertyKeys.rows, rows);
268   }
269 
270   /**
271   Bottom margin between container component and the children.
272 
273   */
274   public org.apache.myfaces.tobago.layout.Measure getMarginBottom() {
275     Object object = getStateHelper().eval(PropertyKeys.marginBottom);
276     if (object != null) {
277        return Measure.valueOf(object);
278     }
279     return getMargin() != null
280    ? getMargin()
281    : ((MarginValues)getRenderer(getFacesContext())).getMarginBottom(getFacesContext(), this);
282   }
283 
284   public void setMarginBottom(org.apache.myfaces.tobago.layout.Measure marginBottom) {
285     getStateHelper().put(PropertyKeys.marginBottom, marginBottom);
286   }
287 
288   /**
289   This attribute is a hint for the layout manager. Should not be used in most cases.
290 
291   */
292   public boolean isColumnOverflow() {
293     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.columnOverflow);
294     if (bool != null) {
295       return bool;
296     }
297     return false;
298   }
299 
300   public void setColumnOverflow(boolean columnOverflow) {
301     getStateHelper().put(PropertyKeys.columnOverflow, columnOverflow);
302   }
303 
304   /**
305   Spacing between the rows in the actual layout.
306 
307   */
308   public org.apache.myfaces.tobago.layout.Measure getRowSpacing() {
309     Object object = getStateHelper().eval(PropertyKeys.rowSpacing);
310     if (object != null) {
311        return Measure.valueOf(object);
312     }
313     return getCellspacing() != null
314    ? getCellspacing()
315    : ((SpacingValues)getRenderer(getFacesContext())).getRowSpacing(getFacesContext(), this);
316   }
317 
318   public void setRowSpacing(org.apache.myfaces.tobago.layout.Measure rowSpacing) {
319     getStateHelper().put(PropertyKeys.rowSpacing, rowSpacing);
320   }
321 
322   public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() {
323     if (currentMarkup != null) {
324       return currentMarkup;
325     }
326     return null;
327   }
328 
329   public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) {
330     this.currentMarkup = currentMarkup;
331   }
332 
333   /**
334   Margin between container component and the children.
335 
336   */
337   public org.apache.myfaces.tobago.layout.Measure getMargin() {
338     Object object = getStateHelper().eval(PropertyKeys.margin);
339     if (object != null) {
340        return Measure.valueOf(object);
341     }
342     return null;
343   }
344 
345   public void setMargin(org.apache.myfaces.tobago.layout.Measure margin) {
346     getStateHelper().put(PropertyKeys.margin, margin);
347   }
348 
349   /**
350   Border size of this component.
351 
352   */
353   public java.lang.String getBorder() {
354     return (java.lang.String) getStateHelper().eval(PropertyKeys.border);
355   }
356 
357   public void setBorder(java.lang.String border) {
358     getStateHelper().put(PropertyKeys.border, border);
359   }
360 
361   /**
362   Spacing between the columns in the actual layout.
363 
364   */
365   public org.apache.myfaces.tobago.layout.Measure getColumnSpacing() {
366     Object object = getStateHelper().eval(PropertyKeys.columnSpacing);
367     if (object != null) {
368        return Measure.valueOf(object);
369     }
370     return getCellspacing() != null
371    ? getCellspacing()
372    : ((SpacingValues)getRenderer(getFacesContext())).getColumnSpacing(getFacesContext(), this);
373   }
374 
375   public void setColumnSpacing(org.apache.myfaces.tobago.layout.Measure columnSpacing) {
376     getStateHelper().put(PropertyKeys.columnSpacing, columnSpacing);
377   }
378 
379   public Object saveState(FacesContext context) {
380     currentMarkup = null;
381     return super.saveState(context);
382   }
383 
384 
385 }