001package org.gwtbootstrap3.extras.fullcalendar.client.ui; 002 003/* 004 * #%L 005 * GwtBootstrap3 006 * %% 007 * Copyright (C) 2013 - 2015 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 023import com.google.gwt.core.client.JavaScriptObject; 024import 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 */ 031public 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 String unselectCancel; 052 private String selectContraint; 053 private boolean selectable; 054 private boolean selectHelper; 055 private boolean unselectAuto = true; 056 private boolean selectOverlap = true; 057 058 public CalendarConfig() { 059 this(null); 060 } 061 062 public CalendarConfig(final Header header) { 063 if (header != null) { 064 setGeneralDisplay(new GeneralDisplay(header)); 065 } 066 } 067 068 public boolean isSelectable() { 069 return selectable; 070 } 071 072 public void setSelectable(final boolean selectable) { 073 this.selectable = selectable; 074 } 075 076 public boolean isSelectHelper() { 077 return selectHelper; 078 } 079 080 public void setSelectHelper(final boolean selectHelper) { 081 this.selectHelper = selectHelper; 082 } 083 084 public void setButtonText(final ButtonText bt) { 085 this.buttonText = bt; 086 } 087 088 public ButtonText getButtonText() { 089 return buttonText; 090 } 091 092 public void setMonthNames(final MonthNames mn) { 093 this.monthNames = mn; 094 } 095 096 public MonthNames getMonthNames() { 097 return monthNames; 098 } 099 100 public void setDayNames(final DayNames dn) { 101 this.dayNames = dn; 102 } 103 104 public DayNames getDayNames() { 105 return dayNames; 106 } 107 108 public EventRenderConfig getRenderConfig() { 109 return renderConfig; 110 } 111 112 public void setRenderHandler(final EventRenderConfig renderConfig) { 113 this.renderConfig = renderConfig; 114 } 115 116 public ColumnFormat getColumnFormat() { 117 return columnFormat; 118 } 119 120 public void setColumnFormat(final ColumnFormat columnFormat) { 121 this.columnFormat = columnFormat; 122 } 123 124 public TimeFormat getTimeFormat() { 125 return timeFormat; 126 } 127 128 public void setTimeFormat(final TimeFormat timeFormat) { 129 this.timeFormat = timeFormat; 130 } 131 132 public TitleFormat getTitleFormat() { 133 return titleFormat; 134 } 135 136 public void setTitleFormat(final TitleFormat titleFormat) { 137 this.titleFormat = titleFormat; 138 } 139 140 public String getWeekNumberTitle() { 141 return weekNumberTitle; 142 } 143 144 public void setWeekNumberTitle(final String weekNumberTitle) { 145 this.weekNumberTitle = weekNumberTitle; 146 } 147 148 public AgendaOptions getAgendaOptions() { 149 return agendaOptions; 150 } 151 152 public void setAgendaOptions(final AgendaOptions agendaOptions) { 153 this.agendaOptions = agendaOptions; 154 } 155 156 public GeneralDisplay getGeneralDisplay() { 157 return generalDisplay; 158 } 159 160 public void setGeneralDisplay(final GeneralDisplay generalDisplay) { 161 this.generalDisplay = generalDisplay; 162 } 163 164 public EventDataConfig getEventConfig() { 165 return eventConfig; 166 } 167 168 public void setEventConfig(final EventDataConfig eventConfig) { 169 this.eventConfig = eventConfig; 170 } 171 172 public ClickAndHoverConfig getClickHoverConfig() { 173 return clickHoverConfig; 174 } 175 176 public void setClickHoverConfig(final ClickAndHoverConfig clickHoverConfig) { 177 this.clickHoverConfig = clickHoverConfig; 178 } 179 180 public SelectConfig getSelectConfig() { 181 return selectConfig; 182 } 183 184 public void setSelectConfig(final SelectConfig selectConfig) { 185 this.selectConfig = selectConfig; 186 } 187 188 public DragAndResizeConfig getDragResizeConfig() { 189 return dragResizeConfig; 190 } 191 192 public void setDragResizeConfig(final DragAndResizeConfig dragResizeConfig) { 193 this.dragResizeConfig = dragResizeConfig; 194 } 195 196 public Language getLangauge() { 197 return langauge; 198 } 199 200 public void setLangauge(final Language langauge) { 201 this.langauge = langauge; 202 } 203 204 public String getTimezone() { 205 return timezone; 206 } 207 208 /** 209 * 'local', 'UTC', a timezone string ('America/Chicago') 210 * 211 * @param timezone 212 */ 213 public void setTimezone(final String timezone) { 214 this.timezone = timezone; 215 } 216 public boolean isUnselectAuto() { 217 return unselectAuto; 218 } 219 220 public void setUnselectAuto(final boolean unselectAuto) { 221 this.unselectAuto = unselectAuto; 222 } 223 224 public String getUnselectCancel() { 225 return unselectCancel; 226 } 227 228 public void setUnselectCancel(final String unselectCancel) { 229 this.unselectCancel = unselectCancel; 230 } 231 232 public boolean isSelectOverlap() { 233 return selectOverlap; 234 } 235 236 public void setSelectOverlap(final boolean selectOverlap) { 237 this.selectOverlap = selectOverlap; 238 } 239 240 public String getSelectContraint() { 241 return selectContraint; 242 } 243 244 public void setSelectContraint(final String selectContraint) { 245 this.selectContraint = selectContraint; 246 } 247 248 public JsArray<JavaScriptObject> getJavaScriptParameters() { 249 @SuppressWarnings("unchecked") 250 final JsArray<JavaScriptObject> params = (JsArray<JavaScriptObject>) JsArray.createArray(); 251 setParameter(params, getGeneralDisplay()); 252 setParameter(params, getButtonText()); 253 setParameter(params, getMonthNames()); 254 setParameter(params, getDayNames()); 255 setParameter(params, getDragResizeConfig()); 256 setParameter(params, getClickHoverConfig()); 257 setParameter(params, getSelectConfig()); 258 setParameter(params, getEventConfig()); 259 setParameter(params, getColumnFormat()); 260 setParameter(params, getTimeFormat()); 261 setParameter(params, getTitleFormat()); 262 setParameter(params, getAgendaOptions()); 263 setParameter(params, getRenderConfig()); 264 return params; 265 } 266 267 private void setParameter(final JsArray<JavaScriptObject> params, final IsJavaScriptObject isJS) { 268 if (isJS != null) { 269 params.push(isJS.toJavaScript()); 270 } 271 } 272}