View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.component.CheckButtonComponent;
5   import org.rcfaces.core.component.familly.IContentAccessors;
6   import org.apache.commons.logging.LogFactory;
7   import javax.faces.context.FacesContext;
8   import org.rcfaces.core.internal.tools.ImageAccessorTools;
9   import org.rcfaces.core.component.capability.IHorizontalTextPositionCapability;
10  import javax.faces.convert.Converter;
11  import javax.el.ValueExpression;
12  import java.util.HashSet;
13  import org.apache.commons.logging.Log;
14  import java.util.Set;
15  import java.util.Arrays;
16  import org.rcfaces.core.component.familly.IImageButtonFamilly;
17  import org.rcfaces.core.internal.converter.TextPositionConverter;
18  
19  /**
20   * <p>The imageCheckButton Component is a <a href="/comps/checkButtonComponent.html">checkButton Component</a> with an image instead of the checkBox.</p>
21   * <p>The imageCheckButton Component has the following capabilities :
22   * <ul>
23   * <li>IImageButtonFamilly</li>
24   * </ul>
25   * </p>
26   * 
27   * 
28   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/ImageCheckButtonComponent.html">imageCheckButton</a> renderer is linked to the <a href="/jsdocs/index.html?f_imageCheckButton.html" target="_blank">f_imageCheckButton</a> javascript class. f_imageCheckButton extends f_imageButton, fa_selected</p>
29   * 
30   * <p> Table of component style classes: </p>
31   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
32   * <tbody>
33   * 
34   * <tr style="text-align:left">
35   * <th  width="33%">Style Name</th>
36   * <th width="50%">Description</th>
37   * </tr>
38   * 
39   * <tr  style="text-align:left">
40   * <td width="33%">f_imageCheckButton</td>
41   * <td width="50%">Defines styles for the wrapper A element</td>
42   * </tr>
43   * 
44   * <tr  style="text-align:left">
45   * <td width="33%">f_imageCheckButton_image</td>
46   * <td width="50%">Defines styles for the  IMG element</td>
47   * </tr>
48   * 
49   * </tbody>
50   * </table>
51   */
52  public class ImageCheckButtonComponent extends CheckButtonComponent implements 
53  	IImageButtonFamilly {
54  
55  	private static final Log LOG = LogFactory.getLog(ImageCheckButtonComponent.class);
56  
57  	public static final String COMPONENT_TYPE="org.rcfaces.core.imageCheckButton";
58  
59  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(CheckButtonComponent.CAMELIA_ATTRIBUTES);
60  	static {
61  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"disabledImageURL","imageHeight","text","borderType","textPosition","hoverImageURL","tabIndex","selectedImageURL","selectionListener","readOnly","border","imageURL","disabled","imageWidth"}));
62  	}
63  	protected static final String CAMELIA_VALUE_ALIAS="selected";
64  
65  	public ImageCheckButtonComponent() {
66  		setRendererType(COMPONENT_TYPE);
67  	}
68  
69  	public ImageCheckButtonComponent(String componentId) {
70  		this();
71  		setId(componentId);
72  	}
73  
74  	protected Converter getTextPositionConverter() {
75  
76  
77  				return TextPositionConverter.SINGLETON;
78  			
79  	}
80  
81  	public java.lang.String getImageURL() {
82  		return getImageURL(null);
83  	}
84  
85  	/**
86  	 * See {@link #getImageURL() getImageURL()} for more details
87  	 */
88  	public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
89  		return engine.getStringProperty(Properties.IMAGE_URL, facesContext);
90  	}
91  
92  	/**
93  	 * Returns <code>true</code> if the attribute "imageURL" is set.
94  	 * @return <code>true</code> if the attribute is set.
95  	 */
96  	public final boolean isImageURLSetted() {
97  		return engine.isPropertySetted(Properties.IMAGE_URL);
98  	}
99  
100 	public void setImageURL(java.lang.String imageURL) {
101 		engine.setProperty(Properties.IMAGE_URL, imageURL);
102 	}
103 
104 	public java.lang.String getDisabledImageURL() {
105 		return getDisabledImageURL(null);
106 	}
107 
108 	/**
109 	 * See {@link #getDisabledImageURL() getDisabledImageURL()} for more details
110 	 */
111 	public java.lang.String getDisabledImageURL(javax.faces.context.FacesContext facesContext) {
112 		return engine.getStringProperty(Properties.DISABLED_IMAGE_URL, facesContext);
113 	}
114 
115 	/**
116 	 * Returns <code>true</code> if the attribute "disabledImageURL" is set.
117 	 * @return <code>true</code> if the attribute is set.
118 	 */
119 	public final boolean isDisabledImageURLSetted() {
120 		return engine.isPropertySetted(Properties.DISABLED_IMAGE_URL);
121 	}
122 
123 	public void setDisabledImageURL(java.lang.String disabledImageURL) {
124 		engine.setProperty(Properties.DISABLED_IMAGE_URL, disabledImageURL);
125 	}
126 
127 	public java.lang.String getHoverImageURL() {
128 		return getHoverImageURL(null);
129 	}
130 
131 	/**
132 	 * See {@link #getHoverImageURL() getHoverImageURL()} for more details
133 	 */
134 	public java.lang.String getHoverImageURL(javax.faces.context.FacesContext facesContext) {
135 		return engine.getStringProperty(Properties.HOVER_IMAGE_URL, facesContext);
136 	}
137 
138 	/**
139 	 * Returns <code>true</code> if the attribute "hoverImageURL" is set.
140 	 * @return <code>true</code> if the attribute is set.
141 	 */
142 	public final boolean isHoverImageURLSetted() {
143 		return engine.isPropertySetted(Properties.HOVER_IMAGE_URL);
144 	}
145 
146 	public void setHoverImageURL(java.lang.String hoverImageURL) {
147 		engine.setProperty(Properties.HOVER_IMAGE_URL, hoverImageURL);
148 	}
149 
150 	public java.lang.String getSelectedImageURL() {
151 		return getSelectedImageURL(null);
152 	}
153 
154 	/**
155 	 * See {@link #getSelectedImageURL() getSelectedImageURL()} for more details
156 	 */
157 	public java.lang.String getSelectedImageURL(javax.faces.context.FacesContext facesContext) {
158 		return engine.getStringProperty(Properties.SELECTED_IMAGE_URL, facesContext);
159 	}
160 
161 	/**
162 	 * Returns <code>true</code> if the attribute "selectedImageURL" is set.
163 	 * @return <code>true</code> if the attribute is set.
164 	 */
165 	public final boolean isSelectedImageURLSetted() {
166 		return engine.isPropertySetted(Properties.SELECTED_IMAGE_URL);
167 	}
168 
169 	public void setSelectedImageURL(java.lang.String selectedImageURL) {
170 		engine.setProperty(Properties.SELECTED_IMAGE_URL, selectedImageURL);
171 	}
172 
173 	public boolean isBorder() {
174 		return isBorder(null);
175 	}
176 
177 	/**
178 	 * See {@link #isBorder() isBorder()} for more details
179 	 */
180 	public boolean isBorder(javax.faces.context.FacesContext facesContext) {
181 		return engine.getBoolProperty(Properties.BORDER, true, facesContext);
182 	}
183 
184 	/**
185 	 * Returns <code>true</code> if the attribute "border" is set.
186 	 * @return <code>true</code> if the attribute is set.
187 	 */
188 	public final boolean isBorderSetted() {
189 		return engine.isPropertySetted(Properties.BORDER);
190 	}
191 
192 	public void setBorder(boolean border) {
193 		engine.setProperty(Properties.BORDER, border);
194 	}
195 
196 	public java.lang.String getBorderType() {
197 		return getBorderType(null);
198 	}
199 
200 	/**
201 	 * See {@link #getBorderType() getBorderType()} for more details
202 	 */
203 	public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
204 		return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
205 	}
206 
207 	/**
208 	 * Returns <code>true</code> if the attribute "borderType" is set.
209 	 * @return <code>true</code> if the attribute is set.
210 	 */
211 	public final boolean isBorderTypeSetted() {
212 		return engine.isPropertySetted(Properties.BORDER_TYPE);
213 	}
214 
215 	public void setBorderType(java.lang.String borderType) {
216 		engine.setProperty(Properties.BORDER_TYPE, borderType);
217 	}
218 
219 	public int getImageHeight() {
220 		return getImageHeight(null);
221 	}
222 
223 	/**
224 	 * See {@link #getImageHeight() getImageHeight()} for more details
225 	 */
226 	public int getImageHeight(javax.faces.context.FacesContext facesContext) {
227 		return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
228 	}
229 
230 	/**
231 	 * Returns <code>true</code> if the attribute "imageHeight" is set.
232 	 * @return <code>true</code> if the attribute is set.
233 	 */
234 	public final boolean isImageHeightSetted() {
235 		return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
236 	}
237 
238 	public void setImageHeight(int imageHeight) {
239 		engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
240 	}
241 
242 	public int getImageWidth() {
243 		return getImageWidth(null);
244 	}
245 
246 	/**
247 	 * See {@link #getImageWidth() getImageWidth()} for more details
248 	 */
249 	public int getImageWidth(javax.faces.context.FacesContext facesContext) {
250 		return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
251 	}
252 
253 	/**
254 	 * Returns <code>true</code> if the attribute "imageWidth" is set.
255 	 * @return <code>true</code> if the attribute is set.
256 	 */
257 	public final boolean isImageWidthSetted() {
258 		return engine.isPropertySetted(Properties.IMAGE_WIDTH);
259 	}
260 
261 	public void setImageWidth(int imageWidth) {
262 		engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
263 	}
264 
265 	public IContentAccessors getImageAccessors(FacesContext facesContext) {
266 
267 
268 			return ImageAccessorTools.createImageAccessors(facesContext, this, engine);
269 		
270 	}
271 
272 	public IContentAccessors getImageAccessors() {
273 
274 
275 			return getImageAccessors(null);
276 		
277 	}
278 
279 	protected Set getCameliaFields() {
280 		return CAMELIA_ATTRIBUTES;
281 	}
282 
283 	protected String getCameliaValueAlias() {
284 		return CAMELIA_VALUE_ALIAS;
285 	}
286 }