View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.component.ExpandableItemComponent;
4   import org.rcfaces.core.internal.component.Properties;
5   import org.apache.commons.logging.LogFactory;
6   import org.rcfaces.core.component.capability.IAcceleratorKeyCapability;
7   import org.rcfaces.core.component.capability.IAccessKeyCapability;
8   import org.rcfaces.core.internal.tools.MenuTools;
9   import org.rcfaces.core.component.iterator.IMenuItemIterator;
10  import org.rcfaces.core.component.capability.IImmediateCapability;
11  import org.rcfaces.core.component.IMenuComponent;
12  import javax.el.ValueExpression;
13  import java.util.HashSet;
14  import org.apache.commons.logging.Log;
15  import org.rcfaces.core.component.capability.IStyleClassCapability;
16  import java.util.Set;
17  import java.util.Arrays;
18  import org.rcfaces.core.component.capability.IMenuEventCapability;
19  
20  /**
21   * A menu item
22   */
23  public class MenuItemComponent extends ExpandableItemComponent implements 
24  	IAccessKeyCapability,
25  	IAcceleratorKeyCapability,
26  	IStyleClassCapability,
27  	IImmediateCapability,
28  	IMenuEventCapability {
29  
30  	private static final Log LOG = LogFactory.getLog(MenuItemComponent.class);
31  
32  	public static final String COMPONENT_TYPE="org.rcfaces.core.menuItem";
33  
34  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(ExpandableItemComponent.CAMELIA_ATTRIBUTES);
35  	static {
36  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"acceleratorKey","immediate","accessKey","removeAllWhenShown","menuListener","styleClass"}));
37  	}
38  
39  	public MenuItemComponent() {
40  		setRendererType(null);
41  	}
42  
43  	public MenuItemComponent(String componentId) {
44  		this();
45  		setId(componentId);
46  	}
47  
48  	public IMenuComponent getMenu() {
49  
50  
51  		return MenuTools.getMenu(this);
52  		
53  	}
54  
55  	public IMenuItemIterator listMenuItems() {
56  
57  
58  		return MenuTools.listMenuItems(this);
59  		
60  	}
61  
62  	public java.lang.String getAccessKey() {
63  		return getAccessKey(null);
64  	}
65  
66  	/**
67  	 * See {@link #getAccessKey() getAccessKey()} for more details
68  	 */
69  	public java.lang.String getAccessKey(javax.faces.context.FacesContext facesContext) {
70  		return engine.getStringProperty(Properties.ACCESS_KEY, facesContext);
71  	}
72  
73  	/**
74  	 * Returns <code>true</code> if the attribute "accessKey" is set.
75  	 * @return <code>true</code> if the attribute is set.
76  	 */
77  	public final boolean isAccessKeySetted() {
78  		return engine.isPropertySetted(Properties.ACCESS_KEY);
79  	}
80  
81  	public void setAccessKey(java.lang.String accessKey) {
82  		engine.setProperty(Properties.ACCESS_KEY, accessKey);
83  	}
84  
85  	public java.lang.String getAcceleratorKey() {
86  		return getAcceleratorKey(null);
87  	}
88  
89  	/**
90  	 * See {@link #getAcceleratorKey() getAcceleratorKey()} for more details
91  	 */
92  	public java.lang.String getAcceleratorKey(javax.faces.context.FacesContext facesContext) {
93  		return engine.getStringProperty(Properties.ACCELERATOR_KEY, facesContext);
94  	}
95  
96  	/**
97  	 * Returns <code>true</code> if the attribute "acceleratorKey" is set.
98  	 * @return <code>true</code> if the attribute is set.
99  	 */
100 	public final boolean isAcceleratorKeySetted() {
101 		return engine.isPropertySetted(Properties.ACCELERATOR_KEY);
102 	}
103 
104 	public void setAcceleratorKey(java.lang.String acceleratorKey) {
105 		engine.setProperty(Properties.ACCELERATOR_KEY, acceleratorKey);
106 	}
107 
108 	public java.lang.String getStyleClass() {
109 		return getStyleClass(null);
110 	}
111 
112 	/**
113 	 * See {@link #getStyleClass() getStyleClass()} for more details
114 	 */
115 	public java.lang.String getStyleClass(javax.faces.context.FacesContext facesContext) {
116 		return engine.getStringProperty(Properties.STYLE_CLASS, facesContext);
117 	}
118 
119 	/**
120 	 * Returns <code>true</code> if the attribute "styleClass" is set.
121 	 * @return <code>true</code> if the attribute is set.
122 	 */
123 	public final boolean isStyleClassSetted() {
124 		return engine.isPropertySetted(Properties.STYLE_CLASS);
125 	}
126 
127 	public void setStyleClass(java.lang.String styleClass) {
128 		engine.setProperty(Properties.STYLE_CLASS, styleClass);
129 	}
130 
131 	public boolean isImmediate() {
132 		return isImmediate(null);
133 	}
134 
135 	/**
136 	 * See {@link #isImmediate() isImmediate()} for more details
137 	 */
138 	public boolean isImmediate(javax.faces.context.FacesContext facesContext) {
139 		return engine.getBoolProperty(Properties.IMMEDIATE, false, facesContext);
140 	}
141 
142 	/**
143 	 * Returns <code>true</code> if the attribute "immediate" is set.
144 	 * @return <code>true</code> if the attribute is set.
145 	 */
146 	public final boolean isImmediateSetted() {
147 		return engine.isPropertySetted(Properties.IMMEDIATE);
148 	}
149 
150 	public void setImmediate(boolean immediate) {
151 		engine.setProperty(Properties.IMMEDIATE, immediate);
152 	}
153 
154 	public final void addMenuListener(org.rcfaces.core.event.IMenuListener listener) {
155 		addFacesListener(listener);
156 	}
157 
158 	public final void removeMenuListener(org.rcfaces.core.event.IMenuListener listener) {
159 		removeFacesListener(listener);
160 	}
161 
162 	public final javax.faces.event.FacesListener [] listMenuListeners() {
163 		return getFacesListeners(org.rcfaces.core.event.IMenuListener.class);
164 	}
165 
166 	/**
167 	 * Returns a boolean value specifying wether the content of the component must be remove before the listener is called and the component displayed.
168 	 * @return true if content is removed when shown
169 	 */
170 	public boolean isRemoveAllWhenShown() {
171 		return isRemoveAllWhenShown(null);
172 	}
173 
174 	/**
175 	 * Returns a boolean value specifying wether the content of the component must be remove before the listener is called and the component displayed.
176 	 * @return true if content is removed when shown
177 	 */
178 	public boolean isRemoveAllWhenShown(javax.faces.context.FacesContext facesContext) {
179 		return engine.getBoolProperty(Properties.REMOVE_ALL_WHEN_SHOWN, false, facesContext);
180 	}
181 
182 	/**
183 	 * Sets a boolean value specifying wether the content of the component must be remove before the listener is called and the component displayed.
184 	 * @param removeAllWhenShown true if content is to be removed when shown
185 	 */
186 	public void setRemoveAllWhenShown(boolean removeAllWhenShown) {
187 		engine.setProperty(Properties.REMOVE_ALL_WHEN_SHOWN, removeAllWhenShown);
188 	}
189 
190 	/**
191 	 * Sets a boolean value specifying wether the content of the component must be remove before the listener is called and the component displayed.
192 	 * @param removeAllWhenShown true if content is to be removed when shown
193 	 */
194 	/**
195 	 * Returns <code>true</code> if the attribute "removeAllWhenShown" is set.
196 	 * @return <code>true</code> if the attribute is set.
197 	 */
198 	public boolean isRemoveAllWhenShownSetted() {
199 		return engine.isPropertySetted(Properties.REMOVE_ALL_WHEN_SHOWN);
200 	}
201 
202 	protected Set getCameliaFields() {
203 		return CAMELIA_ATTRIBUTES;
204 	}
205 }