@Override public String[] getDayNamesShort() { if (dayNamesShort != null) { return dayNamesShort; } else { return super.getDayNamesShort(); } }
@Override public String[] getMonthNamesShort() { if (monthNamesShort != null) { return monthNamesShort; } else { return super.getMonthNamesShort(); } }
@Override public List<CalendarEvent> getEvents(Date startDate, Date endDate) { List<CalendarEvent> events = getEventProvider().getEvents(startDate, endDate); cacheMinMaxTimeOfDay(events); return events; }
@Override public void eventClick(int eventIndex) { if (!isEventClickAllowed()) { return; } if (eventIndex >= 0 && eventIndex < events.size() && events.get(eventIndex) != null) { fireEventClick(eventIndex); } }
initCalendarWithLocale(); CalendarState state = getState(); startDate = getStartDate(); endDate = getEndDate(); state.dayNames = getDayNamesShort(); state.monthNames = getMonthNamesShort(); Date firstDateToShow = expandStartDate(startDate, durationInDays > 7); Date lastDateToShow = expandEndDate(endDate, durationInDays > 7); DateFormat weeklyCaptionFormatter = getWeeklyCaptionFormatter(); weeklyCaptionFormatter.setTimeZone(currentCalendar.getTimeZone()); day.date = df_date.format(date); day.localizedDateFormat = weeklyCaptionFormatter.format(date); day.dayOfWeek = getDowByLocale(currentCalendar); day.week = getWeek(currentCalendar); day.yearOfWeek = getYearOfWeek(currentCalendar); GregorianCalendar cal = new GregorianCalendar(getTimeZone(), getLocale()); cal.clear(); cal.set(currentCalendar.get(java.util.Calendar.YEAR), setActionsForDay(actionMap, start, end, actionHandler); } else {
Date firstDateToShow = expandStartDate(startDate, durationInDays > 7); Date lastDateToShow = expandEndDate(endDate, durationInDays > 7); events = getEventProvider().getEvents(firstDateToShow, lastDateToShow); cacheMinMaxTimeOfDay(events); getState().events = calendarStateEvents;
/** * Fires event when a date was clicked in the calendar. Uses an existing * event from the event cache. * * @param index * The index of the event in the event cache. */ protected void fireEventClick(Integer index) { fireEvent(new EventClick(this, events.get(index))); }
/** * Set the handler for the given type information. Mirrors * {@link #addListener(String, Class, Object, Method) addListener} from * AbstractComponent * * @param eventId * A unique id for the event. Usually one of * {@link CalendarEventId} * @param eventType * The class of the event, most likely a subclass of * {@link CalendarComponentEvent} * @param listener * A listener that listens to the given event * @param listenerMethod * The method on the lister to call when the event is triggered */ protected void setHandler(String eventId, Class<?> eventType, EventListener listener, Method listenerMethod) { if (handlers.get(eventId) != null) { removeListener(eventId, eventType, handlers.get(eventId)); handlers.remove(eventId); } if (listener != null) { addListener(eventId, eventType, listener, listenerMethod); handlers.put(eventId, listener); } }
@Override public TargetDetails translateDropTargetDetails( Map<String, Object> clientVariables) { Map<String, Object> serverVariables = new HashMap<String, Object>(); if (clientVariables.containsKey("dropSlotIndex")) { int slotIndex = (Integer) clientVariables.get("dropSlotIndex"); int dayIndex = (Integer) clientVariables.get("dropDayIndex"); currentCalendar.setTime(getStartOfDay(currentCalendar, startDate)); currentCalendar.add(java.util.Calendar.DATE, dayIndex); // change this if slot length is modified currentCalendar.add(java.util.Calendar.MINUTE, slotIndex * 30); serverVariables.put("dropTime", currentCalendar.getTime()); } else { int dayIndex = (Integer) clientVariables.get("dropDayIndex"); currentCalendar.setTime(expandStartDate(startDate, true)); currentCalendar.add(java.util.Calendar.DATE, dayIndex); serverVariables.put("dropDay", currentCalendar.getTime()); } serverVariables.put("mouseEvent", clientVariables.get("mouseEvent")); CalendarTargetDetails td = new CalendarTargetDetails(serverVariables, this); td.setHasDropTime(clientVariables.containsKey("dropSlotIndex")); return td; }
@Override public void dateClick(String date) { if (date != null && date.length() > 6) { try { Date d = df_date.parse(date); fireDateClick(d); } catch (ParseException e) { } } }
/** * Fires event when a week was clicked in the calendar. * * @param week * The week that was clicked * @param year * The year of the week */ protected void fireWeekClick(int week, int year) { fireEvent(new WeekClick(this, week, year)); }
/** * Fires event when a date was clicked in the calendar. Creates a new event * for the date and passes it to the listener. * * @param date * The date and time that was clicked */ protected void fireDateClick(Date date) { fireEvent(new DateClickEvent(this, date)); }
/** * Fires an event when the user selecing moving forward/backward in the * calendar. * * @param forward * True if the calendar moved forward else backward is assumed. */ protected void fireNavigationEvent(boolean forward) { if (forward) { fireEvent(new ForwardEvent(this)); } else { fireEvent(new BackwardEvent(this)); } }
/** * Fires an event range selected event. The event is fired when a user * highlights an area in the calendar. The highlighted areas start and end * dates are returned as arguments. * * @param from * The start date and time of the highlighted area * @param to * The end date and time of the highlighted area * @param monthlyMode * Is the calendar in monthly mode */ protected void fireRangeSelect(Date from, Date to, boolean monthlyMode) { fireEvent(new RangeSelectEvent(this, from, to, monthlyMode)); }
/** * Fires an event move event to all server side move listeners. * * @param index * The index of the event in the events list * @param newFromDatetime * The changed from date time */ protected void fireEventMove(int index, Date newFromDatetime) { MoveEvent event = new MoveEvent(this, events.get(index), newFromDatetime); if (calendarEventProvider instanceof EventMoveHandler) { // Notify event provider if it is an event move handler ((EventMoveHandler) calendarEventProvider).eventMove(event); } // Notify event move handler attached by using the // setHandler(EventMoveHandler) method fireEvent(event); }
/** * Fires an event resize event. The event is fired when a user resizes the * event in the calendar causing the time range of the event to increase or * decrease. The new start and end times are returned as arguments to this * method. * * @param index * The index of the event in the event cache * @param startTime * The new start date and time of the event * @param endTime * The new end date and time of the event */ protected void fireEventResize(int index, Date startTime, Date endTime) { EventResize event = new EventResize(this, events.get(index), startTime, endTime); if (calendarEventProvider instanceof EventResizeHandler) { // Notify event provider if it is an event resize handler ((EventResizeHandler) calendarEventProvider).eventResize(event); } // Notify event resize handler attached by using the // setHandler(EventMoveHandler) method fireEvent(event); }