1 package org.rcfaces.core.component;
2
3 import org.rcfaces.core.component.capability.ISelectionEventCapability;
4 import org.rcfaces.core.internal.component.Properties;
5 import org.apache.commons.logging.LogFactory;
6 import org.rcfaces.core.component.AbstractCommandComponent;
7 import org.rcfaces.core.component.capability.IAlternateTextCapability;
8 import org.rcfaces.core.component.capability.IFocusStyleClassCapability;
9 import org.rcfaces.core.component.capability.ITextDirectionCapability;
10 import org.rcfaces.core.component.capability.IReadOnlyCapability;
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.capability.ITextCapability;
17
18
19
20
21
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 public class ButtonComponent extends AbstractCommandComponent implements
51 ITextCapability,
52 ITextDirectionCapability,
53 ISelectionEventCapability,
54 IReadOnlyCapability,
55 IAlternateTextCapability,
56 IFocusStyleClassCapability {
57
58 private static final Log LOG = LogFactory.getLog(ButtonComponent.class);
59
60 public static final String COMPONENT_TYPE="org.rcfaces.core.button";
61
62 protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCommandComponent.CAMELIA_ATTRIBUTES);
63 static {
64 CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"focusStyleClass","selectionListener","text","readOnly","alternateText","textDirection"}));
65 }
66
67 public ButtonComponent() {
68 setRendererType(COMPONENT_TYPE);
69 }
70
71 public ButtonComponent(String componentId) {
72 this();
73 setId(componentId);
74 }
75
76 public java.lang.String getText() {
77 return getText(null);
78 }
79
80
81
82
83 public java.lang.String getText(javax.faces.context.FacesContext facesContext) {
84 return engine.getStringProperty(Properties.TEXT, facesContext);
85 }
86
87
88
89
90
91 public final boolean isTextSetted() {
92 return engine.isPropertySetted(Properties.TEXT);
93 }
94
95 public void setText(java.lang.String text) {
96 engine.setProperty(Properties.TEXT, text);
97 }
98
99 public int getTextDirection() {
100 return getTextDirection(null);
101 }
102
103
104
105
106 public int getTextDirection(javax.faces.context.FacesContext facesContext) {
107 return engine.getIntProperty(Properties.TEXT_DIRECTION,0, facesContext);
108 }
109
110
111
112
113
114 public final boolean isTextDirectionSetted() {
115 return engine.isPropertySetted(Properties.TEXT_DIRECTION);
116 }
117
118 public void setTextDirection(int textDirection) {
119 engine.setProperty(Properties.TEXT_DIRECTION, textDirection);
120 }
121
122 public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
123 addFacesListener(listener);
124 }
125
126 public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
127 removeFacesListener(listener);
128 }
129
130 public final javax.faces.event.FacesListener [] listSelectionListeners() {
131 return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
132 }
133
134 public boolean isReadOnly() {
135 return isReadOnly(null);
136 }
137
138
139
140
141 public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
142 return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
143 }
144
145
146
147
148
149 public final boolean isReadOnlySetted() {
150 return engine.isPropertySetted(Properties.READ_ONLY);
151 }
152
153 public void setReadOnly(boolean readOnly) {
154 engine.setProperty(Properties.READ_ONLY, readOnly);
155 }
156
157 public java.lang.String getAlternateText() {
158 return getAlternateText(null);
159 }
160
161
162
163
164 public java.lang.String getAlternateText(javax.faces.context.FacesContext facesContext) {
165 return engine.getStringProperty(Properties.ALTERNATE_TEXT, facesContext);
166 }
167
168
169
170
171
172 public final boolean isAlternateTextSetted() {
173 return engine.isPropertySetted(Properties.ALTERNATE_TEXT);
174 }
175
176 public void setAlternateText(java.lang.String alternateText) {
177 engine.setProperty(Properties.ALTERNATE_TEXT, alternateText);
178 }
179
180 public java.lang.String getFocusStyleClass() {
181 return getFocusStyleClass(null);
182 }
183
184
185
186
187 public java.lang.String getFocusStyleClass(javax.faces.context.FacesContext facesContext) {
188 return engine.getStringProperty(Properties.FOCUS_STYLE_CLASS, facesContext);
189 }
190
191
192
193
194
195 public final boolean isFocusStyleClassSetted() {
196 return engine.isPropertySetted(Properties.FOCUS_STYLE_CLASS);
197 }
198
199 public void setFocusStyleClass(java.lang.String focusStyleClass) {
200 engine.setProperty(Properties.FOCUS_STYLE_CLASS, focusStyleClass);
201 }
202
203 protected Set getCameliaFields() {
204 return CAMELIA_ATTRIBUTES;
205 }
206 }