View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.custom.schedule;
21  
22  import java.io.Serializable;
23  
24  import javax.faces.component.UIComponentBase;
25  import javax.faces.component.ValueHolder;
26  import javax.faces.context.FacesContext;
27  import javax.faces.convert.Converter;
28  
29  import org.apache.myfaces.custom.schedule.model.ScheduleModel;
30  import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
31  import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
32  
33  /**
34   * Base class for the Schedule component. This class contains all the properties
35   * for the schedule, but not the ActionSource stuff. Keeping these things separate
36   * should make the code a little easier to digest.
37   * 
38   * @JSFComponent
39   *   serialuid = "5702081384947086911L"
40   *   class = "org.apache.myfaces.custom.schedule.UIScheduleBase"
41   *   implements = "java.io.Serializable, javax.faces.component.ValueHolder"   
42   * @since 1.1.7
43   * @author Jurgen Lust
44   * @version $Revision: 691856 $
45   */
46  public abstract class AbstractUIScheduleBase extends UIComponentBase implements ValueHolder,
47          Serializable
48  {
49      //private static final long serialVersionUID = 5702081384947086911L;
50  
51      public static final String COMPONENT_FAMILY = "javax.faces.Panel";
52      public static final String COMPONENT_TYPE = "org.apache.myfaces.ScheduleBase";
53      public static final String RENDERER_TYPE = "org.apache.myfaces.Schedule";
54  
55      protected static final String HOUR_NOTATION_24 = "24";
56      protected static final String HOUR_NOTATION_12 = "12";
57  
58      protected static final int DEFAULT_COMPACT_MONTH_ROWHEIGHT = 120;
59      protected static final int DEFAULT_COMPACT_WEEK_ROWHEIGHT = 200;
60      protected static final int DEFAULT_DETAILED_ROWHEIGHT = 22;
61      protected static final boolean DEFAULT_EXPAND_TO_FIT = false;
62      protected static final String DEFAULT_HEADER_DATE_FORMAT = null;
63      protected static final boolean DEFAULT_IMMEDIATE = false;
64      protected static final boolean DEFAULT_READONLY = false;
65      protected static final boolean DEFAULT_RENDER_ZEROLENGTH = false;
66      protected static final String DEFAULT_THEME = "default";
67      protected static final boolean DEFAULT_TOOLTIP = false;
68      protected static final int DEFAULT_VISIBLE_END_HOUR = 20;
69      protected static final int DEFAULT_VISIBLE_START_HOUR = 8;
70      protected static final int DEFAULT_WORKING_END_HOUR = 17;
71      protected static final int DEFAULT_WORKING_START_HOUR = 9;
72      protected static final String DEFAULT_ENABLED_ON_USER_ROLE = null;
73      protected static final boolean DEFAULT_SUBMIT_ON_CLICK = false;
74      protected static final String DEFAULT_VISIBLE_ON_USER_ROLE = null;
75      protected static final boolean DEFAULT_SPLIT_WEEKEND = true;
76      
77      /**
78       * @JSFProperty
79       *   defaultValue = true;
80       */
81      public abstract boolean isSplitWeekend();
82      
83      /**
84       * Should the parent form of this schedule be submitted when the user
85       * clicks on a day? Note that this will only work when the readonly
86       * property is set to false.
87       * 
88       * @JSFProperty
89       *   defaultValue = "false"
90       * @return the _submitOnClick
91       */
92      public abstract boolean isSubmitOnClick();
93  
94      /**
95       * @JSFProperty
96       *   defaultValue="120"
97       * @return the compactMonthRowHeight
98       */
99      public abstract int getCompactMonthRowHeight();
100 
101     /**
102      * @JSFProperty
103      *   defaultValue = "200"
104      * @return the compactWeekRowHeight
105      */
106     public abstract int getCompactWeekRowHeight();
107 
108     /**
109      * @JSFProperty 
110      * @see javax.faces.component.ValueHolder#getConverter()
111      */
112     public abstract Converter getConverter();
113 
114     /**
115      * @JSFProperty
116      *   defaultValue = "22"
117      * @return the detailedRowHeight
118      */
119     public abstract int getDetailedRowHeight();
120 
121     /**
122      * @JSFProperty
123      *   defaultValue = "false"
124      * @return the expandToFitEntries
125      */
126     public abstract boolean isExpandToFitEntries();
127 
128     /**
129      * @see javax.faces.component.UIComponent#getFamily()
130      */
131     public String getFamily()
132     {
133         return COMPONENT_FAMILY;
134     }
135 
136     /**
137      * @JSFProperty
138      * @return the headerDateFormat
139      */
140     public abstract String getHeaderDateFormat();
141 
142     /**
143      * @JSFProperty
144      *   defaultValue="false"
145      * @return the immediate
146      */
147     public abstract boolean isImmediate();
148 
149     /**
150      * @see javax.faces.component.ValueHolder#getLocalValue()
151      */
152     public abstract Object getLocalValue();
153 
154     /**
155      * The underlying model
156      *
157      * @return Returns the model.
158      */
159     public ScheduleModel getModel()
160     {
161         if (getValue() instanceof ScheduleModel)
162         {
163             return (ScheduleModel) getValue();
164         }
165         else
166         {
167             return new SimpleScheduleModel();
168         }
169     }
170 
171     /**
172      * @JSFProperty
173      *   defaultValue="false"
174      * @return the readonly
175      */
176     public abstract boolean isReadonly();
177 
178     /**
179      * @see javax.faces.component.UIComponentBase#getRendersChildren()
180      */
181     public boolean isRendersChildren()
182     {
183         return true;
184     }
185 
186     /**
187      * @JSFProperty
188      * @return the renderZeroLengthEntries
189      */
190     public abstract boolean isRenderZeroLengthEntries();
191 
192     /**
193      * @JSFProperty
194      *   defaultValue = "default"
195      * @return the theme
196      */
197     public abstract String getTheme();
198 
199     /**
200      * @JSFProperty
201      *   defaultValue = "false"
202      * @return the tooltip
203      */
204     public abstract boolean isTooltip();
205 
206     /**
207      * @JSFProperty
208      *   localMethod="true"
209      *   localMethodScope="public"
210      * @see javax.faces.component.ValueHolder#getValue()
211      */
212     public abstract Object getValue();
213 
214     /**
215      * @JSFProperty
216      *   defaultValue = "20"
217      * @return the visibleEndHour
218      */
219     public abstract int getVisibleEndHour();
220 
221     /**
222      * @JSFProperty
223      *   defaultValue = "8"
224      * @return the visibleStartHour
225      */
226     public abstract int getVisibleStartHour();
227 
228     /**
229      * @JSFProperty
230      *   defaultValue = "17"
231      * @return the workingEndHour
232      */
233     public abstract int getWorkingEndHour();
234 
235     /**
236      * @JSFProperty
237      *   defaultValue="9"
238      * @return the workingStartHour
239      */
240     public abstract int getWorkingStartHour();
241 
242     /**
243      * <p>
244      * Show dates in 24 hour notation or 12 hour notation.
245      * </p>
246      * @JSFProperty
247      * @return "12", "24" or null for the renderer default
248      */
249     public abstract String getHourNotation();
250 
251     /**
252      * @JSFProperty
253      * @return the headerDateFormat
254      */
255     public abstract String getCompactMonthDayOfWeekDateFormat();
256     
257     /**
258      * The underlying model
259      *
260      * @param model The model to set.
261      */
262     public void setModel(ScheduleModel model)
263     {
264         setValue(model);
265     }
266 
267 }