View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.iterator.IMenuIterator;
4   import org.rcfaces.core.component.capability.ISelectionEventCapability;
5   import org.rcfaces.core.internal.component.Properties;
6   import java.lang.String;
7   import org.apache.commons.logging.LogFactory;
8   import org.rcfaces.core.internal.tools.MenuTools;
9   import org.rcfaces.core.component.capability.IRequiredCapability;
10  import org.rcfaces.core.component.capability.IAlternateTextCapability;
11  import org.rcfaces.core.component.capability.IEmptyMessageCapability;
12  import org.rcfaces.core.component.capability.IFocusStyleClassCapability;
13  import org.rcfaces.core.component.IMenuComponent;
14  import org.rcfaces.core.component.capability.ITextDirectionCapability;
15  import org.rcfaces.core.component.capability.IReadOnlyCapability;
16  import javax.el.ValueExpression;
17  import java.util.HashSet;
18  import org.apache.commons.logging.Log;
19  import java.util.Set;
20  import java.util.Arrays;
21  import org.rcfaces.core.component.capability.IValueChangeEventCapability;
22  import org.rcfaces.core.component.AbstractInputComponent;
23  import org.rcfaces.core.component.capability.IMenuCapability;
24  import org.rcfaces.core.component.capability.ISeverityStyleClassCapability;
25  import org.rcfaces.core.component.capability.ITextCapability;
26  
27  /**
28   * <p>The textEditorToolFolder component is a container allowing to edit text and have a specific toolBar </p>
29   * 
30   * <p>The textEditorToolFolder Component has the following capabilities :
31   * <ul>
32   * <li>IRequiredCapability</li>
33   * <li>ITextCapability</li>
34   * <li>ITextDirectionCapability</li>
35   * <li>IEmptyMessageCapability</li>
36   * <li>IReadOnlyCapability</li>
37   * <li>IValueChangeEventCapability</li>
38   * <li>IMenuCapability</li>
39   * <li>IFocusStyleClassCapability</li>
40   * <li>ISeverityStyleClassCapability</li>
41   * <li>ISelectionEventCapability</li>
42   * <li>IAlternateTextCapability</li>
43   * </ul>
44   * </p>
45   * 
46   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/TextEditorComponent.html">textEditorToolFolder</a> renderer is linked to the <a href="/jsdocs/index.html?f_textEditor.html" target="_blank">f_textEditor</a> javascript class. f_textEditor extends f_component</p>
47   * <p> Table of component style classes: </p>
48   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
49   * <tbody>
50   * 
51   * <tr style="text-align:left">
52   * <th  width="33%">Style Name</th>
53   * <th width="50%">Description</th>
54   * </tr>
55   * 
56   * <tr  style="text-align:left">
57   * <td width="33%">f_textEditor</td>
58   * <td width="50%">Defines styles for the wrapper DIV element</td>
59   * </tr>
60   * </tbody>
61   * </table>
62   */
63  public class TextEditorComponent extends AbstractInputComponent implements 
64  	IRequiredCapability,
65  	ITextCapability,
66  	ITextDirectionCapability,
67  	IEmptyMessageCapability,
68  	IReadOnlyCapability,
69  	IValueChangeEventCapability,
70  	IMenuCapability,
71  	IFocusStyleClassCapability,
72  	ISeverityStyleClassCapability,
73  	ISelectionEventCapability,
74  	IAlternateTextCapability {
75  
76  	private static final Log LOG = LogFactory.getLog(TextEditorComponent.class);
77  
78  	public static final String COMPONENT_TYPE="org.rcfaces.core.textEditor";
79  
80  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractInputComponent.CAMELIA_ATTRIBUTES);
81  	static {
82  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"focusStyleClass","text","fatalStyleClass","styleClass","textDirection","emptyMessage","selectionListener","valueChangeListener","readOnly","errorStyleClass","warnStyleClass","alternateText","infoStyleClass","valueMimeType","required"}));
83  	}
84  	protected static final String CAMELIA_VALUE_ALIAS="text";
85  
86  	public TextEditorComponent() {
87  		setRendererType(COMPONENT_TYPE);
88  	}
89  
90  	public TextEditorComponent(String componentId) {
91  		this();
92  		setId(componentId);
93  	}
94  
95  	public java.lang.String getText() {
96  		return getText(null);
97  	}
98  
99  	/**
100 	 * See {@link #getText() getText()} for more details
101 	 */
102 	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
103 		return org.rcfaces.core.internal.tools.ValuesTools.valueToString(this, facesContext);
104 	}
105 
106 	/**
107 	 * Returns <code>true</code> if the attribute "text" is set.
108 	 * @return <code>true</code> if the attribute is set.
109 	 */
110 	public final boolean isTextSetted() {
111 		return engine.isPropertySetted(Properties.TEXT);
112 	}
113 
114 	public void setText(java.lang.String text) {
115 		if (org.rcfaces.core.internal.listener.CameliaPhaseListener.isApplyingRequestValues()) {
116 			setSubmittedExternalValue(text);
117 		} else {
118 			setValue(text);
119 		}
120 	}
121 
122 	public int getTextDirection() {
123 		return getTextDirection(null);
124 	}
125 
126 	/**
127 	 * See {@link #getTextDirection() getTextDirection()} for more details
128 	 */
129 	public int getTextDirection(javax.faces.context.FacesContext facesContext) {
130 		return engine.getIntProperty(Properties.TEXT_DIRECTION,0, facesContext);
131 	}
132 
133 	/**
134 	 * Returns <code>true</code> if the attribute "textDirection" is set.
135 	 * @return <code>true</code> if the attribute is set.
136 	 */
137 	public final boolean isTextDirectionSetted() {
138 		return engine.isPropertySetted(Properties.TEXT_DIRECTION);
139 	}
140 
141 	public void setTextDirection(int textDirection) {
142 		engine.setProperty(Properties.TEXT_DIRECTION, textDirection);
143 	}
144 
145 	public java.lang.String getEmptyMessage() {
146 		return getEmptyMessage(null);
147 	}
148 
149 	/**
150 	 * See {@link #getEmptyMessage() getEmptyMessage()} for more details
151 	 */
152 	public java.lang.String getEmptyMessage(javax.faces.context.FacesContext facesContext) {
153 		return engine.getStringProperty(Properties.EMPTY_MESSAGE, facesContext);
154 	}
155 
156 	/**
157 	 * Returns <code>true</code> if the attribute "emptyMessage" is set.
158 	 * @return <code>true</code> if the attribute is set.
159 	 */
160 	public final boolean isEmptyMessageSetted() {
161 		return engine.isPropertySetted(Properties.EMPTY_MESSAGE);
162 	}
163 
164 	public void setEmptyMessage(java.lang.String emptyMessage) {
165 		engine.setProperty(Properties.EMPTY_MESSAGE, emptyMessage);
166 	}
167 
168 	public boolean isReadOnly() {
169 		return isReadOnly(null);
170 	}
171 
172 	/**
173 	 * See {@link #isReadOnly() isReadOnly()} for more details
174 	 */
175 	public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
176 		return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
177 	}
178 
179 	/**
180 	 * Returns <code>true</code> if the attribute "readOnly" is set.
181 	 * @return <code>true</code> if the attribute is set.
182 	 */
183 	public final boolean isReadOnlySetted() {
184 		return engine.isPropertySetted(Properties.READ_ONLY);
185 	}
186 
187 	public void setReadOnly(boolean readOnly) {
188 		engine.setProperty(Properties.READ_ONLY, readOnly);
189 	}
190 
191 	public final void addValueChangeListener(javax.faces.event.ValueChangeListener listener) {
192 		addFacesListener(listener);
193 	}
194 
195 	public final void removeValueChangeListener(javax.faces.event.ValueChangeListener listener) {
196 		removeFacesListener(listener);
197 	}
198 
199 	public final javax.faces.event.FacesListener [] listValueChangeListeners() {
200 		return getFacesListeners(javax.faces.event.ValueChangeListener.class);
201 	}
202 
203 	public IMenuComponent getMenu() {
204 
205 
206 		return MenuTools.getMenu(this);
207 		
208 	}
209 
210 	public IMenuComponent getMenu(String menuId) {
211 
212 
213 		return MenuTools.getMenu(this, menuId);
214 		
215 	}
216 
217 	public IMenuIterator listMenus() {
218 
219 
220 		return MenuTools.listMenus(this);
221 		
222 	}
223 
224 	public java.lang.String getFocusStyleClass() {
225 		return getFocusStyleClass(null);
226 	}
227 
228 	/**
229 	 * See {@link #getFocusStyleClass() getFocusStyleClass()} for more details
230 	 */
231 	public java.lang.String getFocusStyleClass(javax.faces.context.FacesContext facesContext) {
232 		return engine.getStringProperty(Properties.FOCUS_STYLE_CLASS, facesContext);
233 	}
234 
235 	/**
236 	 * Returns <code>true</code> if the attribute "focusStyleClass" is set.
237 	 * @return <code>true</code> if the attribute is set.
238 	 */
239 	public final boolean isFocusStyleClassSetted() {
240 		return engine.isPropertySetted(Properties.FOCUS_STYLE_CLASS);
241 	}
242 
243 	public void setFocusStyleClass(java.lang.String focusStyleClass) {
244 		engine.setProperty(Properties.FOCUS_STYLE_CLASS, focusStyleClass);
245 	}
246 
247 	public java.lang.String getErrorStyleClass() {
248 		return getErrorStyleClass(null);
249 	}
250 
251 	/**
252 	 * See {@link #getErrorStyleClass() getErrorStyleClass()} for more details
253 	 */
254 	public java.lang.String getErrorStyleClass(javax.faces.context.FacesContext facesContext) {
255 		return engine.getStringProperty(Properties.ERROR_STYLE_CLASS, facesContext);
256 	}
257 
258 	/**
259 	 * Returns <code>true</code> if the attribute "errorStyleClass" is set.
260 	 * @return <code>true</code> if the attribute is set.
261 	 */
262 	public final boolean isErrorStyleClassSetted() {
263 		return engine.isPropertySetted(Properties.ERROR_STYLE_CLASS);
264 	}
265 
266 	public void setErrorStyleClass(java.lang.String errorStyleClass) {
267 		engine.setProperty(Properties.ERROR_STYLE_CLASS, errorStyleClass);
268 	}
269 
270 	public java.lang.String getFatalStyleClass() {
271 		return getFatalStyleClass(null);
272 	}
273 
274 	/**
275 	 * See {@link #getFatalStyleClass() getFatalStyleClass()} for more details
276 	 */
277 	public java.lang.String getFatalStyleClass(javax.faces.context.FacesContext facesContext) {
278 		return engine.getStringProperty(Properties.FATAL_STYLE_CLASS, facesContext);
279 	}
280 
281 	/**
282 	 * Returns <code>true</code> if the attribute "fatalStyleClass" is set.
283 	 * @return <code>true</code> if the attribute is set.
284 	 */
285 	public final boolean isFatalStyleClassSetted() {
286 		return engine.isPropertySetted(Properties.FATAL_STYLE_CLASS);
287 	}
288 
289 	public void setFatalStyleClass(java.lang.String fatalStyleClass) {
290 		engine.setProperty(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
291 	}
292 
293 	public java.lang.String getInfoStyleClass() {
294 		return getInfoStyleClass(null);
295 	}
296 
297 	/**
298 	 * See {@link #getInfoStyleClass() getInfoStyleClass()} for more details
299 	 */
300 	public java.lang.String getInfoStyleClass(javax.faces.context.FacesContext facesContext) {
301 		return engine.getStringProperty(Properties.INFO_STYLE_CLASS, facesContext);
302 	}
303 
304 	/**
305 	 * Returns <code>true</code> if the attribute "infoStyleClass" is set.
306 	 * @return <code>true</code> if the attribute is set.
307 	 */
308 	public final boolean isInfoStyleClassSetted() {
309 		return engine.isPropertySetted(Properties.INFO_STYLE_CLASS);
310 	}
311 
312 	public void setInfoStyleClass(java.lang.String infoStyleClass) {
313 		engine.setProperty(Properties.INFO_STYLE_CLASS, infoStyleClass);
314 	}
315 
316 	public java.lang.String getWarnStyleClass() {
317 		return getWarnStyleClass(null);
318 	}
319 
320 	/**
321 	 * See {@link #getWarnStyleClass() getWarnStyleClass()} for more details
322 	 */
323 	public java.lang.String getWarnStyleClass(javax.faces.context.FacesContext facesContext) {
324 		return engine.getStringProperty(Properties.WARN_STYLE_CLASS, facesContext);
325 	}
326 
327 	/**
328 	 * Returns <code>true</code> if the attribute "warnStyleClass" is set.
329 	 * @return <code>true</code> if the attribute is set.
330 	 */
331 	public final boolean isWarnStyleClassSetted() {
332 		return engine.isPropertySetted(Properties.WARN_STYLE_CLASS);
333 	}
334 
335 	public void setWarnStyleClass(java.lang.String warnStyleClass) {
336 		engine.setProperty(Properties.WARN_STYLE_CLASS, warnStyleClass);
337 	}
338 
339 	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
340 		addFacesListener(listener);
341 	}
342 
343 	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
344 		removeFacesListener(listener);
345 	}
346 
347 	public final javax.faces.event.FacesListener [] listSelectionListeners() {
348 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
349 	}
350 
351 	public java.lang.String getAlternateText() {
352 		return getAlternateText(null);
353 	}
354 
355 	/**
356 	 * See {@link #getAlternateText() getAlternateText()} for more details
357 	 */
358 	public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
359 		return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
360 	}
361 
362 	/**
363 	 * Returns <code>true</code> if the attribute "alternateText" is set.
364 	 * @return <code>true</code> if the attribute is set.
365 	 */
366 	public final boolean isAlternateTextSetted() {
367 		return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
368 	}
369 
370 	public void setAlternateText(java.lang.String alternateText) {
371 		engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
372 	}
373 
374 	public String getValueMimeType() {
375 		return getValueMimeType(null);
376 	}
377 
378 	public String getValueMimeType(javax.faces.context.FacesContext facesContext) {
379 		return engine.getStringProperty(Properties.VALUE_MIME_TYPE, facesContext);
380 	}
381 
382 	public void setValueMimeType(String valueMimeType) {
383 		engine.setProperty(Properties.VALUE_MIME_TYPE, valueMimeType);
384 	}
385 
386 	/**
387 	 * Returns <code>true</code> if the attribute "valueMimeType" is set.
388 	 * @return <code>true</code> if the attribute is set.
389 	 */
390 	public boolean isValueMimeTypeSetted() {
391 		return engine.isPropertySetted(Properties.VALUE_MIME_TYPE);
392 	}
393 
394 	protected Set getCameliaFields() {
395 		return CAMELIA_ATTRIBUTES;
396 	}
397 
398 	protected String getCameliaValueAlias() {
399 		return CAMELIA_VALUE_ALIAS;
400 	}
401 }