View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.capability.IPositionCapability;
4   import org.rcfaces.core.component.capability.IVisibilityCapability;
5   import org.rcfaces.core.internal.component.Properties;
6   import org.rcfaces.core.component.capability.ILayoutPositionCapability;
7   import java.lang.String;
8   import org.rcfaces.core.component.capability.IForegroundBackgroundColorCapability;
9   import org.rcfaces.core.component.capability.ILookAndFeelCapability;
10  import org.apache.commons.logging.LogFactory;
11  import org.rcfaces.core.component.capability.IHiddenModeCapability;
12  import javax.faces.context.FacesContext;
13  import org.rcfaces.core.internal.tools.MarginTools;
14  import org.rcfaces.core.internal.converter.AlignmentNormalizer;
15  import org.rcfaces.core.component.capability.IAlignmentCapability;
16  import org.rcfaces.core.internal.component.CameliaBaseComponent;
17  import javax.el.ValueExpression;
18  import org.rcfaces.core.component.capability.ISizeCapability;
19  import java.util.HashSet;
20  import org.apache.commons.logging.Log;
21  import java.util.Set;
22  import java.util.Arrays;
23  import org.rcfaces.core.internal.converter.HiddenModeConverter;
24  import org.rcfaces.core.component.capability.IOrientationCapability;
25  import org.rcfaces.core.component.capability.IMarginCapability;
26  
27  /**
28   * <p>The ruler Component is the &lt;HR&gt; HTML equivalent.</p>
29   * <p>It is used often when simple HTML is not desirable : for example if a part of a page is loaded via AJAX it might be easier to have only a jsf tree memory represantation.</p>
30   * <p>The ruler Component has the following capability :
31   * <ul>
32   * <li>IPositionCapability</li>
33   * <li>IMarginCapability</li>
34   * <li>ISizeCapability</li>
35   * <li>IVisibilityCapability</li>
36   * <li>IHiddenModeCapability</li>
37   * <li>ILookAndFeelCapability</li>
38   * <li>IOrientationCapability</li>
39   * <li>IForegroundBackgroundColorCapability</li>
40   * <li>IAlignmentCapability</li>
41   * </ul>
42   * </p>
43   * 
44   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/RulerComponent.html">ruler</a> renderer is linked to the <a href="/jsdocs/index.html?f_ruler.html" target="_blank">f_ruler</a> javascript class. f_ruler extends f_component</p>
45   * 
46   * <p> Table of component style classes: </p>
47   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
48   * <tbody>
49   * 
50   * <tr style="text-align:left">
51   * <th  width="33%">Style Name</th>
52   * <th width="50%">Description</th>
53   * </tr>
54   * 
55   * <tr  style="text-align:left">
56   * <td width="33%">f_ruler</td>
57   * <td width="50%">Defines styles for the HR element</td>
58   * </tr>
59   * 
60   * </tbody>
61   * </table>
62   */
63  public class RulerComponent extends CameliaBaseComponent implements 
64  	IPositionCapability,
65  	ILayoutPositionCapability,
66  	IMarginCapability,
67  	ISizeCapability,
68  	IVisibilityCapability,
69  	IHiddenModeCapability,
70  	ILookAndFeelCapability,
71  	IOrientationCapability,
72  	IForegroundBackgroundColorCapability,
73  	IAlignmentCapability {
74  
75  	private static final Log LOG = LogFactory.getLog(RulerComponent.class);
76  
77  	public static final String COMPONENT_TYPE="org.rcfaces.core.ruler";
78  
79  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(CameliaBaseComponent.CAMELIA_ATTRIBUTES);
80  	static {
81  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"alignment","orientation","lookId","visible","backgroundColor","marginLeft","marginTop","marginRight","width","rendered","marginBottom","height","hiddenMode","bottom","left","right","foregroundColor","y","margins","x","top"}));
82  	}
83  
84  	public RulerComponent() {
85  		setRendererType(COMPONENT_TYPE);
86  	}
87  
88  	public RulerComponent(String componentId) {
89  		this();
90  		setId(componentId);
91  	}
92  
93  	public void setMargins(String margins) {
94  
95  
96  				MarginTools.setMargins(this, margins);
97  			
98  	}
99  
100 	public void setHiddenMode(String hiddenMode) {
101 
102 
103 			setHiddenMode(((Integer)HiddenModeConverter.SINGLETON.getAsObject(null, this, hiddenMode)).intValue());
104 		
105 	}
106 
107 	public Boolean getVisibleState(FacesContext facesContext) {
108 
109 
110 			if (engine.isPropertySetted(Properties.VISIBLE)==false) {
111 				return null;
112 			}
113 			
114 			return Boolean.valueOf(isVisible(facesContext));
115 		
116 	}
117 
118 	public java.lang.String getX() {
119 		return getX(null);
120 	}
121 
122 	/**
123 	 * See {@link #getX() getX()} for more details
124 	 */
125 	public java.lang.String getX(javax.faces.context.FacesContext facesContext) {
126 		return engine.getStringProperty(Properties.X, facesContext);
127 	}
128 
129 	/**
130 	 * Returns <code>true</code> if the attribute "x" is set.
131 	 * @return <code>true</code> if the attribute is set.
132 	 */
133 	public final boolean isXSetted() {
134 		return engine.isPropertySetted(Properties.X);
135 	}
136 
137 	public void setX(java.lang.String x) {
138 		engine.setProperty(Properties.X, x);
139 	}
140 
141 	public java.lang.String getY() {
142 		return getY(null);
143 	}
144 
145 	/**
146 	 * See {@link #getY() getY()} for more details
147 	 */
148 	public java.lang.String getY(javax.faces.context.FacesContext facesContext) {
149 		return engine.getStringProperty(Properties.Y, facesContext);
150 	}
151 
152 	/**
153 	 * Returns <code>true</code> if the attribute "y" is set.
154 	 * @return <code>true</code> if the attribute is set.
155 	 */
156 	public final boolean isYSetted() {
157 		return engine.isPropertySetted(Properties.Y);
158 	}
159 
160 	public void setY(java.lang.String y) {
161 		engine.setProperty(Properties.Y, y);
162 	}
163 
164 	public int getBottom() {
165 		return getBottom(null);
166 	}
167 
168 	/**
169 	 * See {@link #getBottom() getBottom()} for more details
170 	 */
171 	public int getBottom(javax.faces.context.FacesContext facesContext) {
172 		return engine.getIntProperty(Properties.BOTTOM,0, facesContext);
173 	}
174 
175 	/**
176 	 * Returns <code>true</code> if the attribute "bottom" is set.
177 	 * @return <code>true</code> if the attribute is set.
178 	 */
179 	public final boolean isBottomSetted() {
180 		return engine.isPropertySetted(Properties.BOTTOM);
181 	}
182 
183 	public void setBottom(int bottom) {
184 		engine.setProperty(Properties.BOTTOM, bottom);
185 	}
186 
187 	public int getLeft() {
188 		return getLeft(null);
189 	}
190 
191 	/**
192 	 * See {@link #getLeft() getLeft()} for more details
193 	 */
194 	public int getLeft(javax.faces.context.FacesContext facesContext) {
195 		return engine.getIntProperty(Properties.LEFT,0, facesContext);
196 	}
197 
198 	/**
199 	 * Returns <code>true</code> if the attribute "left" is set.
200 	 * @return <code>true</code> if the attribute is set.
201 	 */
202 	public final boolean isLeftSetted() {
203 		return engine.isPropertySetted(Properties.LEFT);
204 	}
205 
206 	public void setLeft(int left) {
207 		engine.setProperty(Properties.LEFT, left);
208 	}
209 
210 	public int getRight() {
211 		return getRight(null);
212 	}
213 
214 	/**
215 	 * See {@link #getRight() getRight()} for more details
216 	 */
217 	public int getRight(javax.faces.context.FacesContext facesContext) {
218 		return engine.getIntProperty(Properties.RIGHT,0, facesContext);
219 	}
220 
221 	/**
222 	 * Returns <code>true</code> if the attribute "right" is set.
223 	 * @return <code>true</code> if the attribute is set.
224 	 */
225 	public final boolean isRightSetted() {
226 		return engine.isPropertySetted(Properties.RIGHT);
227 	}
228 
229 	public void setRight(int right) {
230 		engine.setProperty(Properties.RIGHT, right);
231 	}
232 
233 	public int getTop() {
234 		return getTop(null);
235 	}
236 
237 	/**
238 	 * See {@link #getTop() getTop()} for more details
239 	 */
240 	public int getTop(javax.faces.context.FacesContext facesContext) {
241 		return engine.getIntProperty(Properties.TOP,0, facesContext);
242 	}
243 
244 	/**
245 	 * Returns <code>true</code> if the attribute "top" is set.
246 	 * @return <code>true</code> if the attribute is set.
247 	 */
248 	public final boolean isTopSetted() {
249 		return engine.isPropertySetted(Properties.TOP);
250 	}
251 
252 	public void setTop(int top) {
253 		engine.setProperty(Properties.TOP, top);
254 	}
255 
256 	public java.lang.String getMarginBottom() {
257 		return getMarginBottom(null);
258 	}
259 
260 	/**
261 	 * See {@link #getMarginBottom() getMarginBottom()} for more details
262 	 */
263 	public java.lang.String getMarginBottom(javax.faces.context.FacesContext facesContext) {
264 		return engine.getStringProperty(Properties.MARGIN_BOTTOM, facesContext);
265 	}
266 
267 	/**
268 	 * Returns <code>true</code> if the attribute "marginBottom" is set.
269 	 * @return <code>true</code> if the attribute is set.
270 	 */
271 	public final boolean isMarginBottomSetted() {
272 		return engine.isPropertySetted(Properties.MARGIN_BOTTOM);
273 	}
274 
275 	public void setMarginBottom(java.lang.String marginBottom) {
276 		engine.setProperty(Properties.MARGIN_BOTTOM, marginBottom);
277 	}
278 
279 	public java.lang.String getMarginLeft() {
280 		return getMarginLeft(null);
281 	}
282 
283 	/**
284 	 * See {@link #getMarginLeft() getMarginLeft()} for more details
285 	 */
286 	public java.lang.String getMarginLeft(javax.faces.context.FacesContext facesContext) {
287 		return engine.getStringProperty(Properties.MARGIN_LEFT, facesContext);
288 	}
289 
290 	/**
291 	 * Returns <code>true</code> if the attribute "marginLeft" is set.
292 	 * @return <code>true</code> if the attribute is set.
293 	 */
294 	public final boolean isMarginLeftSetted() {
295 		return engine.isPropertySetted(Properties.MARGIN_LEFT);
296 	}
297 
298 	public void setMarginLeft(java.lang.String marginLeft) {
299 		engine.setProperty(Properties.MARGIN_LEFT, marginLeft);
300 	}
301 
302 	public java.lang.String getMarginRight() {
303 		return getMarginRight(null);
304 	}
305 
306 	/**
307 	 * See {@link #getMarginRight() getMarginRight()} for more details
308 	 */
309 	public java.lang.String getMarginRight(javax.faces.context.FacesContext facesContext) {
310 		return engine.getStringProperty(Properties.MARGIN_RIGHT, facesContext);
311 	}
312 
313 	/**
314 	 * Returns <code>true</code> if the attribute "marginRight" is set.
315 	 * @return <code>true</code> if the attribute is set.
316 	 */
317 	public final boolean isMarginRightSetted() {
318 		return engine.isPropertySetted(Properties.MARGIN_RIGHT);
319 	}
320 
321 	public void setMarginRight(java.lang.String marginRight) {
322 		engine.setProperty(Properties.MARGIN_RIGHT, marginRight);
323 	}
324 
325 	public java.lang.String getMarginTop() {
326 		return getMarginTop(null);
327 	}
328 
329 	/**
330 	 * See {@link #getMarginTop() getMarginTop()} for more details
331 	 */
332 	public java.lang.String getMarginTop(javax.faces.context.FacesContext facesContext) {
333 		return engine.getStringProperty(Properties.MARGIN_TOP, facesContext);
334 	}
335 
336 	/**
337 	 * Returns <code>true</code> if the attribute "marginTop" is set.
338 	 * @return <code>true</code> if the attribute is set.
339 	 */
340 	public final boolean isMarginTopSetted() {
341 		return engine.isPropertySetted(Properties.MARGIN_TOP);
342 	}
343 
344 	public void setMarginTop(java.lang.String marginTop) {
345 		engine.setProperty(Properties.MARGIN_TOP, marginTop);
346 	}
347 
348 	public java.lang.String getWidth() {
349 		return getWidth(null);
350 	}
351 
352 	/**
353 	 * See {@link #getWidth() getWidth()} for more details
354 	 */
355 	public java.lang.String getWidth(javax.faces.context.FacesContext facesContext) {
356 		return engine.getStringProperty(Properties.WIDTH, facesContext);
357 	}
358 
359 	/**
360 	 * Returns <code>true</code> if the attribute "width" is set.
361 	 * @return <code>true</code> if the attribute is set.
362 	 */
363 	public final boolean isWidthSetted() {
364 		return engine.isPropertySetted(Properties.WIDTH);
365 	}
366 
367 	public void setWidth(java.lang.String width) {
368 		engine.setProperty(Properties.WIDTH, width);
369 	}
370 
371 	public java.lang.String getHeight() {
372 		return getHeight(null);
373 	}
374 
375 	/**
376 	 * See {@link #getHeight() getHeight()} for more details
377 	 */
378 	public java.lang.String getHeight(javax.faces.context.FacesContext facesContext) {
379 		return engine.getStringProperty(Properties.HEIGHT, facesContext);
380 	}
381 
382 	/**
383 	 * Returns <code>true</code> if the attribute "height" is set.
384 	 * @return <code>true</code> if the attribute is set.
385 	 */
386 	public final boolean isHeightSetted() {
387 		return engine.isPropertySetted(Properties.HEIGHT);
388 	}
389 
390 	public void setHeight(java.lang.String height) {
391 		engine.setProperty(Properties.HEIGHT, height);
392 	}
393 
394 	public boolean isVisible() {
395 		return isVisible(null);
396 	}
397 
398 	/**
399 	 * See {@link #isVisible() isVisible()} for more details
400 	 */
401 	public boolean isVisible(javax.faces.context.FacesContext facesContext) {
402 		return engine.getBoolProperty(Properties.VISIBLE, true, facesContext);
403 	}
404 
405 	/**
406 	 * Returns <code>true</code> if the attribute "visible" is set.
407 	 * @return <code>true</code> if the attribute is set.
408 	 */
409 	public final boolean isVisibleSetted() {
410 		return engine.isPropertySetted(Properties.VISIBLE);
411 	}
412 
413 	public void setVisible(boolean visible) {
414 		engine.setProperty(Properties.VISIBLE, visible);
415 	}
416 
417 	public Boolean getVisibleState() {
418 
419 
420 			return getVisibleState(null);
421 		
422 	}
423 
424 	public int getHiddenMode() {
425 		return getHiddenMode(null);
426 	}
427 
428 	/**
429 	 * See {@link #getHiddenMode() getHiddenMode()} for more details
430 	 */
431 	public int getHiddenMode(javax.faces.context.FacesContext facesContext) {
432 		return engine.getIntProperty(Properties.HIDDEN_MODE,IHiddenModeCapability.DEFAULT_HIDDEN_MODE, facesContext);
433 	}
434 
435 	/**
436 	 * Returns <code>true</code> if the attribute "hiddenMode" is set.
437 	 * @return <code>true</code> if the attribute is set.
438 	 */
439 	public final boolean isHiddenModeSetted() {
440 		return engine.isPropertySetted(Properties.HIDDEN_MODE);
441 	}
442 
443 	public void setHiddenMode(int hiddenMode) {
444 		engine.setProperty(Properties.HIDDEN_MODE, hiddenMode);
445 	}
446 
447 	public java.lang.String getLookId() {
448 		return getLookId(null);
449 	}
450 
451 	/**
452 	 * See {@link #getLookId() getLookId()} for more details
453 	 */
454 	public java.lang.String getLookId(javax.faces.context.FacesContext facesContext) {
455 		return engine.getStringProperty(Properties.LOOK_ID, facesContext);
456 	}
457 
458 	/**
459 	 * Returns <code>true</code> if the attribute "lookId" is set.
460 	 * @return <code>true</code> if the attribute is set.
461 	 */
462 	public final boolean isLookIdSetted() {
463 		return engine.isPropertySetted(Properties.LOOK_ID);
464 	}
465 
466 	public void setLookId(java.lang.String lookId) {
467 		engine.setProperty(Properties.LOOK_ID, lookId);
468 	}
469 
470 	public java.lang.String getOrientation() {
471 		return getOrientation(null);
472 	}
473 
474 	/**
475 	 * See {@link #getOrientation() getOrientation()} for more details
476 	 */
477 	public java.lang.String getOrientation(javax.faces.context.FacesContext facesContext) {
478 		return engine.getStringProperty(Properties.ORIENTATION, facesContext);
479 	}
480 
481 	/**
482 	 * Returns <code>true</code> if the attribute "orientation" is set.
483 	 * @return <code>true</code> if the attribute is set.
484 	 */
485 	public final boolean isOrientationSetted() {
486 		return engine.isPropertySetted(Properties.ORIENTATION);
487 	}
488 
489 	public void setOrientation(java.lang.String orientation) {
490 		engine.setProperty(Properties.ORIENTATION, orientation);
491 	}
492 
493 	public java.lang.String getBackgroundColor() {
494 		return getBackgroundColor(null);
495 	}
496 
497 	/**
498 	 * See {@link #getBackgroundColor() getBackgroundColor()} for more details
499 	 */
500 	public java.lang.String getBackgroundColor(javax.faces.context.FacesContext facesContext) {
501 		return engine.getStringProperty(Properties.BACKGROUND_COLOR, facesContext);
502 	}
503 
504 	/**
505 	 * Returns <code>true</code> if the attribute "backgroundColor" is set.
506 	 * @return <code>true</code> if the attribute is set.
507 	 */
508 	public final boolean isBackgroundColorSetted() {
509 		return engine.isPropertySetted(Properties.BACKGROUND_COLOR);
510 	}
511 
512 	public void setBackgroundColor(java.lang.String backgroundColor) {
513 		engine.setProperty(Properties.BACKGROUND_COLOR, backgroundColor);
514 	}
515 
516 	public java.lang.String getForegroundColor() {
517 		return getForegroundColor(null);
518 	}
519 
520 	/**
521 	 * See {@link #getForegroundColor() getForegroundColor()} for more details
522 	 */
523 	public java.lang.String getForegroundColor(javax.faces.context.FacesContext facesContext) {
524 		return engine.getStringProperty(Properties.FOREGROUND_COLOR, facesContext);
525 	}
526 
527 	/**
528 	 * Returns <code>true</code> if the attribute "foregroundColor" is set.
529 	 * @return <code>true</code> if the attribute is set.
530 	 */
531 	public final boolean isForegroundColorSetted() {
532 		return engine.isPropertySetted(Properties.FOREGROUND_COLOR);
533 	}
534 
535 	public void setForegroundColor(java.lang.String foregroundColor) {
536 		engine.setProperty(Properties.FOREGROUND_COLOR, foregroundColor);
537 	}
538 
539 	public java.lang.String getAlignment() {
540 		return getAlignment(null);
541 	}
542 
543 	/**
544 	 * See {@link #getAlignment() getAlignment()} for more details
545 	 */
546 	public java.lang.String getAlignment(javax.faces.context.FacesContext facesContext) {
547 		return engine.getStringProperty(Properties.ALIGNMENT, facesContext);
548 	}
549 
550 	/**
551 	 * Returns <code>true</code> if the attribute "alignment" is set.
552 	 * @return <code>true</code> if the attribute is set.
553 	 */
554 	public final boolean isAlignmentSetted() {
555 		return engine.isPropertySetted(Properties.ALIGNMENT);
556 	}
557 
558 	public void setAlignment(String alignment) {
559 
560 
561 			engine.setProperty(Properties.ALIGNMENT, AlignmentNormalizer.normalize(alignment));
562     	
563 	}
564 
565 	protected Set getCameliaFields() {
566 		return CAMELIA_ATTRIBUTES;
567 	}
568 }