View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.capability.ITypedComponentCapability;
5   import org.apache.commons.logging.LogFactory;
6   import org.rcfaces.core.component.capability.IAccessKeyCapability;
7   import org.rcfaces.core.component.capability.IForCapability;
8   import org.rcfaces.core.component.capability.ITextDirectionCapability;
9   import javax.el.ValueExpression;
10  import org.rcfaces.core.component.capability.ITextAlignmentCapability;
11  import java.util.HashSet;
12  import org.apache.commons.logging.Log;
13  import org.rcfaces.core.component.AbstractOutputComponent;
14  import java.util.Set;
15  import java.util.Arrays;
16  import org.rcfaces.core.component.capability.ITextCapability;
17  import org.rcfaces.core.component.capability.IFontCapability;
18  
19  /**
20   * <p>The text Component is a placeholder for displaying text.</p>
21   * <p>The text Component has the following capabilities :
22   * <ul>
23   * <li>ITextCapability</li>
24   * <li>ITextDirectionCapability</li>
25   * <li>IFontCapability</li>
26   * <li>ITextAlignmentCapability</li>
27   * <li>IAccessKeyCapability</li>
28   * <li>IForCapability</li>
29   * <li>ITypedComponentCapability </li>
30   * </ul>
31   * </p>
32   * 
33   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/TextComponent.html">text</a> renderer is linked to the <a href="/jsdocs/index.html?f_text.html" target="_blank">f_text</a> javascript class. f_text extends f_component</p>
34   * 
35   * <p> Table of component style classes: </p>
36   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
37   * <tbody>
38   * 
39   * <tr style="text-align:left">
40   * <th  width="33%">Style Name</th>
41   * <th width="50%">Description</th>
42   * </tr>
43   * 
44   * <tr  style="text-align:left">
45   * <td width="33%">f_text</td>
46   * <td width="50%">Defines styles for the wrapper element</td>
47   * </tr>
48   * 
49   * </tbody>
50   * </table>
51   */
52  public class TextComponent extends AbstractOutputComponent implements 
53  	ITextCapability,
54  	ITextDirectionCapability,
55  	IFontCapability,
56  	ITextAlignmentCapability,
57  	IAccessKeyCapability,
58  	IForCapability,
59  	ITypedComponentCapability {
60  
61  	private static final Log LOG = LogFactory.getLog(TextComponent.class);
62  
63  	public static final String COMPONENT_TYPE="org.rcfaces.core.text";
64  
65  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractOutputComponent.CAMELIA_ATTRIBUTES);
66  	static {
67  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"accessKey","fontName","fontItalic","text","fontUnderline","for","textAlignment","fontBold","type","fontSize","textDirection"}));
68  	}
69  	protected static final String CAMELIA_VALUE_ALIAS="text";
70  
71  	public TextComponent() {
72  		setRendererType(COMPONENT_TYPE);
73  	}
74  
75  	public TextComponent(String componentId) {
76  		this();
77  		setId(componentId);
78  	}
79  
80  	public java.lang.String getText() {
81  		return getText(null);
82  	}
83  
84  	/**
85  	 * See {@link #getText() getText()} for more details
86  	 */
87  	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
88  		return org.rcfaces.core.internal.tools.ValuesTools.valueToString(this, facesContext);
89  	}
90  
91  	/**
92  	 * Returns <code>true</code> if the attribute "text" is set.
93  	 * @return <code>true</code> if the attribute is set.
94  	 */
95  	public final boolean isTextSetted() {
96  		return engine.isPropertySetted(Properties.TEXT);
97  	}
98  
99  	public void setText(java.lang.String text) {
100 		setValue(text);
101 	}
102 
103 	public int getTextDirection() {
104 		return getTextDirection(null);
105 	}
106 
107 	/**
108 	 * See {@link #getTextDirection() getTextDirection()} for more details
109 	 */
110 	public int getTextDirection(javax.faces.context.FacesContext facesContext) {
111 		return engine.getIntProperty(Properties.TEXT_DIRECTION,0, facesContext);
112 	}
113 
114 	/**
115 	 * Returns <code>true</code> if the attribute "textDirection" is set.
116 	 * @return <code>true</code> if the attribute is set.
117 	 */
118 	public final boolean isTextDirectionSetted() {
119 		return engine.isPropertySetted(Properties.TEXT_DIRECTION);
120 	}
121 
122 	public void setTextDirection(int textDirection) {
123 		engine.setProperty(Properties.TEXT_DIRECTION, textDirection);
124 	}
125 
126 	public java.lang.Boolean getFontBold() {
127 		return getFontBold(null);
128 	}
129 
130 	/**
131 	 * See {@link #getFontBold() getFontBold()} for more details
132 	 */
133 	public java.lang.Boolean getFontBold(javax.faces.context.FacesContext facesContext) {
134 		return engine.getBooleanProperty(Properties.FONT_BOLD, facesContext);
135 	}
136 
137 	/**
138 	 * Returns <code>true</code> if the attribute "fontBold" is set.
139 	 * @return <code>true</code> if the attribute is set.
140 	 */
141 	public final boolean isFontBoldSetted() {
142 		return engine.isPropertySetted(Properties.FONT_BOLD);
143 	}
144 
145 	public void setFontBold(java.lang.Boolean fontBold) {
146 		engine.setProperty(Properties.FONT_BOLD, fontBold);
147 	}
148 
149 	public java.lang.Boolean getFontItalic() {
150 		return getFontItalic(null);
151 	}
152 
153 	/**
154 	 * See {@link #getFontItalic() getFontItalic()} for more details
155 	 */
156 	public java.lang.Boolean getFontItalic(javax.faces.context.FacesContext facesContext) {
157 		return engine.getBooleanProperty(Properties.FONT_ITALIC, facesContext);
158 	}
159 
160 	/**
161 	 * Returns <code>true</code> if the attribute "fontItalic" is set.
162 	 * @return <code>true</code> if the attribute is set.
163 	 */
164 	public final boolean isFontItalicSetted() {
165 		return engine.isPropertySetted(Properties.FONT_ITALIC);
166 	}
167 
168 	public void setFontItalic(java.lang.Boolean fontItalic) {
169 		engine.setProperty(Properties.FONT_ITALIC, fontItalic);
170 	}
171 
172 	public java.lang.String getFontName() {
173 		return getFontName(null);
174 	}
175 
176 	/**
177 	 * See {@link #getFontName() getFontName()} for more details
178 	 */
179 	public java.lang.String getFontName(javax.faces.context.FacesContext facesContext) {
180 		return engine.getStringProperty(Properties.FONT_NAME, facesContext);
181 	}
182 
183 	/**
184 	 * Returns <code>true</code> if the attribute "fontName" is set.
185 	 * @return <code>true</code> if the attribute is set.
186 	 */
187 	public final boolean isFontNameSetted() {
188 		return engine.isPropertySetted(Properties.FONT_NAME);
189 	}
190 
191 	public void setFontName(java.lang.String fontName) {
192 		engine.setProperty(Properties.FONT_NAME, fontName);
193 	}
194 
195 	public java.lang.String getFontSize() {
196 		return getFontSize(null);
197 	}
198 
199 	/**
200 	 * See {@link #getFontSize() getFontSize()} for more details
201 	 */
202 	public java.lang.String getFontSize(javax.faces.context.FacesContext facesContext) {
203 		return engine.getStringProperty(Properties.FONT_SIZE, facesContext);
204 	}
205 
206 	/**
207 	 * Returns <code>true</code> if the attribute "fontSize" is set.
208 	 * @return <code>true</code> if the attribute is set.
209 	 */
210 	public final boolean isFontSizeSetted() {
211 		return engine.isPropertySetted(Properties.FONT_SIZE);
212 	}
213 
214 	public void setFontSize(java.lang.String fontSize) {
215 		engine.setProperty(Properties.FONT_SIZE, fontSize);
216 	}
217 
218 	public java.lang.Boolean getFontUnderline() {
219 		return getFontUnderline(null);
220 	}
221 
222 	/**
223 	 * See {@link #getFontUnderline() getFontUnderline()} for more details
224 	 */
225 	public java.lang.Boolean getFontUnderline(javax.faces.context.FacesContext facesContext) {
226 		return engine.getBooleanProperty(Properties.FONT_UNDERLINE, facesContext);
227 	}
228 
229 	/**
230 	 * Returns <code>true</code> if the attribute "fontUnderline" is set.
231 	 * @return <code>true</code> if the attribute is set.
232 	 */
233 	public final boolean isFontUnderlineSetted() {
234 		return engine.isPropertySetted(Properties.FONT_UNDERLINE);
235 	}
236 
237 	public void setFontUnderline(java.lang.Boolean fontUnderline) {
238 		engine.setProperty(Properties.FONT_UNDERLINE, fontUnderline);
239 	}
240 
241 	public java.lang.String getTextAlignment() {
242 		return getTextAlignment(null);
243 	}
244 
245 	/**
246 	 * See {@link #getTextAlignment() getTextAlignment()} for more details
247 	 */
248 	public java.lang.String getTextAlignment(javax.faces.context.FacesContext facesContext) {
249 		return engine.getStringProperty(Properties.TEXT_ALIGNMENT, facesContext);
250 	}
251 
252 	/**
253 	 * Returns <code>true</code> if the attribute "textAlignment" is set.
254 	 * @return <code>true</code> if the attribute is set.
255 	 */
256 	public final boolean isTextAlignmentSetted() {
257 		return engine.isPropertySetted(Properties.TEXT_ALIGNMENT);
258 	}
259 
260 	public void setTextAlignment(java.lang.String textAlignment) {
261 		engine.setProperty(Properties.TEXT_ALIGNMENT, textAlignment);
262 	}
263 
264 	public java.lang.String getAccessKey() {
265 		return getAccessKey(null);
266 	}
267 
268 	/**
269 	 * See {@link #getAccessKey() getAccessKey()} for more details
270 	 */
271 	public java.lang.String getAccessKey(javax.faces.context.FacesContext facesContext) {
272 		return engine.getStringProperty(Properties.ACCESS_KEY, facesContext);
273 	}
274 
275 	/**
276 	 * Returns <code>true</code> if the attribute "accessKey" is set.
277 	 * @return <code>true</code> if the attribute is set.
278 	 */
279 	public final boolean isAccessKeySetted() {
280 		return engine.isPropertySetted(Properties.ACCESS_KEY);
281 	}
282 
283 	public void setAccessKey(java.lang.String accessKey) {
284 		engine.setProperty(Properties.ACCESS_KEY, accessKey);
285 	}
286 
287 	public java.lang.String getFor() {
288 		return getFor(null);
289 	}
290 
291 	/**
292 	 * See {@link #getFor() getFor()} for more details
293 	 */
294 	public java.lang.String getFor(javax.faces.context.FacesContext facesContext) {
295 		return engine.getStringProperty(Properties.FOR, facesContext);
296 	}
297 
298 	/**
299 	 * Returns <code>true</code> if the attribute "for" is set.
300 	 * @return <code>true</code> if the attribute is set.
301 	 */
302 	public final boolean isForSetted() {
303 		return engine.isPropertySetted(Properties.FOR);
304 	}
305 
306 	public void setFor(java.lang.String forValue) {
307 		engine.setProperty(Properties.FOR, forValue);
308 	}
309 
310 	public java.lang.String getType() {
311 		return getType(null);
312 	}
313 
314 	/**
315 	 * See {@link #getType() getType()} for more details
316 	 */
317 	public java.lang.String getType(javax.faces.context.FacesContext facesContext) {
318 		return engine.getStringProperty(Properties.TYPE, facesContext);
319 	}
320 
321 	/**
322 	 * Returns <code>true</code> if the attribute "type" is set.
323 	 * @return <code>true</code> if the attribute is set.
324 	 */
325 	public final boolean isTypeSetted() {
326 		return engine.isPropertySetted(Properties.TYPE);
327 	}
328 
329 	public void setType(java.lang.String type) {
330 		engine.setProperty(Properties.TYPE, type);
331 	}
332 
333 	protected Set getCameliaFields() {
334 		return CAMELIA_ATTRIBUTES;
335 	}
336 
337 	protected String getCameliaValueAlias() {
338 		return CAMELIA_VALUE_ALIAS;
339 	}
340 }