View Javadoc

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.capability.IBorderCapability;
7   import org.rcfaces.core.component.AbstractCommandComponent;
8   import org.rcfaces.core.component.capability.IBorderTypeCapability;
9   import org.rcfaces.core.component.capability.IReadOnlyCapability;
10  import javax.el.ValueExpression;
11  import java.util.HashSet;
12  import org.apache.commons.logging.Log;
13  import java.util.Set;
14  import java.util.Arrays;
15  import org.rcfaces.core.component.capability.IDoubleClickEventCapability;
16  
17  /**
18   * A button Component highly customizable through its API.
19   */
20  public class CustomButtonComponent extends AbstractCommandComponent implements 
21  	IBorderTypeCapability,
22  	IBorderCapability,
23  	ISelectionEventCapability,
24  	IDoubleClickEventCapability,
25  	IReadOnlyCapability {
26  
27  	private static final Log LOG = LogFactory.getLog(CustomButtonComponent.class);
28  
29  	public static final String COMPONENT_TYPE="org.rcfaces.core.customButton";
30  
31  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCommandComponent.CAMELIA_ATTRIBUTES);
32  	static {
33  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"selectionListener","readOnly","borderType","doubleClickListener","border"}));
34  	}
35  
36  	public CustomButtonComponent() {
37  		setRendererType(COMPONENT_TYPE);
38  	}
39  
40  	public CustomButtonComponent(String componentId) {
41  		this();
42  		setId(componentId);
43  	}
44  
45  	public java.lang.String getBorderType() {
46  		return getBorderType(null);
47  	}
48  
49  	/**
50  	 * See {@link #getBorderType() getBorderType()} for more details
51  	 */
52  	public java.lang.String getBorderType(javax.faces.context.FacesContext facesContext) {
53  		return engine.getStringProperty(Properties.BORDER_TYPE, facesContext);
54  	}
55  
56  	/**
57  	 * Returns <code>true</code> if the attribute "borderType" is set.
58  	 * @return <code>true</code> if the attribute is set.
59  	 */
60  	public final boolean isBorderTypeSetted() {
61  		return engine.isPropertySetted(Properties.BORDER_TYPE);
62  	}
63  
64  	public void setBorderType(java.lang.String borderType) {
65  		engine.setProperty(Properties.BORDER_TYPE, borderType);
66  	}
67  
68  	public boolean isBorder() {
69  		return isBorder(null);
70  	}
71  
72  	/**
73  	 * See {@link #isBorder() isBorder()} for more details
74  	 */
75  	public boolean isBorder(javax.faces.context.FacesContext facesContext) {
76  		return engine.getBoolProperty(Properties.BORDER, true, facesContext);
77  	}
78  
79  	/**
80  	 * Returns <code>true</code> if the attribute "border" is set.
81  	 * @return <code>true</code> if the attribute is set.
82  	 */
83  	public final boolean isBorderSetted() {
84  		return engine.isPropertySetted(Properties.BORDER);
85  	}
86  
87  	public void setBorder(boolean border) {
88  		engine.setProperty(Properties.BORDER, border);
89  	}
90  
91  	public final void addSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
92  		addFacesListener(listener);
93  	}
94  
95  	public final void removeSelectionListener(org.rcfaces.core.event.ISelectionListener listener) {
96  		removeFacesListener(listener);
97  	}
98  
99  	public final javax.faces.event.FacesListener [] listSelectionListeners() {
100 		return getFacesListeners(org.rcfaces.core.event.ISelectionListener.class);
101 	}
102 
103 	public final void addDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
104 		addFacesListener(listener);
105 	}
106 
107 	public final void removeDoubleClickListener(org.rcfaces.core.event.IDoubleClickListener listener) {
108 		removeFacesListener(listener);
109 	}
110 
111 	public final javax.faces.event.FacesListener [] listDoubleClickListeners() {
112 		return getFacesListeners(org.rcfaces.core.event.IDoubleClickListener.class);
113 	}
114 
115 	public boolean isReadOnly() {
116 		return isReadOnly(null);
117 	}
118 
119 	/**
120 	 * See {@link #isReadOnly() isReadOnly()} for more details
121 	 */
122 	public boolean isReadOnly(javax.faces.context.FacesContext facesContext) {
123 		return engine.getBoolProperty(Properties.READ_ONLY, false, facesContext);
124 	}
125 
126 	/**
127 	 * Returns <code>true</code> if the attribute "readOnly" is set.
128 	 * @return <code>true</code> if the attribute is set.
129 	 */
130 	public final boolean isReadOnlySetted() {
131 		return engine.isPropertySetted(Properties.READ_ONLY);
132 	}
133 
134 	public void setReadOnly(boolean readOnly) {
135 		engine.setProperty(Properties.READ_ONLY, readOnly);
136 	}
137 
138 	protected Set getCameliaFields() {
139 		return CAMELIA_ATTRIBUTES;
140 	}
141 }