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
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
123
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
139
140 public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
141 return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
142 }
143
144
145
146
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
186
187 public java.lang.Object getCheckedValues(javax.faces.context.FacesContext facesContext) {
188 return engine.getProperty(Properties.CHECKED_VALUES, facesContext);
189 }
190
191
192
193
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
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
244
245 public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
246 return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
247 }
248
249
250
251
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
263
264
265 public String getDefaultImageURL() {
266 return getDefaultImageURL(null);
267 }
268
269
270
271
272
273 public String getDefaultImageURL(javax.faces.context.FacesContext facesContext) {
274 return engine.getStringProperty(Properties.DEFAULT_IMAGE_URL, facesContext);
275 }
276
277
278
279
280
281 public void setDefaultImageURL(String defaultImageURL) {
282 engine.setProperty(Properties.DEFAULT_IMAGE_URL, defaultImageURL);
283 }
284
285
286
287
288
289
290
291
292
293 public boolean isDefaultImageURLSetted() {
294 return engine.isPropertySetted(Properties.DEFAULT_IMAGE_URL);
295 }
296
297
298
299
300
301 public String getDefaultSelectedImageURL() {
302 return getDefaultSelectedImageURL(null);
303 }
304
305
306
307
308
309 public String getDefaultSelectedImageURL(javax.faces.context.FacesContext facesContext) {
310 return engine.getStringProperty(Properties.DEFAULT_SELECTED_IMAGE_URL, facesContext);
311 }
312
313
314
315
316
317 public void setDefaultSelectedImageURL(String defaultSelectedImageURL) {
318 engine.setProperty(Properties.DEFAULT_SELECTED_IMAGE_URL, defaultSelectedImageURL);
319 }
320
321
322
323
324
325
326
327
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
347
348
349 public boolean isDefaultHoverImageURLSetted() {
350 return engine.isPropertySetted(Properties.DEFAULT_HOVER_IMAGE_URL);
351 }
352
353
354
355
356
357 public String getDefaultDisabledImageURL() {
358 return getDefaultDisabledImageURL(null);
359 }
360
361
362
363
364
365 public String getDefaultDisabledImageURL(javax.faces.context.FacesContext facesContext) {
366 return engine.getStringProperty(Properties.DEFAULT_DISABLED_IMAGE_URL, facesContext);
367 }
368
369
370
371
372
373 public void setDefaultDisabledImageURL(String defaultDisabledImageURL) {
374 engine.setProperty(Properties.DEFAULT_DISABLED_IMAGE_URL, defaultDisabledImageURL);
375 }
376
377
378
379
380
381
382
383
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
403
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
423
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
443
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
463
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
483
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
503
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 }