1 package org.rcfaces.core.component;
2
3 import org.rcfaces.core.component.TextEntryComponent;
4 import org.rcfaces.core.internal.component.Properties;
5 import javax.el.ValueExpression;
6 import org.apache.commons.logging.Log;
7 import java.util.HashSet;
8 import org.apache.commons.logging.LogFactory;
9 import java.util.Arrays;
10 import java.util.Set;
11
12 /**
13 * <p>The spinner Component is a <a href="/comps/textEntryComponent.html">textEntry Component</a> that accepts numbers and whose value can be incremented or decremented (by a parametrable step) with buttons or the keyboard arrows.</p>
14 * <p>The spinner Component has the following capabilities :
15 * <ul>
16 * <li>Position & Size</li>
17 * <li>Foreground & Background Color</li>
18 * <li>Text & font</li>
19 * <li>Help</li>
20 * <li>Visibility, Read-Only, Disabled</li>
21 * <li>Events Handling</li>
22 * <li>limits and step</li>
23 * </ul>
24 * </p>
25 *
26 * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/SpinnerComponent.html">spinner</a> renderer is linked to the <a href="/jsdocs/index.html?f_spinner.html" target="_blank">f_spinner</a> javascript class. f_spinner extends f_textEntry, fa_spinner</p>
27 *
28 * <p> Table of component style classes: </p>
29 * <table border="1" cellpadding="3" cellspacing="0" width="100%">
30 * <tbody>
31 *
32 * <tr style="text-align:left">
33 * <th width="33%">Style Name</th>
34 * <th width="50%">Description</th>
35 * </tr>
36 *
37 * <tr style="text-align:left">
38 * <td width="33%">f_spinner</td>
39 * <td width="50%">Defines styles for the wrapper element</td>
40 * </tr>
41 *
42 * <tr style="text-align:left">
43 * <td width="33%">f_spinner_input</td>
44 * <td width="50%">Defines styles for the INPUT element</td>
45 * </tr>
46 * <tr style="text-align:left">
47 * <td width="33%">f_spinner_up</td>
48 * <td width="50%">Defines styles for the IMG element of the up button</td>
49 * </tr>
50 * <tr style="text-align:left">
51 * <td width="33%">f_spinner_down</td>
52 * <td width="50%">Defines styles for the IMG elemen of the down button</td>
53 * </tr>
54 *
55 * </tbody>
56 * </table>
57 */
58 public class SpinnerComponent extends TextEntryComponent {
59
60 private static final Log LOG = LogFactory.getLog(SpinnerComponent.class);
61
62 public static final String COMPONENT_TYPE="org.rcfaces.core.spinner";
63
64 protected static final Set CAMELIA_ATTRIBUTES=new HashSet(TextEntryComponent.CAMELIA_ATTRIBUTES);
65 static {
66 CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"minimum","maximum","cycleValue","step"}));
67 }
68
69 public SpinnerComponent() {
70 setRendererType(COMPONENT_TYPE);
71 }
72
73 public SpinnerComponent(String componentId) {
74 this();
75 setId(componentId);
76 }
77
78 public double getMinimum() {
79 return getMinimum(null);
80 }
81
82 public double getMinimum(javax.faces.context.FacesContext facesContext) {
83 return engine.getDoubleProperty(Properties.MINIMUM, 0.0, facesContext);
84 }
85
86 public void setMinimum(double minimum) {
87 engine.setProperty(Properties.MINIMUM, minimum);
88 }
89
90 /**
91 * Returns <code>true</code> if the attribute "minimum" is set.
92 * @return <code>true</code> if the attribute is set.
93 */
94 public boolean isMinimumSetted() {
95 return engine.isPropertySetted(Properties.MINIMUM);
96 }
97
98 /**
99 * Returns an int value specifying the upper limit for the value of the component.
100 * @return maximum
101 */
102 public double getMaximum() {
103 return getMaximum(null);
104 }
105
106 /**
107 * Returns an int value specifying the upper limit for the value of the component.
108 * @return maximum
109 */
110 public double getMaximum(javax.faces.context.FacesContext facesContext) {
111 return engine.getDoubleProperty(Properties.MAXIMUM, 0.0, facesContext);
112 }
113
114 /**
115 * Sets an int value specifying the upper limit for the value of the component.
116 * @param maximum maximum
117 */
118 public void setMaximum(double maximum) {
119 engine.setProperty(Properties.MAXIMUM, maximum);
120 }
121
122 /**
123 * Sets an int value specifying the upper limit for the value of the component.
124 * @param maximum maximum
125 */
126 /**
127 * Returns <code>true</code> if the attribute "maximum" is set.
128 * @return <code>true</code> if the attribute is set.
129 */
130 public boolean isMaximumSetted() {
131 return engine.isPropertySetted(Properties.MAXIMUM);
132 }
133
134 /**
135 * Returns a boolean value indicating wether to start from the beginning when reaching the end or not. And vice versa.
136 * @return true if the component should cycle
137 */
138 public boolean isCycleValue() {
139 return isCycleValue(null);
140 }
141
142 /**
143 * Returns a boolean value indicating wether to start from the beginning when reaching the end or not. And vice versa.
144 * @return true if the component should cycle
145 */
146 public boolean isCycleValue(javax.faces.context.FacesContext facesContext) {
147 return engine.getBoolProperty(Properties.CYCLE_VALUE, false, facesContext);
148 }
149
150 /**
151 * Sets a boolean value indicating wether to start from the beginning when reaching the end or not. And vice versa.
152 * @param cycleValue true if the component should cycle
153 */
154 public void setCycleValue(boolean cycleValue) {
155 engine.setProperty(Properties.CYCLE_VALUE, cycleValue);
156 }
157
158 /**
159 * Sets a boolean value indicating wether to start from the beginning when reaching the end or not. And vice versa.
160 * @param cycleValue true if the component should cycle
161 */
162 /**
163 * Returns <code>true</code> if the attribute "cycleValue" is set.
164 * @return <code>true</code> if the attribute is set.
165 */
166 public boolean isCycleValueSetted() {
167 return engine.isPropertySetted(Properties.CYCLE_VALUE);
168 }
169
170 public String getStep() {
171 return getStep(null);
172 }
173
174 public String getStep(javax.faces.context.FacesContext facesContext) {
175 return engine.getStringProperty(Properties.STEP, facesContext);
176 }
177
178 public void setStep(String step) {
179 engine.setProperty(Properties.STEP, step);
180 }
181
182 /**
183 * Returns <code>true</code> if the attribute "step" is set.
184 * @return <code>true</code> if the attribute is set.
185 */
186 public boolean isStepSetted() {
187 return engine.isPropertySetted(Properties.STEP);
188 }
189
190 protected Set getCameliaFields() {
191 return CAMELIA_ATTRIBUTES;
192 }
193 }