/** * Checks whether event captions are rendered as HTML * <p> * The default is false, i.e. to render that caption as plain text. * * @return true if the captions are rendered as HTML, false if rendered as * plain text */ public boolean isEventCaptionAsHtml() { return getState(false).eventCaptionAsHtml; }
/** * Returns sort order for events. * * @return currently active sort strategy */ public EventSortOrder getEventSortOrder() { EventSortOrder order = getState(false).eventSortOrder; if (order == null) { return EventSortOrder.DURATION_DESC; } else { return order; } }
/** * Sets whether the event captions are rendered as HTML. * <p> * If set to true, the captions are rendered in the browser as HTML and the * developer is responsible for ensuring no harmful HTML is used. If set to * false, the caption is rendered in the browser as plain text. * <p> * The default is false, i.e. to render that caption as plain text. * * @param eventCaptionAsHtml * {@code true} if the captions are rendered as HTML, * {@code false} if rendered as plain text */ public void setEventCaptionAsHtml(boolean eventCaptionAsHtml) { getState().eventCaptionAsHtml = eventCaptionAsHtml; }
/** * Is the calendar in a mode where all days of the month is shown. * * @return Returns true if calendar is in monthly mode and false if it is in * weekly mode */ public boolean isMonthlyMode() { CalendarState state = getState(false); if (state.days != null) { return state.days.size() > 7; } else { // Default mode return true; } }
/** * Sets sort order for events. By default sort order is * {@link EventSortOrder#DURATION_DESC}. * * @param order * sort strategy for events */ public void setEventSortOrder(EventSortOrder order) { if (order == null) { getState().eventSortOrder = EventSortOrder.DURATION_DESC; } else { getState().eventSortOrder = EventSortOrder.values()[order .ordinal()]; } }
/** * This method restricts the hours that are shown per day. This affects the * weekly view. The general contract is that <b>firstHour < lastHour</b>. * <p> * Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. * <p> * You can use {@link #autoScaleVisibleHoursOfDay()} for automatic scaling * of the visible hours based on current events. * * @param lastHour * the first hour of the day to show, between 0 and 23 * @see #autoScaleVisibleHoursOfDay() */ public void setLastVisibleHourOfDay(int lastHour) { if (this.lastHour != lastHour && lastHour >= 0 && lastHour <= 23 && lastHour >= getFirstVisibleHourOfDay()) { this.lastHour = lastHour; getState().lastHourOfDay = lastHour; } }
/** * <p> * This method restricts the weekdays that are shown. This affects both the * monthly and the weekly view. The general contract is that <b>firstDay < * lastDay</b>. * </p> * * <p> * Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. * </p> * * @param firstDay * the first day of the week to show, between 1 and 7 */ public void setFirstVisibleDayOfWeek(int firstDay) { if (this.firstDay != firstDay && firstDay >= 1 && firstDay <= 7 && getLastVisibleDayOfWeek() >= firstDay) { this.firstDay = firstDay; getState().firstVisibleDayOfWeek = firstDay; } }
/** * <p> * This method restricts the weekdays that are shown. This affects both the * monthly and the weekly view. The general contract is that <b>firstDay < * lastDay</b>. * </p> * * <p> * Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. * </p> * * @param lastDay * the first day of the week to show, between 1 and 7 */ public void setLastVisibleDayOfWeek(int lastDay) { if (this.lastDay != lastDay && lastDay >= 1 && lastDay <= 7 && getFirstVisibleDayOfWeek() <= lastDay) { this.lastDay = lastDay; getState().lastVisibleDayOfWeek = lastDay; } }
/** * <p> * This method restricts the hours that are shown per day. This affects the * weekly view. The general contract is that <b>firstHour < lastHour</b>. * </p> * * <p> * Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. * </p> * You can use {@link #autoScaleVisibleHoursOfDay()} for automatic scaling * of the visible hours based on current events. * * @param firstHour * the first hour of the day to show, between 0 and 23 * @see #autoScaleVisibleHoursOfDay() */ public void setFirstVisibleHourOfDay(int firstHour) { if (this.firstHour != firstHour && firstHour >= 0 && firstHour <= 23 && firstHour <= getLastVisibleHourOfDay()) { this.firstHour = firstHour; getState().firstHourOfDay = firstHour; } }
/** * <p> * Construct a Vaadin Calendar with event provider and a caption. Event * provider is obligatory, because calendar component will query active * events through it. * </p> * * <p> * By default, Vaadin Calendar will show dates from the start of the current * week to the end of the current week. Use {@link #setStartDate(Date)} and * {@link #setEndDate(Date)} to change this. * </p> * * @param eventProvider * Event provider, cannot be null. */ // this is the constructor every other constructor calls public Calendar(String caption, CalendarEventProvider eventProvider) { registerRpc(rpc); setCaption(caption); handlers = new HashMap<String, EventListener>(); setDefaultHandlers(); currentCalendar.setTime(new Date()); setEventProvider(eventProvider); getState().firstDayOfWeek = firstDay; getState().lastVisibleDayOfWeek = lastDay; getState().firstHourOfDay = firstHour; getState().lastHourOfDay = lastHour; setTimeFormat(null); }
CalendarState state = getState();
@Override public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); initCalendarWithLocale(); getState().format24H = TimeFormat.Format24H == getTimeFormat(); setupDaysAndActions(); setupCalendarEvents(); rpc.scroll(scrollTop); }
getState().events = calendarStateEvents;