View Javadoc

1   package org.rcfaces.core.component;
2   
3   import javax.faces.component.NamingContainer;
4   import org.rcfaces.core.internal.component.Properties;
5   import org.apache.commons.logging.LogFactory;
6   import org.rcfaces.core.component.ToolBarComponent;
7   import org.rcfaces.core.component.capability.IReadOnlyCapability;
8   import org.rcfaces.core.internal.converter.InputTypeConverter;
9   import org.apache.commons.logging.Log;
10  import java.util.Set;
11  import org.rcfaces.core.component.capability.IInitEventCapability;
12  import org.rcfaces.core.component.capability.IDoubleClickEventCapability;
13  import org.rcfaces.core.internal.tools.CheckTools;
14  import org.rcfaces.core.component.capability.ISelectionEventCapability;
15  import org.rcfaces.core.component.capability.ICheckedValuesCapability;
16  import java.lang.String;
17  import org.rcfaces.core.component.capability.IHorizontalTextPositionCapability;
18  import org.rcfaces.core.component.capability.IBorderTypeCapability;
19  import org.rcfaces.core.component.capability.ICheckEventCapability;
20  import javax.faces.convert.Converter;
21  import org.rcfaces.core.component.capability.IMouseEventCapability;
22  import javax.el.ValueExpression;
23  import org.rcfaces.core.component.capability.ITextPositionCapability;
24  import org.rcfaces.core.component.capability.IDisabledCapability;
25  import java.util.HashSet;
26  import org.rcfaces.core.internal.tools.ToolBarTools;
27  import java.util.Arrays;
28  import org.rcfaces.core.internal.converter.HiddenModeConverter;
29  import org.rcfaces.core.component.AbstractInputComponent;
30  import org.rcfaces.core.internal.converter.TextPositionConverter;
31  
32  public class ItemsListComponent extends AbstractInputComponent implements 
33  	IInitEventCapability,
34  	IMouseEventCapability,
35  	IDoubleClickEventCapability,
36  	ITextPositionCapability,
37  	IBorderTypeCapability,
38  	ISelectionEventCapability,
39  	ICheckEventCapability,
40  	ICheckedValuesCapability,
41  	IDisabledCapability,
42  	IReadOnlyCapability,
43  	NamingContainer {
44  
45  	private static final Log LOG = LogFactory.getLog(ItemsListComponent.class);
46  
47  	public static final String COMPONENT_TYPE="org.rcfaces.core.itemsList";
48  
49  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractInputComponent.CAMELIA_ATTRIBUTES);
50  	static {
51  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"checkListener","defaultHoverImageURL","defaultItemLookId","defaultDisabledImageURL","itemHiddenMode","defaultItemGroupName","textPosition","borderType","defaultImageURL","doubleClickListener","initListener","checkedValues","selectionListener","readOnly","mouseOverListener","defaultItemInputType","defaultSelectedImageURL","itemPadding","defaultItemStyleClass","mouseOutListener","disabled"}));
52  	}
53  
54  	public ItemsListComponent() {
55  		setRendererType(COMPONENT_TYPE);
56  	}
57  
58  	public ItemsListComponent(String componentId) {
59  		this();
60  		setId(componentId);
61  	}
62  
63  	public void setItemHiddenMode(String hiddenMode) {
64  
65  
66  			setItemHiddenMode(((Integer)HiddenModeConverter.SINGLETON.getAsObject(null, this, hiddenMode)).intValue());
67  		
68  	}
69  
70  	protected Converter getTextPositionConverter() {
71  
72  
73  				return TextPositionConverter.SINGLETON;
74  			
75  	}
76  
77  	public void setDefaultItemInputType(String inputType) {
78  
79  
80  			setDefaultItemInputType(((Integer)InputTypeConverter.SINGLETON.getAsObject(null, this, inputType)).intValue());
81  		
82  	}
83  
84  	public void setTextPosition(String textPosition) {
85  
86  
87  			setTextPosition(((Integer)getTextPositionConverter().getAsObject(null, this, textPosition)).intValue());
88  		
89  	}
90  
91  	public ToolBarComponent getToolBar() {
92  
93  
94  		return (ToolBarComponent)getParent();
95  		
96  	}
97  
98  	public final void addDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
99  		addFacesListener(listener);
100 	}
101 
102 	public final void removeDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
103 		removeFacesListener(listener);
104 	}
105 
106 	public final javax.faces.event.FacesListener [] listDoubleClickListeners() {
107 		return getFacesListeners(org.rcfaces.core.event.IDoubleClickListener.class);
108 	}
109 
110 	public int getTextPosition() {
111 		return getTextPosition(null);
112 	}
113 
114 	/**
115 	 * See {@link #getTextPosition() getTextPosition()} for more details
116 	 */
117 	public int getTextPosition(javax.faces.context.FacesContext facesContext) {
118 		return engine.getIntProperty(Properties.TEXT_POSITION,IHorizontalTextPositionCapability.DEFAULT_POSITION, facesContext);
119 	}
120 
121 	/**
122 	 * Returns <code>true</code> if the attribute "textPosition" is set.
123 	 * @return <code>true</code> if the attribute is set.
124 	 */
125 	public final boolean isTextPositionSetted() {
126 		return engine.isPropertySetted(Properties.TEXT_POSITION);
127 	}
128 
129 	public void setTextPosition(int textPosition) {
130 		engine.setProperty(Properties.TEXT_POSITION, textPosition);
131 	}
132 
133 	public java.lang.String getBorderType() {
134 		return getBorderType(null);
135 	}
136 
137 	/**
138 	 * See {@link #getBorderType() getBorderType()} for more details
139 	 */
140 	public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
141 		return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
142 	}
143 
144 	/**
145 	 * Returns <code>true</code> if the attribute "borderType" is set.
146 	 * @return <code>true</code> if the attribute is set.
147 	 */
148 	public final boolean isBorderTypeSetted() {
149 		return engine.isPropertySetted(Properties.BORDER_TYPE);
150 	}
151 
152 	public void setBorderType(java.lang.String borderType) {
153 		engine.setProperty(Properties.BORDER_TYPE, borderType);
154 	}
155 
156 	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
157 		addFacesListener(listener);
158 	}
159 
160 	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
161 		removeFacesListener(listener);
162 	}
163 
164 	public final javax.faces.event.FacesListener [] listSelectionListeners() {
165 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
166 	}
167 
168 	public final void addCheckListener(org.rcfaces.core.event.ICheckListener listener) {
169 		addFacesListener(listener);
170 	}
171 
172 	public final void removeCheckListener(org.rcfaces.core.event.ICheckListener listener) {
173 		removeFacesListener(listener);
174 	}
175 
176 	public final javax.faces.event.FacesListener [] listCheckListeners() {
177 		return getFacesListeners(org.rcfaces.core.event.ICheckListener.class);
178 	}
179 
180 	public java.lang.Object getCheckedValues() {
181 		return getCheckedValues(null);
182 	}
183 
184 	/**
185 	 * See {@link #getCheckedValues() getCheckedValues()} for more details
186 	 */
187 	public java.lang.Object getCheckedValues(javax.faces.context.FacesContext facesContext) {
188 		return engine.getProperty(Properties.CHECKED_VALUES, facesContext);
189 	}
190 
191 	/**
192 	 * Returns <code>true</code> if the attribute "checkedValues" is set.
193 	 * @return <code>true</code> if the attribute is set.
194 	 */
195 	public final boolean isCheckedValuesSetted() {
196 		return engine.isPropertySetted(Properties.CHECKED_VALUES);
197 	}
198 
199 	public void setCheckedValues(java.lang.Object checkedValues) {
200 		engine.setProperty(Properties.CHECKED_VALUES, checkedValues);
201 	}
202 
203 	/**
204 	 * Return the type of the property represented by the {@link ValueExpression}, relative to the specified {@link javax.faces.context.FacesContext}.
205 	 */
206 	public Class getCheckedValuesType(javax.faces.context.FacesContext facesContext) {
207 		ValueExpression valueExpression=engine.getValueExpressionProperty(Properties.CHECKED_VALUES);
208 		if (valueExpression==null) {
209 			return null;
210 		}
211 		if (facesContext==null) {
212 			facesContext=javax.faces.context.FacesContext.getCurrentInstance();
213 		}
214 		return valueExpression.getType(facesContext.getELContext());
215 	}
216 
217 	public Object getFirstCheckedValue() {
218 
219 
220 			return CheckTools.getFirst(getCheckedValues(), getValue());
221 		
222 	}
223 
224 	public int getCheckedValuesCount() {
225 
226 
227 			return CheckTools.getCount(getCheckedValues());
228 		
229 	}
230 
231 	public Object[] listCheckedValues() {
232 
233 
234 			return CheckTools.listValues(getCheckedValues(), getValue());
235 		
236 	}
237 
238 	public boolean isReadOnly() {
239 		return isReadOnly(null);
240 	}
241 
242 	/**
243 	 * See {@link #isReadOnly() isReadOnly()} for more details
244 	 */
245 	public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
246 		return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
247 	}
248 
249 	/**
250 	 * Returns <code>true</code> if the attribute "readOnly" is set.
251 	 * @return <code>true</code> if the attribute is set.
252 	 */
253 	public final boolean isReadOnlySetted() {
254 		return engine.isPropertySetted(Properties.READ_ONLY);
255 	}
256 
257 	public void setReadOnly(boolean readOnly) {
258 		engine.setProperty(Properties.READ_ONLY, readOnly);
259 	}
260 
261 	/**
262 	 * Returns an url string pointing to the default image.
263 	 * @return image url
264 	 */
265 	public String getDefaultImageURL() {
266 		return getDefaultImageURL(null);
267 	}
268 
269 	/**
270 	 * Returns an url string pointing to the default image.
271 	 * @return image url
272 	 */
273 	public String getDefaultImageURL(javax.faces.context.FacesContext facesContext) {
274 		return engine.getStringProperty(Properties.DEFAULT_IMAGE_URL, facesContext);
275 	}
276 
277 	/**
278 	 * Sets an url string pointing to the default image.
279 	 * @param defaultImageURL image url
280 	 */
281 	public void setDefaultImageURL(String defaultImageURL) {
282 		engine.setProperty(Properties.DEFAULT_IMAGE_URL, defaultImageURL);
283 	}
284 
285 	/**
286 	 * Sets an url string pointing to the default image.
287 	 * @param defaultImageURL image url
288 	 */
289 	/**
290 	 * Returns <code>true</code> if the attribute "defaultImageURL" is set.
291 	 * @return <code>true</code> if the attribute is set.
292 	 */
293 	public boolean isDefaultImageURLSetted() {
294 		return engine.isPropertySetted(Properties.DEFAULT_IMAGE_URL);
295 	}
296 
297 	/**
298 	 * Returns an url string pointing to the default image for the selected state.
299 	 * @return selected image url
300 	 */
301 	public String getDefaultSelectedImageURL() {
302 		return getDefaultSelectedImageURL(null);
303 	}
304 
305 	/**
306 	 * Returns an url string pointing to the default image for the selected state.
307 	 * @return selected image url
308 	 */
309 	public String getDefaultSelectedImageURL(javax.faces.context.FacesContext facesContext) {
310 		return engine.getStringProperty(Properties.DEFAULT_SELECTED_IMAGE_URL, facesContext);
311 	}
312 
313 	/**
314 	 * Sets an url string pointing to the default image for the selected state.
315 	 * @param defaultSelectedImageURL selected image url
316 	 */
317 	public void setDefaultSelectedImageURL(String defaultSelectedImageURL) {
318 		engine.setProperty(Properties.DEFAULT_SELECTED_IMAGE_URL, defaultSelectedImageURL);
319 	}
320 
321 	/**
322 	 * Sets an url string pointing to the default image for the selected state.
323 	 * @param defaultSelectedImageURL selected image url
324 	 */
325 	/**
326 	 * Returns <code>true</code> if the attribute "defaultSelectedImageURL" is set.
327 	 * @return <code>true</code> if the attribute is set.
328 	 */
329 	public boolean isDefaultSelectedImageURLSetted() {
330 		return engine.isPropertySetted(Properties.DEFAULT_SELECTED_IMAGE_URL);
331 	}
332 
333 	public String getDefaultHoverImageURL() {
334 		return getDefaultHoverImageURL(null);
335 	}
336 
337 	public String getDefaultHoverImageURL(javax.faces.context.FacesContext facesContext) {
338 		return engine.getStringProperty(Properties.DEFAULT_HOVER_IMAGE_URL, facesContext);
339 	}
340 
341 	public void setDefaultHoverImageURL(String defaultHoverImageURL) {
342 		engine.setProperty(Properties.DEFAULT_HOVER_IMAGE_URL, defaultHoverImageURL);
343 	}
344 
345 	/**
346 	 * Returns <code>true</code> if the attribute "defaultHoverImageURL" is set.
347 	 * @return <code>true</code> if the attribute is set.
348 	 */
349 	public boolean isDefaultHoverImageURLSetted() {
350 		return engine.isPropertySetted(Properties.DEFAULT_HOVER_IMAGE_URL);
351 	}
352 
353 	/**
354 	 * Returns an url string pointing to the default image for the disabled state.
355 	 * @return disabled image url
356 	 */
357 	public String getDefaultDisabledImageURL() {
358 		return getDefaultDisabledImageURL(null);
359 	}
360 
361 	/**
362 	 * Returns an url string pointing to the default image for the disabled state.
363 	 * @return disabled image url
364 	 */
365 	public String getDefaultDisabledImageURL(javax.faces.context.FacesContext facesContext) {
366 		return engine.getStringProperty(Properties.DEFAULT_DISABLED_IMAGE_URL, facesContext);
367 	}
368 
369 	/**
370 	 * Sets an url string pointing to the default image for the disabled state.
371 	 * @param defaultDisabledImageURL disabled image url
372 	 */
373 	public void setDefaultDisabledImageURL(String defaultDisabledImageURL) {
374 		engine.setProperty(Properties.DEFAULT_DISABLED_IMAGE_URL, defaultDisabledImageURL);
375 	}
376 
377 	/**
378 	 * Sets an url string pointing to the default image for the disabled state.
379 	 * @param defaultDisabledImageURL disabled image url
380 	 */
381 	/**
382 	 * Returns <code>true</code> if the attribute "defaultDisabledImageURL" is set.
383 	 * @return <code>true</code> if the attribute is set.
384 	 */
385 	public boolean isDefaultDisabledImageURLSetted() {
386 		return engine.isPropertySetted(Properties.DEFAULT_DISABLED_IMAGE_URL);
387 	}
388 
389 	public int getDefaultItemInputType() {
390 		return getDefaultItemInputType(null);
391 	}
392 
393 	public int getDefaultItemInputType(javax.faces.context.FacesContext facesContext) {
394 		return engine.getIntProperty(Properties.DEFAULT_ITEM_INPUT_TYPE, 0, facesContext);
395 	}
396 
397 	public void setDefaultItemInputType(int defaultItemInputType) {
398 		engine.setProperty(Properties.DEFAULT_ITEM_INPUT_TYPE, defaultItemInputType);
399 	}
400 
401 	/**
402 	 * Returns <code>true</code> if the attribute "defaultItemInputType" is set.
403 	 * @return <code>true</code> if the attribute is set.
404 	 */
405 	public boolean isDefaultItemInputTypeSetted() {
406 		return engine.isPropertySetted(Properties.DEFAULT_ITEM_INPUT_TYPE);
407 	}
408 
409 	public String getDefaultItemLookId() {
410 		return getDefaultItemLookId(null);
411 	}
412 
413 	public String getDefaultItemLookId(javax.faces.context.FacesContext facesContext) {
414 		return engine.getStringProperty(Properties.DEFAULT_ITEM_LOOK_ID, facesContext);
415 	}
416 
417 	public void setDefaultItemLookId(String defaultItemLookId) {
418 		engine.setProperty(Properties.DEFAULT_ITEM_LOOK_ID, defaultItemLookId);
419 	}
420 
421 	/**
422 	 * Returns <code>true</code> if the attribute "defaultItemLookId" is set.
423 	 * @return <code>true</code> if the attribute is set.
424 	 */
425 	public boolean isDefaultItemLookIdSetted() {
426 		return engine.isPropertySetted(Properties.DEFAULT_ITEM_LOOK_ID);
427 	}
428 
429 	public String getDefaultItemStyleClass() {
430 		return getDefaultItemStyleClass(null);
431 	}
432 
433 	public String getDefaultItemStyleClass(javax.faces.context.FacesContext facesContext) {
434 		return engine.getStringProperty(Properties.DEFAULT_ITEM_STYLE_CLASS, facesContext);
435 	}
436 
437 	public void setDefaultItemStyleClass(String defaultItemStyleClass) {
438 		engine.setProperty(Properties.DEFAULT_ITEM_STYLE_CLASS, defaultItemStyleClass);
439 	}
440 
441 	/**
442 	 * Returns <code>true</code> if the attribute "defaultItemStyleClass" is set.
443 	 * @return <code>true</code> if the attribute is set.
444 	 */
445 	public boolean isDefaultItemStyleClassSetted() {
446 		return engine.isPropertySetted(Properties.DEFAULT_ITEM_STYLE_CLASS);
447 	}
448 
449 	public String getDefaultItemGroupName() {
450 		return getDefaultItemGroupName(null);
451 	}
452 
453 	public String getDefaultItemGroupName(javax.faces.context.FacesContext facesContext) {
454 		return engine.getStringProperty(Properties.DEFAULT_ITEM_GROUP_NAME, facesContext);
455 	}
456 
457 	public void setDefaultItemGroupName(String defaultItemGroupName) {
458 		engine.setProperty(Properties.DEFAULT_ITEM_GROUP_NAME, defaultItemGroupName);
459 	}
460 
461 	/**
462 	 * Returns <code>true</code> if the attribute "defaultItemGroupName" is set.
463 	 * @return <code>true</code> if the attribute is set.
464 	 */
465 	public boolean isDefaultItemGroupNameSetted() {
466 		return engine.isPropertySetted(Properties.DEFAULT_ITEM_GROUP_NAME);
467 	}
468 
469 	public int getItemPadding() {
470 		return getItemPadding(null);
471 	}
472 
473 	public int getItemPadding(javax.faces.context.FacesContext facesContext) {
474 		return engine.getIntProperty(Properties.ITEM_PADDING, 0, facesContext);
475 	}
476 
477 	public void setItemPadding(int itemPadding) {
478 		engine.setProperty(Properties.ITEM_PADDING, itemPadding);
479 	}
480 
481 	/**
482 	 * Returns <code>true</code> if the attribute "itemPadding" is set.
483 	 * @return <code>true</code> if the attribute is set.
484 	 */
485 	public boolean isItemPaddingSetted() {
486 		return engine.isPropertySetted(Properties.ITEM_PADDING);
487 	}
488 
489 	public int getItemHiddenMode() {
490 		return getItemHiddenMode(null);
491 	}
492 
493 	public int getItemHiddenMode(javax.faces.context.FacesContext facesContext) {
494 		return engine.getIntProperty(Properties.ITEM_HIDDEN_MODE, 0, facesContext);
495 	}
496 
497 	public void setItemHiddenMode(int itemHiddenMode) {
498 		engine.setProperty(Properties.ITEM_HIDDEN_MODE, itemHiddenMode);
499 	}
500 
501 	/**
502 	 * Returns <code>true</code> if the attribute "itemHiddenMode" is set.
503 	 * @return <code>true</code> if the attribute is set.
504 	 */
505 	public boolean isItemHiddenModeSetted() {
506 		return engine.isPropertySetted(Properties.ITEM_HIDDEN_MODE);
507 	}
508 
509 	protected Set getCameliaFields() {
510 		return CAMELIA_ATTRIBUTES;
511 	}
512 }