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.myfaces.tobago.renderkit.css.CustomClass;
27  import org.apache.myfaces.tobago.renderkit.css.Style;
28  import org.apache.myfaces.tobago.internal.util.ArrayUtils;
29  import org.apache.myfaces.tobago.internal.util.StringUtils;
30  import org.apache.myfaces.tobago.internal.util.Deprecation;
31  import javax.el.ELException;
32  import javax.faces.FacesException;
33  import java.util.Arrays;
34  import java.util.ArrayList;
35  import java.util.Collection;
36  import java.util.List;
37  import javax.el.MethodExpression;
38  import javax.el.ValueExpression;
39  
40  /** 
41   Renders a GridLayout.
42    <pre>
43    columns/rows ::= LAYOUT
44    LAYOUT       ::= TOKEN [";" TOKEN]+
45    TOKEN        ::= AUTO | PIXEL | PROPORTIONAL
46    AUTO         ::= "auto" | "fixed"
47    PIXEL        ::= NUMBER "px"
48    PROPORTIONAL ::= [NUMBER] "*"
49    </pre>
50    <table border="1">
51    <caption>GridLayout</caption>
52    <tr>
53    <th>Parent</th>
54    <th>Child</th>
55    <th>Okay?</th>
56    <th>Remarks</th>
57    </tr>
58    <tr>
59    <td>AUTO</td>
60    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
61    <td>okay</td>
62    <td>-</td>
63    </tr>
64    <tr>
65    <td>AUTO</td>
66    <td>any combination with at least one PROPORTIONAL</td>
67    <td>wrong</td>
68    <td>Layout manager cannot compute the auto value.</td>
69    </tr>
70    <tr>
71    <td>PIXEL</td>
72    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
73    <td>potentially wrong</td>
74    <td>The values depend on each other, the programmer has to keep consistency manually.</td>
75    </tr>
76    <tr>
77    <td>PIXEL</td>
78    <td>any combination with at least one PROPORTIONAL</td>
79    <td>okay</td>
80    <td>-</td>
81    </tr>
82    <tr>
83    <td>PROPORTIONAL</td>
84    <td>any combination of AUTO or PIXEL but no PROPORTIONAL</td>
85    <td>potentially wrong</td>
86    <td>No automatic matching:<ul><li>too little space: scroll bar</li>
87    <li>too much space: elements will be spread.</li></ul></td>
88    </tr>
89    <tr>
90    <td>PROPORTIONAL</td>
91    <td>any combination with at least one PROPORTIONAL</td>
92    <td>okay</td>
93    <td>-</td>
94    </tr>
95    </table>
96    * UIComponent class, generated from template {@code component.stg} with class
97    * {@link org.apache.myfaces.tobago.internal.taglib.component.GridLayoutTagDeclaration}.
98   */
99  public class UIGridLayout
100     extends AbstractUIGridLayout implements Visual {
101 
102   public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.GridLayout";
103 
104   public static final String COMPONENT_FAMILY = "org.apache.myfaces.tobago.GridLayout";
105 
106 
107   enum PropertyKeys {
108     columnSpacing,
109     markup,
110     columns,
111     customClass,
112     style,
113     rowSpacing,
114     rows,
115     rigid,
116   }
117 
118   public String getFamily() {
119     return COMPONENT_FAMILY;
120   }
121 
122 
123   /**
124   Spacing between the columns in the actual layout.
125 
126   */
127   public org.apache.myfaces.tobago.layout.Measure getColumnSpacing() {
128     Object object = getStateHelper().eval(PropertyKeys.columnSpacing);
129     if (object != null) {
130        return Measure.valueOf(object);
131     }
132     return Measure.ZERO;
133   }
134 
135   public void setColumnSpacing(org.apache.myfaces.tobago.layout.Measure columnSpacing) {
136     getStateHelper().put(PropertyKeys.columnSpacing, columnSpacing);
137   }
138 
139   public org.apache.myfaces.tobago.context.Markup getMarkup() {
140     Object object = getStateHelper().eval(PropertyKeys.markup);
141     if (object != null) {
142       return Markup.valueOf(object);
143     }
144     return null;
145   }
146 
147   public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) {
148     getStateHelper().put(PropertyKeys.markup, markup);
149   }
150 
151   /**
152   This value defines the layout constraints for column layout.
153    It is a semicolon separated list of layout tokens '[&lt;n&gt;]*', '&lt;n&gt;px' or 'auto'.
154    Where &lt;n&gt; is a non negative integer and the square brackets means optional.
155    Example: '2*;*;100px;auto'.
156   <br>Default: <code>1*</code>
157   */
158   public java.lang.String getColumns() {
159     java.lang.String columns = (java.lang.String) getStateHelper().eval(PropertyKeys.columns);
160     if (columns != null) {
161       return columns;
162     }
163     return "1*";
164   }
165 
166   public void setColumns(java.lang.String columns) {
167     getStateHelper().put(PropertyKeys.columns, columns);
168   }
169 
170   /**
171   Sets a CSS class in its parent, if the parent supports it.
172 
173    Which this feature it is possible to put a CSS class name into a component with the &lt;tc:style&gt; tag. Example:
174 
175    <pre>
176    &lt;tc:in&gt;
177      &lt;tc:style customClass="my-emphasized"/&gt;
178    &lt;/tc:in&gt;
179    </pre>
180 
181    One capability is, to used external CSS libs.
182    <br>
183    This feature should not be used imprudent.
184    Because it might be unstable against changes in the renderered HTML code.
185 
186   */
187   public org.apache.myfaces.tobago.renderkit.css.CustomClass getCustomClass() {
188     return (org.apache.myfaces.tobago.renderkit.css.CustomClass) getStateHelper().eval(PropertyKeys.customClass);
189   }
190 
191   public void setCustomClass(org.apache.myfaces.tobago.renderkit.css.CustomClass customClass) {
192     getStateHelper().put(PropertyKeys.customClass, customClass);
193   }
194 
195   /**
196   For internal use. Used for rendering, if there is a child tag &lt;tc:style&gt;
197 
198   */
199   public org.apache.myfaces.tobago.renderkit.css.Style getStyle() {
200     return (org.apache.myfaces.tobago.renderkit.css.Style) getStateHelper().eval(PropertyKeys.style);
201   }
202 
203   public void setStyle(org.apache.myfaces.tobago.renderkit.css.Style style) {
204     getStateHelper().put(PropertyKeys.style, style);
205   }
206 
207   /**
208   Spacing between the rows in the actual layout.
209 
210   */
211   public org.apache.myfaces.tobago.layout.Measure getRowSpacing() {
212     Object object = getStateHelper().eval(PropertyKeys.rowSpacing);
213     if (object != null) {
214        return Measure.valueOf(object);
215     }
216     return Measure.ZERO;
217   }
218 
219   public void setRowSpacing(org.apache.myfaces.tobago.layout.Measure rowSpacing) {
220     getStateHelper().put(PropertyKeys.rowSpacing, rowSpacing);
221   }
222 
223   /**
224   This value defines the layout constraints for row layout.
225    It is a semicolon separated list of layout tokens '[&lt;n&gt;]*', '&lt;n&gt;px' or 'auto'.
226    Where &lt;n&gt; is a non negative integer and the square brackets means optional.
227    Example: '2*;*;100px;auto'.
228   <br>Default: <code>1*</code>
229   */
230   public java.lang.String getRows() {
231     java.lang.String rows = (java.lang.String) getStateHelper().eval(PropertyKeys.rows);
232     if (rows != null) {
233       return rows;
234     }
235     return "1*";
236   }
237 
238   public void setRows(java.lang.String rows) {
239     getStateHelper().put(PropertyKeys.rows, rows);
240   }
241 
242   /**
243   This attribute advises the layout manager, to not use space that comes from non rendered components.
244 
245   */
246   public boolean isRigid() {
247     Boolean bool = (Boolean) getStateHelper().eval(PropertyKeys.rigid);
248     if (bool != null) {
249       return bool;
250     }
251     return false;
252   }
253 
254   public void setRigid(boolean rigid) {
255     getStateHelper().put(PropertyKeys.rigid, rigid);
256   }
257 
258 
259 }