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