View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.capability.IImmediateCapability;
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.rcfaces.core.component.capability.IKeyPressEventCapability;
9   import org.apache.commons.logging.LogFactory;
10  import java.util.Arrays;
11  import java.util.Set;
12  import org.rcfaces.core.component.capability.IForCapability;
13  import org.rcfaces.core.component.capability.IValidationEventCapability;
14  import org.rcfaces.core.internal.component.CameliaCommandComponent;
15  
16  /**
17   * <p>The accelerator Component is a non-visual component.</p>
18   * <p>It allows to associate an accelerator key to an action or another component.</p>
19   * <p>The accelerator Component has the following capabilities :
20   * <ul>
21   * <li>IKeyPressEventCapability</li>
22   * <li>IImmediateCapability</li>
23   * <li>IValidationEventCapability</li>
24   * <li>IForCapability</li>
25   * </ul>
26   * </p>
27   * 
28   * 
29   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/AcceleratorComponent.html">accelerator</a> renderer is linked to the <a href="/jsdocs/index.html?f_accelerator.html" target="_blank">f_accelerator</a> javascript class. f_accelerator extends f_object, fa_immediate, fa_eventTarget</p>
30   */
31  public class AcceleratorComponent extends CameliaCommandComponent implements 
32  	IKeyPressEventCapability,
33  	IImmediateCapability,
34  	IValidationEventCapability,
35  	IForCapability {
36  
37  	private static final Log LOG = LogFactory.getLog(AcceleratorComponent.class);
38  
39  	public static final String COMPONENT_TYPE="org.rcfaces.core.accelerator";
40  
41  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(CameliaCommandComponent.CAMELIA_ATTRIBUTES);
42  	static {
43  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"immediate","forItemValue","for","keyBinding","keyPressListener","ignoreEditableComponent","validationListener"}));
44  	}
45  
46  	public AcceleratorComponent() {
47  		setRendererType(COMPONENT_TYPE);
48  	}
49  
50  	public AcceleratorComponent(String componentId) {
51  		this();
52  		setId(componentId);
53  	}
54  
55  	public final void addKeyPressListener(org.rcfaces.core.event.IKeyPressListener listener) {
56  		addFacesListener(listener);
57  	}
58  
59  	public final void removeKeyPressListener(org.rcfaces.core.event.IKeyPressListener listener) {
60  		removeFacesListener(listener);
61  	}
62  
63  	public final javax.faces.event.FacesListener [] listKeyPressListeners() {
64  		return getFacesListeners(org.rcfaces.core.event.IKeyPressListener.class);
65  	}
66  
67  	public final void addValidationListener(org.rcfaces.core.event.IValidationListener listener) {
68  		addFacesListener(listener);
69  	}
70  
71  	public final void removeValidationListener(org.rcfaces.core.event.IValidationListener listener) {
72  		removeFacesListener(listener);
73  	}
74  
75  	public final javax.faces.event.FacesListener [] listValidationListeners() {
76  		return getFacesListeners(org.rcfaces.core.event.IValidationListener.class);
77  	}
78  
79  	public java.lang.String getFor() {
80  		return getFor(null);
81  	}
82  
83  	/**
84  	 * See {@link #getFor() getFor()} for more details
85  	 */
86  	public java.lang.String getFor(javax.faces.context.FacesContext facesContext) {
87  		return engine.getStringProperty(Properties.FOR, facesContext);
88  	}
89  
90  	/**
91  	 * Returns <code>true</code> if the attribute "for" is set.
92  	 * @return <code>true</code> if the attribute is set.
93  	 */
94  	public final boolean isForSetted() {
95  		return engine.isPropertySetted(Properties.FOR);
96  	}
97  
98  	public void setFor(java.lang.String forValue) {
99  		engine.setProperty(Properties.FOR, forValue);
100 	}
101 
102 	/**
103 	 * Returns a string specifying a value to select in the component identified in the <b>for</b> property.
104 	 * @return value to selected
105 	 */
106 	public String getForItemValue() {
107 		return getForItemValue(null);
108 	}
109 
110 	/**
111 	 * Returns a string specifying a value to select in the component identified in the <b>for</b> property.
112 	 * @return value to selected
113 	 */
114 	public String getForItemValue(javax.faces.context.FacesContext facesContext) {
115 		return engine.getStringProperty(Properties.FOR_ITEM_VALUE, facesContext);
116 	}
117 
118 	/**
119 	 * Sets a string specifying a value to select in the component identified in the <b>for</b> property.
120 	 * @param forItemValue value to select
121 	 */
122 	public void setForItemValue(String forItemValue) {
123 		engine.setProperty(Properties.FOR_ITEM_VALUE, forItemValue);
124 	}
125 
126 	/**
127 	 * Sets a string specifying a value to select in the component identified in the <b>for</b> property.
128 	 * @param forItemValue value to select
129 	 */
130 	/**
131 	 * Returns <code>true</code> if the attribute "forItemValue" is set.
132 	 * @return <code>true</code> if the attribute is set.
133 	 */
134 	public boolean isForItemValueSetted() {
135 		return engine.isPropertySetted(Properties.FOR_ITEM_VALUE);
136 	}
137 
138 	/**
139 	 * Returns a string value specifying the key associated to the component. for example "Alt+F1"
140 	 * @return key
141 	 */
142 	public String getKeyBinding() {
143 		return getKeyBinding(null);
144 	}
145 
146 	/**
147 	 * Returns a string value specifying the key associated to the component. for example "Alt+F1"
148 	 * @return key
149 	 */
150 	public String getKeyBinding(javax.faces.context.FacesContext facesContext) {
151 		return engine.getStringProperty(Properties.KEY_BINDING, facesContext);
152 	}
153 
154 	/**
155 	 * Sets a string value specifying the key associated to the component. for example "Alt+F1"
156 	 * @param keyBinding key
157 	 */
158 	public void setKeyBinding(String keyBinding) {
159 		engine.setProperty(Properties.KEY_BINDING, keyBinding);
160 	}
161 
162 	/**
163 	 * Sets a string value specifying the key associated to the component. for example "Alt+F1"
164 	 * @param keyBinding key
165 	 */
166 	/**
167 	 * Returns <code>true</code> if the attribute "keyBinding" is set.
168 	 * @return <code>true</code> if the attribute is set.
169 	 */
170 	public boolean isKeyBindingSetted() {
171 		return engine.isPropertySetted(Properties.KEY_BINDING);
172 	}
173 
174 	public boolean isIgnoreEditableComponent() {
175 		return isIgnoreEditableComponent(null);
176 	}
177 
178 	public boolean isIgnoreEditableComponent(javax.faces.context.FacesContext facesContext) {
179 		return engine.getBoolProperty(Properties.IGNORE_EDITABLE_COMPONENT, false, facesContext);
180 	}
181 
182 	public void setIgnoreEditableComponent(boolean ignoreEditableComponent) {
183 		engine.setProperty(Properties.IGNORE_EDITABLE_COMPONENT, ignoreEditableComponent);
184 	}
185 
186 	/**
187 	 * Returns <code>true</code> if the attribute "ignoreEditableComponent" is set.
188 	 * @return <code>true</code> if the attribute is set.
189 	 */
190 	public boolean isIgnoreEditableComponentSetted() {
191 		return engine.isPropertySetted(Properties.IGNORE_EDITABLE_COMPONENT);
192 	}
193 
194 	protected Set getCameliaFields() {
195 		return CAMELIA_ATTRIBUTES;
196 	}
197 }