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 org.rcfaces.core.component.capability.IImageCapability;
6 import java.lang.String;
7 import org.apache.commons.logging.LogFactory;
8 import org.rcfaces.core.component.capability.IImageSizeCapability;
9 import javax.faces.context.FacesContext;
10 import org.rcfaces.core.component.capability.IAlternateTextCapability;
11 import org.rcfaces.core.internal.tools.ImageAccessorTools;
12 import org.rcfaces.core.internal.converter.FilterPropertiesConverter;
13 import javax.el.ValueExpression;
14 import org.rcfaces.core.component.capability.IFilterCapability;
15 import java.util.HashSet;
16 import org.apache.commons.logging.Log;
17 import org.rcfaces.core.component.AbstractOutputComponent;
18 import org.rcfaces.core.model.IFilterProperties;
19 import java.util.Set;
20 import java.util.Arrays;
21 import org.rcfaces.core.internal.capability.IImageAccessorsCapability;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 public class ImageComponent extends AbstractOutputComponent implements
57 IImageCapability,
58 IImageSizeCapability,
59 IAlternateTextCapability,
60 IFilterCapability,
61 IImageAccessorsCapability {
62
63 private static final Log LOG = LogFactory.getLog(ImageComponent.class);
64
65 public static final String COMPONENT_TYPE="org.rcfaces.core.image";
66
67 protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractOutputComponent.CAMELIA_ATTRIBUTES);
68 static {
69 CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"imageHeight","filterProperties","alternateText","imageWidth","imageURL"}));
70 }
71 protected static final String CAMELIA_VALUE_ALIAS="imageURL";
72
73 public ImageComponent() {
74 setRendererType(COMPONENT_TYPE);
75 }
76
77 public ImageComponent(String componentId) {
78 this();
79 setId(componentId);
80 }
81
82 public IContentAccessors getImageAccessors(FacesContext facesContext) {
83
84
85 Object value=getLocalValue();
86 if (value==null) {
87 value=getValueExpression(Properties.VALUE);
88 }
89
90 return ImageAccessorTools.createImageAccessor(facesContext, value);
91
92 }
93
94 public void setFilterProperties(String properties) {
95
96
97 IFilterProperties filterProperties=(IFilterProperties)FilterPropertiesConverter.SINGLETON.getAsObject(null, this, properties);
98
99 setFilterProperties(filterProperties);
100
101 }
102
103 public java.lang.String getImageURL() {
104 return getImageURL(null);
105 }
106
107
108
109
110 public java.lang.String getImageURL(javax.faces.context.FacesContext facesContext) {
111 return org.rcfaces.core.internal.tools.ValuesTools.valueToString(this, facesContext);
112 }
113
114
115
116
117
118 public final boolean isImageURLSetted() {
119 return engine.isPropertySetted(Properties.IMAGE_URL);
120 }
121
122 public void setImageURL(java.lang.String imageURL) {
123 setValue(imageURL);
124 }
125
126 public IContentAccessors getImageAccessors() {
127
128
129 return getImageAccessors(null);
130
131 }
132
133 public int getImageHeight() {
134 return getImageHeight(null);
135 }
136
137
138
139
140 public int getImageHeight(javax.faces.context.FacesContext facesContext) {
141 return engine.getIntProperty(Properties.IMAGE_HEIGHT,0, facesContext);
142 }
143
144
145
146
147
148 public final boolean isImageHeightSetted() {
149 return engine.isPropertySetted(Properties.IMAGE_HEIGHT);
150 }
151
152 public void setImageHeight(int imageHeight) {
153 engine.setProperty(Properties.IMAGE_HEIGHT, imageHeight);
154 }
155
156 public int getImageWidth() {
157 return getImageWidth(null);
158 }
159
160
161
162
163 public int getImageWidth(javax.faces.context.FacesContext facesContext) {
164 return engine.getIntProperty(Properties.IMAGE_WIDTH,0, facesContext);
165 }
166
167
168
169
170
171 public final boolean isImageWidthSetted() {
172 return engine.isPropertySetted(Properties.IMAGE_WIDTH);
173 }
174
175 public void setImageWidth(int imageWidth) {
176 engine.setProperty(Properties.IMAGE_WIDTH, imageWidth);
177 }
178
179 public java.lang.String getAlternateText() {
180 return getAlternateText(null);
181 }
182
183
184
185
186 public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
187 return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
188 }
189
190
191
192
193
194 public final boolean isAlternateTextSetted() {
195 return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
196 }
197
198 public void setAlternateText(java.lang.String alternateText) {
199 engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
200 }
201
202 public org.rcfaces.core.model.IFilterProperties getFilterProperties() {
203 return getFilterProperties(null);
204 }
205
206
207
208
209 public org.rcfaces.core.model.IFilterProperties getFilterProperties(javax.faces.context.FacesContext facesContext) {
210 return (org.rcfaces.core.model.IFilterProperties)engine.getProperty(Properties.FILTER_PROPERTIES, facesContext);
211 }
212
213
214
215
216
217 public final boolean isFilterPropertiesSetted() {
218 return engine.isPropertySetted(Properties.FILTER_PROPERTIES);
219 }
220
221 public void setFilterProperties(org.rcfaces.core.model.IFilterProperties filterProperties) {
222 engine.setProperty(Properties.FILTER_PROPERTIES, filterProperties);
223 }
224
225 protected Set getCameliaFields() {
226 return CAMELIA_ATTRIBUTES;
227 }
228
229 protected String getCameliaValueAlias() {
230 return CAMELIA_VALUE_ALIAS;
231 }
232 }