View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.familly.IContentAccessors;
5   import java.lang.String;
6   import org.apache.commons.logging.LogFactory;
7   import org.rcfaces.core.component.capability.IShowDropDownMarkCapability;
8   import javax.faces.context.FacesContext;
9   import org.rcfaces.core.internal.tools.ImageAccessorTools;
10  import org.rcfaces.core.component.capability.IHorizontalTextPositionCapability;
11  import javax.faces.convert.Converter;
12  import javax.el.ValueExpression;
13  import java.util.HashSet;
14  import org.apache.commons.logging.Log;
15  import java.util.Set;
16  import java.util.Arrays;
17  import org.rcfaces.core.component.AbstractMenuComponent;
18  import org.rcfaces.core.component.familly.IImageButtonFamilly;
19  import org.rcfaces.core.internal.converter.TextPositionConverter;
20  
21  /**
22   * <p>The imageCombo Component is a <a href="/comps/comboComponent.html">combo Component</a> with an image added to the text.</p>
23   * <p>The imageCombo Component has the following capabilities :
24   * <ul>
25   * <li>IImageButtonFamilly</li>
26   * <li>IShowDropDownMarkCapability</li>
27   * </ul>
28   * </p>
29   * 
30   * 
31   * 
32   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ImageComboComponent.html">imageCombo</a> renderer is linked to the <a href="/jsdocs/index.html?f_imageCombo.html" target="_blank">f_imageCombo</a> javascript class. f_imageCombo extends f_imageButton, fa_subMenu, fa_itemsWrapper</p>
33   * 
34   * <p> Table of component style classes: </p>
35   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
36   * <tbody>
37   * 
38   * <tr style="text-align:left">
39   * <th  width="33%">Style Name</th>
40   * <th width="50%">Description</th>
41   * </tr>
42   * 
43   * <tr  style="text-align:left">
44   * <td width="33%">f_imageCombo</td>
45   * <td width="50%">Defines styles for the wrapper DIV element</td>
46   * </tr>
47   * 
48   * <tr  style="text-align:left">
49   * <td width="33%">f_imageCheckButton_ctext</td>
50   * <td width="50%">Defines styles for the  Text element of the combo</td>
51   * </tr>
52   * 
53   * <tr  style="text-align:left">
54   * <td width="33%">f_imageCheckButton_cimage</td>
55   * <td width="50%">Defines styles for the IMG element of the combo</td>
56   * </tr>
57   * <tr  style="text-align:left">
58   * <td width="33%">f_menu_popup</td>
59   * <td width="50%">Defines styles for the pop-up element of the combo</td>
60   * </tr>
61   * 
62   * </tbody>
63   * </table>
64   */
65  public class ImageComboComponent extends AbstractMenuComponent implements 
66  	IImageButtonFamilly,
67  	IShowDropDownMarkCapability {
68  
69  	private static final Log LOG = LogFactory.getLog(ImageComboComponent.class);
70  
71  	public static final String COMPONENT_TYPE="org.rcfaces.core.imageCombo";
72  
73  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractMenuComponent.CAMELIA_ATTRIBUTES);
74  	static {
75  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"disabledImageURL","imageHeight","text","popupRowNumber","showDropDownMark","borderType","textPosition","hoverImageURL","tabIndex","selectedImageURL","selectionListener","readOnly","border","imageURL","disabled","imageWidth"}));
76  	}
77  
78  	public ImageComboComponent() {
79  		setRendererType(COMPONENT_TYPE);
80  	}
81  
82  	public ImageComboComponent(String componentId) {
83  		this();
84  		setId(componentId);
85  	}
86  
87  	protected Converter getTextPositionConverter() {
88  
89  
90  				return TextPositionConverter.SINGLETON;
91  			
92  	}
93  
94  	public void setTextPosition(String textPosition) {
95  
96  
97  			setTextPosition(((Integer)getTextPositionConverter().getAsObject(null, this, textPosition)).intValue());
98  		
99  	}
100 
101 	public java.lang.String getImageURL() {
102 		return getImageURL(null);
103 	}
104 
105 	/**
106 	 * See {@link #getImageURL() getImageURL()} for more details
107 	 */
108 	public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
109 		return engine.getStringProperty(Properties.IMAGE_URL, facesContext);
110 	}
111 
112 	/**
113 	 * Returns <code>true</code> if the attribute "imageURL" is set.
114 	 * @return <code>true</code> if the attribute is set.
115 	 */
116 	public final boolean isImageURLSetted() {
117 		return engine.isPropertySetted(Properties.IMAGE_URL);
118 	}
119 
120 	public void setImageURL(java.lang.String imageURL) {
121 		engine.setProperty(Properties.IMAGE_URL, imageURL);
122 	}
123 
124 	public java.lang.String getDisabledImageURL() {
125 		return getDisabledImageURL(null);
126 	}
127 
128 	/**
129 	 * See {@link #getDisabledImageURL() getDisabledImageURL()} for more details
130 	 */
131 	public java.lang.String getDisabledImageURL(javax.faces.context.FacesContext facesContext) {
132 		return engine.getStringProperty(Properties.DISABLED_IMAGE_URL, facesContext);
133 	}
134 
135 	/**
136 	 * Returns <code>true</code> if the attribute "disabledImageURL" is set.
137 	 * @return <code>true</code> if the attribute is set.
138 	 */
139 	public final boolean isDisabledImageURLSetted() {
140 		return engine.isPropertySetted(Properties.DISABLED_IMAGE_URL);
141 	}
142 
143 	public void setDisabledImageURL(java.lang.String disabledImageURL) {
144 		engine.setProperty(Properties.DISABLED_IMAGE_URL, disabledImageURL);
145 	}
146 
147 	public java.lang.String getHoverImageURL() {
148 		return getHoverImageURL(null);
149 	}
150 
151 	/**
152 	 * See {@link #getHoverImageURL() getHoverImageURL()} for more details
153 	 */
154 	public java.lang.String getHoverImageURL(javax.faces.context.FacesContext facesContext) {
155 		return engine.getStringProperty(Properties.HOVER_IMAGE_URL, facesContext);
156 	}
157 
158 	/**
159 	 * Returns <code>true</code> if the attribute "hoverImageURL" is set.
160 	 * @return <code>true</code> if the attribute is set.
161 	 */
162 	public final boolean isHoverImageURLSetted() {
163 		return engine.isPropertySetted(Properties.HOVER_IMAGE_URL);
164 	}
165 
166 	public void setHoverImageURL(java.lang.String hoverImageURL) {
167 		engine.setProperty(Properties.HOVER_IMAGE_URL, hoverImageURL);
168 	}
169 
170 	public java.lang.String getSelectedImageURL() {
171 		return getSelectedImageURL(null);
172 	}
173 
174 	/**
175 	 * See {@link #getSelectedImageURL() getSelectedImageURL()} for more details
176 	 */
177 	public java.lang.String getSelectedImageURL(javax.faces.context.FacesContext facesContext) {
178 		return engine.getStringProperty(Properties.SELECTED_IMAGE_URL, facesContext);
179 	}
180 
181 	/**
182 	 * Returns <code>true</code> if the attribute "selectedImageURL" is set.
183 	 * @return <code>true</code> if the attribute is set.
184 	 */
185 	public final boolean isSelectedImageURLSetted() {
186 		return engine.isPropertySetted(Properties.SELECTED_IMAGE_URL);
187 	}
188 
189 	public void setSelectedImageURL(java.lang.String selectedImageURL) {
190 		engine.setProperty(Properties.SELECTED_IMAGE_URL, selectedImageURL);
191 	}
192 
193 	public boolean isBorder() {
194 		return isBorder(null);
195 	}
196 
197 	/**
198 	 * See {@link #isBorder() isBorder()} for more details
199 	 */
200 	public boolean isBorder(javax.faces.context.FacesContext facesContext) {
201 		return engine.getBoolProperty(Properties.BORDER, true, facesContext);
202 	}
203 
204 	/**
205 	 * Returns <code>true</code> if the attribute "border" is set.
206 	 * @return <code>true</code> if the attribute is set.
207 	 */
208 	public final boolean isBorderSetted() {
209 		return engine.isPropertySetted(Properties.BORDER);
210 	}
211 
212 	public void setBorder(boolean border) {
213 		engine.setProperty(Properties.BORDER, border);
214 	}
215 
216 	public java.lang.String getBorderType() {
217 		return getBorderType(null);
218 	}
219 
220 	/**
221 	 * See {@link #getBorderType() getBorderType()} for more details
222 	 */
223 	public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
224 		return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
225 	}
226 
227 	/**
228 	 * Returns <code>true</code> if the attribute "borderType" is set.
229 	 * @return <code>true</code> if the attribute is set.
230 	 */
231 	public final boolean isBorderTypeSetted() {
232 		return engine.isPropertySetted(Properties.BORDER_TYPE);
233 	}
234 
235 	public void setBorderType(java.lang.String borderType) {
236 		engine.setProperty(Properties.BORDER_TYPE, borderType);
237 	}
238 
239 	public java.lang.String getText() {
240 		return getText(null);
241 	}
242 
243 	/**
244 	 * See {@link #getText() getText()} for more details
245 	 */
246 	public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
247 		return engine.getStringProperty(Properties.TEXT, facesContext);
248 	}
249 
250 	/**
251 	 * Returns <code>true</code> if the attribute "text" is set.
252 	 * @return <code>true</code> if the attribute is set.
253 	 */
254 	public final boolean isTextSetted() {
255 		return engine.isPropertySetted(Properties.TEXT);
256 	}
257 
258 	public void setText(java.lang.String text) {
259 		engine.setProperty(Properties.TEXT, text);
260 	}
261 
262 	public int getTextPosition() {
263 		return getTextPosition(null);
264 	}
265 
266 	/**
267 	 * See {@link #getTextPosition() getTextPosition()} for more details
268 	 */
269 	public int getTextPosition(javax.faces.context.FacesContext facesContext) {
270 		return engine.getIntProperty(Properties.TEXT_POSITION,IHorizontalTextPositionCapability.DEFAULT_POSITION, facesContext);
271 	}
272 
273 	/**
274 	 * Returns <code>true</code> if the attribute "textPosition" is set.
275 	 * @return <code>true</code> if the attribute is set.
276 	 */
277 	public final boolean isTextPositionSetted() {
278 		return engine.isPropertySetted(Properties.TEXT_POSITION);
279 	}
280 
281 	public void setTextPosition(int textPosition) {
282 		engine.setProperty(Properties.TEXT_POSITION, textPosition);
283 	}
284 
285 	public int getImageHeight() {
286 		return getImageHeight(null);
287 	}
288 
289 	/**
290 	 * See {@link #getImageHeight() getImageHeight()} for more details
291 	 */
292 	public int getImageHeight(javax.faces.context.FacesContext facesContext) {
293 		return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
294 	}
295 
296 	/**
297 	 * Returns <code>true</code> if the attribute "imageHeight" is set.
298 	 * @return <code>true</code> if the attribute is set.
299 	 */
300 	public final boolean isImageHeightSetted() {
301 		return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
302 	}
303 
304 	public void setImageHeight(int imageHeight) {
305 		engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
306 	}
307 
308 	public int getImageWidth() {
309 		return getImageWidth(null);
310 	}
311 
312 	/**
313 	 * See {@link #getImageWidth() getImageWidth()} for more details
314 	 */
315 	public int getImageWidth(javax.faces.context.FacesContext facesContext) {
316 		return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
317 	}
318 
319 	/**
320 	 * Returns <code>true</code> if the attribute "imageWidth" is set.
321 	 * @return <code>true</code> if the attribute is set.
322 	 */
323 	public final boolean isImageWidthSetted() {
324 		return engine.isPropertySetted(Properties.IMAGE_WIDTH);
325 	}
326 
327 	public void setImageWidth(int imageWidth) {
328 		engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
329 	}
330 
331 	public IContentAccessors getImageAccessors(FacesContext facesContext) {
332 
333 
334 			return ImageAccessorTools.createImageAccessors(facesContext, this, engine);
335 		
336 	}
337 
338 	public IContentAccessors getImageAccessors() {
339 
340 
341 			return getImageAccessors(null);
342 		
343 	}
344 
345 	public boolean isShowDropDownMark() {
346 		return isShowDropDownMark(null);
347 	}
348 
349 	/**
350 	 * See {@link #isShowDropDownMark() isShowDropDownMark()} for more details
351 	 */
352 	public boolean isShowDropDownMark(javax.faces.context.FacesContext facesContext) {
353 		return engine.getBoolProperty(Properties.SHOW_DROP_DOWN_MARK, false, facesContext);
354 	}
355 
356 	/**
357 	 * Returns <code>true</code> if the attribute "showDropDownMark" is set.
358 	 * @return <code>true</code> if the attribute is set.
359 	 */
360 	public final boolean isShowDropDownMarkSetted() {
361 		return engine.isPropertySetted(Properties.SHOW_DROP_DOWN_MARK);
362 	}
363 
364 	public void setShowDropDownMark(boolean showDropDownMark) {
365 		engine.setProperty(Properties.SHOW_DROP_DOWN_MARK, showDropDownMark);
366 	}
367 
368 	/**
369 	 * Experimental : do not use!
370 	 */
371 	public int getPopupRowNumber() {
372 		return getPopupRowNumber(null);
373 	}
374 
375 	/**
376 	 * Experimental : do not use!
377 	 */
378 	public int getPopupRowNumber(javax.faces.context.FacesContext facesContext) {
379 		return engine.getIntProperty(Properties.POPUP_ROW_NUMBER, 0, facesContext);
380 	}
381 
382 	/**
383 	 * Experimental : do not use!
384 	 */
385 	public void setPopupRowNumber(int popupRowNumber) {
386 		engine.setProperty(Properties.POPUP_ROW_NUMBER, popupRowNumber);
387 	}
388 
389 	/**
390 	 * Experimental : do not use!
391 	 */
392 	/**
393 	 * Returns <code>true</code> if the attribute "popupRowNumber" is set.
394 	 * @return <code>true</code> if the attribute is set.
395 	 */
396 	public boolean isPopupRowNumberSetted() {
397 		return engine.isPropertySetted(Properties.POPUP_ROW_NUMBER);
398 	}
399 
400 	protected Set getCameliaFields() {
401 		return CAMELIA_ATTRIBUTES;
402 	}
403 }