View Javadoc

1   package org.rcfaces.core.component;
2   
3   import org.rcfaces.core.internal.component.Properties;
4   import org.rcfaces.core.internal.converter.CalendarModeConverter;
5   import org.rcfaces.core.internal.converter.CalendarLayoutConverter;
6   import java.lang.String;
7   import org.apache.commons.logging.LogFactory;
8   import org.rcfaces.core.component.capability.ICalendarModeCapability;
9   import org.rcfaces.core.component.capability.ICalendarLayoutCapability;
10  import org.rcfaces.core.component.capability.IBorderCapability;
11  import org.rcfaces.core.component.capability.IMultipleSelectCapability;
12  import org.rcfaces.core.component.AbstractCalendarComponent;
13  import javax.el.ValueExpression;
14  import java.util.HashSet;
15  import org.apache.commons.logging.Log;
16  import java.util.Set;
17  import java.util.Arrays;
18  
19  /**
20   * <p>The calendar Component shows a calendar. It can be customized in differents ways (days off, holidays, tool tips ...).</p>
21   * <p>The calendar Component has the following capabilities :
22   * <ul>
23   * <li>ISelectionEventCapability</li>
24   * <li>IReadOnlyCapability</li>
25   * <li>ILiteralLocaleCapability</li>
26   * <li>ILiteralTimeZoneCapability</li>
27   * <li>IComponentLocaleCapability</li>
28   * <li>IComponentTimeZoneCapability</li>
29   * <li>IClientDatesStrategyCapability</li>
30   * <li>IBorderCapability</li>
31   * <li>ICalendarLayoutCapability</li>
32   * <li>IMultipleSelectCapability</li>
33   * <li>ICalendarModeCapability</li>
34   * </ul>
35   * </p>
36   * 
37   * 
38   * <p>The default <a href="/apidocs/index.html?org/rcfaces/core/component/CalendarComponent.html">calendar</a> renderer is linked to the <a href="/jsdocs/index.html?f_calendar.html" target="_blank">f_calendar</a> javascript class. f_calendar extends f_component, fa_readOnly, fa_disabled, fa_itemsWrapper</p>
39   * <p> Table of the main component style classes: </p>
40   * <table border="1" cellpadding="3" cellspacing="0" width="100%">
41   * <tbody>
42   * 
43   * <tr style="text-align:left">
44   * <th  width="33%">Style Name</th>
45   * <th width="50%">Description</th>
46   * </tr>
47   * 
48   * <tr  style="text-align:left">
49   * <td width="33%">f_calendar_yearCursor</td>
50   * <td width="50%">Defines styles for the wrapper Table element used to change years of the calendar. Contains other style</td>
51   * </tr>
52   * <tr  style="text-align:left">
53   * <td width="33%">f_calendar_monthList</td>
54   * <td width="50%">Defines styles for the wrapper Table element the element containing the  months of year  </td>
55   * </tr>
56   * <tr  style="text-align:left">
57   * <td width="33%">f_calendar_dayList</td>
58   * <td width="50%">Defines styles for the wrapper Table element the element containing the day list of year  </td>
59   * </tr>
60   * <tr  style="text-align:left">
61   * <td width="33%">f_calendar_day</td>
62   * <td width="50%">Defines styles for the A element</td>
63   * </tr>
64   * 
65   * 
66   * </tbody>
67   * </table>
68   */
69  public class CalendarComponent extends AbstractCalendarComponent implements 
70  	IBorderCapability,
71  	ICalendarLayoutCapability,
72  	IMultipleSelectCapability,
73  	ICalendarModeCapability {
74  
75  	private static final Log LOG = LogFactory.getLog(CalendarComponent.class);
76  
77  	public static final String COMPONENT_TYPE="org.rcfaces.core.calendar";
78  
79  	protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCalendarComponent.CAMELIA_ATTRIBUTES);
80  	static {
81  		CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"multipleSelect","border","autoSelection","mode","calendarLayout"}));
82  	}
83  
84  	public CalendarComponent() {
85  		setRendererType(COMPONENT_TYPE);
86  	}
87  
88  	public CalendarComponent(String componentId) {
89  		this();
90  		setId(componentId);
91  	}
92  
93  	public void setMode(String calendarMode) {
94  
95  
96  			setMode(((Integer)CalendarModeConverter.SINGLETON.getAsObject(null, this, calendarMode)).intValue());
97  			
98  	}
99  
100 	public void setCalendarLayout(String layout) {
101 
102 
103 			setCalendarLayout(((Integer)CalendarLayoutConverter.SINGLETON.getAsObject(null, this, layout)).intValue());
104 		
105 	}
106 
107 	public boolean isBorder() {
108 		return isBorder(null);
109 	}
110 
111 	/**
112 	 * See {@link #isBorder() isBorder()} for more details
113 	 */
114 	public boolean isBorder(javax.faces.context.FacesContext facesContext) {
115 		return engine.getBoolProperty(Properties.BORDER, true, facesContext);
116 	}
117 
118 	/**
119 	 * Returns <code>true</code> if the attribute "border" is set.
120 	 * @return <code>true</code> if the attribute is set.
121 	 */
122 	public final boolean isBorderSetted() {
123 		return engine.isPropertySetted(Properties.BORDER);
124 	}
125 
126 	public void setBorder(boolean border) {
127 		engine.setProperty(Properties.BORDER, border);
128 	}
129 
130 	public int getCalendarLayout() {
131 		return getCalendarLayout(null);
132 	}
133 
134 	/**
135 	 * See {@link #getCalendarLayout() getCalendarLayout()} for more details
136 	 */
137 	public int getCalendarLayout(javax.faces.context.FacesContext facesContext) {
138 		return engine.getIntProperty(Properties.CALENDAR_LAYOUT,ICalendarLayoutCapability.DEFAULT_LAYOUT, facesContext);
139 	}
140 
141 	/**
142 	 * Returns <code>true</code> if the attribute "calendarLayout" is set.
143 	 * @return <code>true</code> if the attribute is set.
144 	 */
145 	public final boolean isCalendarLayoutSetted() {
146 		return engine.isPropertySetted(Properties.CALENDAR_LAYOUT);
147 	}
148 
149 	public void setCalendarLayout(int calendarLayout) {
150 		engine.setProperty(Properties.CALENDAR_LAYOUT, calendarLayout);
151 	}
152 
153 	public boolean isMultipleSelect() {
154 		return isMultipleSelect(null);
155 	}
156 
157 	/**
158 	 * See {@link #isMultipleSelect() isMultipleSelect()} for more details
159 	 */
160 	public boolean isMultipleSelect(javax.faces.context.FacesContext facesContext) {
161 		return engine.getBoolProperty(Properties.MULTIPLE_SELECT, false, facesContext);
162 	}
163 
164 	/**
165 	 * Returns <code>true</code> if the attribute "multipleSelect" is set.
166 	 * @return <code>true</code> if the attribute is set.
167 	 */
168 	public final boolean isMultipleSelectSetted() {
169 		return engine.isPropertySetted(Properties.MULTIPLE_SELECT);
170 	}
171 
172 	public void setMultipleSelect(boolean multipleSelect) {
173 		engine.setProperty(Properties.MULTIPLE_SELECT, multipleSelect);
174 	}
175 
176 	public int getMode() {
177 		return getMode(null);
178 	}
179 
180 	/**
181 	 * See {@link #getMode() getMode()} for more details
182 	 */
183 	public int getMode(javax.faces.context.FacesContext facesContext) {
184 		return engine.getIntProperty(Properties.MODE,0, facesContext);
185 	}
186 
187 	/**
188 	 * Returns <code>true</code> if the attribute "mode" is set.
189 	 * @return <code>true</code> if the attribute is set.
190 	 */
191 	public final boolean isModeSetted() {
192 		return engine.isPropertySetted(Properties.MODE);
193 	}
194 
195 	public void setMode(int mode) {
196 		engine.setProperty(Properties.MODE, mode);
197 	}
198 
199 	public boolean isAutoSelection() {
200 		return isAutoSelection(null);
201 	}
202 
203 	public boolean isAutoSelection(javax.faces.context.FacesContext facesContext) {
204 		return engine.getBoolProperty(Properties.AUTO_SELECTION, false, facesContext);
205 	}
206 
207 	public void setAutoSelection(boolean autoSelection) {
208 		engine.setProperty(Properties.AUTO_SELECTION, autoSelection);
209 	}
210 
211 	/**
212 	 * Returns <code>true</code> if the attribute "autoSelection" is set.
213 	 * @return <code>true</code> if the attribute is set.
214 	 */
215 	public boolean isAutoSelectionSetted() {
216 		return engine.isPropertySetted(Properties.AUTO_SELECTION);
217 	}
218 
219 	protected Set getCameliaFields() {
220 		return CAMELIA_ATTRIBUTES;
221 	}
222 }