001    package org.gwtbootstrap3.extras.fullcalendar.client.ui;
002    
003    /*
004     * #%L
005     * GwtBootstrap3
006     * %%
007     * Copyright (C) 2013 - 2014 GwtBootstrap3
008     * %%
009     * Licensed under the Apache License, Version 2.0 (the "License");
010     * you may not use this file except in compliance with the License.
011     * You may obtain a copy of the License at
012     * 
013     *      http://www.apache.org/licenses/LICENSE-2.0
014     * 
015     * Unless required by applicable law or agreed to in writing, software
016     * distributed under the License is distributed on an "AS IS" BASIS,
017     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018     * See the License for the specific language governing permissions and
019     * limitations under the License.
020     * #L%
021     */
022    
023    import com.google.gwt.core.client.JavaScriptObject;
024    import com.google.gwt.core.client.JsArray;
025    
026    /**
027     * Container class for all the javascript parameters to pass to <code>FullCalendar</code>
028     *
029     * @author Jeff Isenhart
030     */
031    public class CalendarConfig {
032    
033        private Language langauge;//http://arshaw.com/fullcalendar/docs/text/lang/
034    
035        private ClickAndHoverConfig clickHoverConfig;//http://arshaw.com/fullcalendar/docs/mouse/
036        private SelectConfig selectConfig;//http://arshaw.com/fullcalendar/docs/selection/
037        private DragAndResizeConfig dragResizeConfig;//http://arshaw.com/fullcalendar/docs/event_ui/;
038        private EventDataConfig eventConfig;//http://arshaw.com/fullcalendar/docs/event_data/
039        private GeneralDisplay generalDisplay;//http://arshaw.com/fullcalendar/docs/display/
040        private ButtonText buttonText;//http://arshaw.com/fullcalendar/docs/text/buttonText/
041        private MonthNames monthNames;//http://arshaw.com/fullcalendar/docs/text/monthNames/
042        private ColumnFormat columnFormat;//http://arshaw.com/fullcalendar/docs/text/columnFormat/
043        private TimeFormat timeFormat;//http://arshaw.com/fullcalendar/docs/text/timeFormat/
044        private TitleFormat titleFormat;//http://arshaw.com/fullcalendar/docs/text/titleFormat/
045        private AgendaOptions agendaOptions;//http://arshaw.com/fullcalendar/docs/agenda/
046        private DayNames dayNames;//http://arshaw.com/fullcalendar/docs/text/dayNames/
047        private EventRenderConfig renderConfig;//http://arshaw.com/fullcalendar/docs/event_rendering/eventRender/
048    
049        private String weekNumberTitle;
050        private String timezone;
051        private boolean selectable;
052        private boolean selectHelper;
053    
054        public CalendarConfig() {
055            this(null);
056        }
057    
058        public CalendarConfig(final Header header) {
059            if (header != null) {
060                setGeneralDisplay(new GeneralDisplay(header));
061            }
062        }
063    
064        public boolean isSelectable() {
065            return selectable;
066        }
067    
068        public void setSelectable(final boolean selectable) {
069            this.selectable = selectable;
070        }
071    
072        public boolean isSelectHelper() {
073            return selectHelper;
074        }
075    
076        public void setSelectHelper(final boolean selectHelper) {
077            this.selectHelper = selectHelper;
078        }
079    
080        public void setButtonText(final ButtonText bt) {
081            this.buttonText = bt;
082        }
083    
084        public ButtonText getButtonText() {
085            return buttonText;
086        }
087    
088        public void setMonthNames(final MonthNames mn) {
089            this.monthNames = mn;
090        }
091    
092        public MonthNames getMonthNames() {
093            return monthNames;
094        }
095    
096        public void setDayNames(final DayNames dn) {
097            this.dayNames = dn;
098        }
099    
100        public DayNames getDayNames() {
101            return dayNames;
102        }
103    
104        public EventRenderConfig getRenderConfig() {
105            return renderConfig;
106        }
107    
108        public void setRenderHandler(final EventRenderConfig renderConfig) {
109            this.renderConfig = renderConfig;
110        }
111    
112        public ColumnFormat getColumnFormat() {
113            return columnFormat;
114        }
115    
116        public void setColumnFormat(final ColumnFormat columnFormat) {
117            this.columnFormat = columnFormat;
118        }
119    
120        public TimeFormat getTimeFormat() {
121            return timeFormat;
122        }
123    
124        public void setTimeFormat(final TimeFormat timeFormat) {
125            this.timeFormat = timeFormat;
126        }
127    
128        public TitleFormat getTitleFormat() {
129            return titleFormat;
130        }
131    
132        public void setTitleFormat(final TitleFormat titleFormat) {
133            this.titleFormat = titleFormat;
134        }
135    
136        public String getWeekNumberTitle() {
137            return weekNumberTitle;
138        }
139    
140        public void setWeekNumberTitle(final String weekNumberTitle) {
141            this.weekNumberTitle = weekNumberTitle;
142        }
143    
144        public AgendaOptions getAgendaOptions() {
145            return agendaOptions;
146        }
147    
148        public void setAgendaOptions(final AgendaOptions agendaOptions) {
149            this.agendaOptions = agendaOptions;
150        }
151    
152        public GeneralDisplay getGeneralDisplay() {
153            return generalDisplay;
154        }
155    
156        public void setGeneralDisplay(final GeneralDisplay generalDisplay) {
157            this.generalDisplay = generalDisplay;
158        }
159    
160        public EventDataConfig getEventConfig() {
161            return eventConfig;
162        }
163    
164        public void setEventConfig(final EventDataConfig eventConfig) {
165            this.eventConfig = eventConfig;
166        }
167    
168        public ClickAndHoverConfig getClickHoverConfig() {
169            return clickHoverConfig;
170        }
171    
172        public void setClickHoverConfig(final ClickAndHoverConfig clickHoverConfig) {
173            this.clickHoverConfig = clickHoverConfig;
174        }
175        
176        public SelectConfig getSelectConfig() {
177            return selectConfig;
178        }
179    
180        public void setSelectConfig(final SelectConfig selectConfig) {
181            this.selectConfig = selectConfig;
182        }
183    
184        public DragAndResizeConfig getDragResizeConfig() {
185            return dragResizeConfig;
186        }
187    
188        public void setDragResizeConfig(final DragAndResizeConfig dragResizeConfig) {
189            this.dragResizeConfig = dragResizeConfig;
190        }
191    
192        public Language getLangauge() {
193            return langauge;
194        }
195    
196        public void setLangauge(final Language langauge) {
197            this.langauge = langauge;
198        }
199    
200        public String getTimezone() {
201            return timezone;
202        }
203    
204        /**
205         * 'local', 'UTC', a timezone string ('America/Chicago')
206         *
207         * @param timezone
208         */
209        public void setTimezone(final String timezone) {
210            this.timezone = timezone;
211        }
212    
213        public JsArray<JavaScriptObject> getJavaScriptParameters() {
214            final JsArray<JavaScriptObject> params = (JsArray<JavaScriptObject>) JsArray.createArray();
215            setParameter(params, getGeneralDisplay());
216            setParameter(params, getButtonText());
217            setParameter(params, getMonthNames());
218            setParameter(params, getDayNames());
219            setParameter(params, getDragResizeConfig());
220            setParameter(params, getClickHoverConfig());
221            setParameter(params, getSelectConfig());
222            setParameter(params, getEventConfig());
223            setParameter(params, getColumnFormat());
224            setParameter(params, getTimeFormat());
225            setParameter(params, getTitleFormat());
226            setParameter(params, getAgendaOptions());
227            setParameter(params, getRenderConfig());
228            return params;
229        }
230    
231        private void setParameter(final JsArray<JavaScriptObject> params, final IsJavaScriptObject isJS) {
232            if (isJS != null) {
233                params.push(isJS.toJavaScript());
234            }
235        }
236    }