2 * Copyright 2000-2018 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.v7.ui.components.calendar;
18 import java.io.Serializable;
19 import java.lang.reflect.Method;
20 import java.util.Date;
21 import java.util.EventListener;
23 import com.vaadin.event.SerializableEventListener;
24 import com.vaadin.util.ReflectTools;
25 import com.vaadin.v7.shared.ui.calendar.CalendarEventId;
26 import com.vaadin.v7.ui.Calendar;
27 import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
30 * Interface for all Vaadin Calendar events.
35 * @deprecated As of 8.0, no replacement available.
38 public interface CalendarComponentEvents extends Serializable {
41 * Notifier interface for notifying listener of calendar events.
44 public interface CalendarEventNotifier extends Serializable {
46 * Get the assigned event handler for the given eventId.
49 * @return the assigned eventHandler, or null if no handler is assigned
51 public EventListener getHandler(String eventId);
55 * Notifier interface for event drag & drops.
58 public interface EventMoveNotifier extends CalendarEventNotifier {
61 * Set the EventMoveHandler.
64 * EventMoveHandler to be added
66 public void setHandler(EventMoveHandler listener);
71 * MoveEvent is sent when existing event is dragged to a new position.
73 @SuppressWarnings("serial")
75 public class MoveEvent extends CalendarComponentEvent {
77 public static final String EVENT_ID = CalendarEventId.EVENTMOVE;
79 /** Index for the moved Schedule.Event. */
80 private CalendarEvent calendarEvent;
82 /** New starting date for the moved Calendar.Event. */
83 private Date newStart;
86 * MoveEvent needs the target event and new start date.
90 * @param calendarEvent
93 * Target event's new start date.
95 public MoveEvent(Calendar source, CalendarEvent calendarEvent,
99 this.calendarEvent = calendarEvent;
100 this.newStart = newStart;
106 * @return Target event.
108 public CalendarEvent getCalendarEvent() {
109 return calendarEvent;
113 * Get new start date.
115 * @return New start date.
117 public Date getNewStart() {
123 * Handler interface for when events are being dragged on the calendar.
127 public interface EventMoveHandler extends SerializableEventListener {
129 /** Trigger method for the MoveEvent. */
130 public static final Method eventMoveMethod = ReflectTools.findMethod(
131 EventMoveHandler.class, "eventMove", MoveEvent.class);
134 * This method will be called when event has been moved to a new
138 * MoveEvent containing specific information of the new
139 * position and target event.
141 public void eventMove(MoveEvent event);
145 * Handler interface for day or time cell drag-marking with mouse.
148 public interface RangeSelectNotifier
149 extends CalendarEventNotifier {
152 * Set the RangeSelectHandler that listens for drag-marking.
155 * RangeSelectHandler to be added.
157 public void setHandler(RangeSelectHandler listener);
161 * RangeSelectEvent is sent when day or time cells are drag-marked with
164 @SuppressWarnings("serial")
166 public class RangeSelectEvent extends CalendarComponentEvent {
168 public static final String EVENT_ID = CalendarEventId.RANGESELECT;
170 /** Calendar event's start date. */
173 /** Calendar event's end date. */
177 * Defines the event's view mode.
179 private boolean monthlyMode;
182 * RangeSelectEvent needs a start and end date.
185 * Calendar component.
191 * Calendar view mode.
193 public RangeSelectEvent(Calendar source, Date start, Date end,
194 boolean monthlyMode) {
198 this.monthlyMode = monthlyMode;
204 * @return Start date.
206 public Date getStart() {
215 public Date getEnd() {
220 * Gets the event's view mode. Calendar can be be either in monthly or
221 * weekly mode, depending on the active date range.
223 * @deprecated User {@link Calendar#isMonthlyMode()} instead
225 * @return Returns true when monthly view is active.
228 public boolean isMonthlyMode() {
233 /** RangeSelectHandler handles RangeSelectEvent. */
235 public interface RangeSelectHandler extends SerializableEventListener {
237 /** Trigger method for the RangeSelectEvent. */
238 public static final Method rangeSelectMethod = ReflectTools.findMethod(
239 RangeSelectHandler.class, "rangeSelect",
240 RangeSelectEvent.class);
243 * This method will be called when day or time cells are drag-marked
247 * RangeSelectEvent that contains range start and end date.
249 public void rangeSelect(RangeSelectEvent event);
252 /** Notifier interface for navigation listening. */
254 public interface NavigationNotifier extends Serializable {
256 * Add a forward navigation listener.
259 * ForwardHandler to be added.
261 public void setHandler(ForwardHandler handler);
264 * Add a backward navigation listener.
267 * BackwardHandler to be added.
269 public void setHandler(BackwardHandler handler);
272 * Add a date click listener.
275 * DateClickHandler to be added.
277 public void setHandler(DateClickHandler handler);
280 * Add a event click listener.
283 * EventClickHandler to be added.
285 public void setHandler(EventClickHandler handler);
288 * Add a week click listener.
291 * WeekClickHandler to be added.
293 public void setHandler(WeekClickHandler handler);
297 * ForwardEvent is sent when forward navigation button is clicked.
299 @SuppressWarnings("serial")
301 public class ForwardEvent extends CalendarComponentEvent {
303 public static final String EVENT_ID = CalendarEventId.FORWARD;
306 * ForwardEvent needs only the source component.
309 * Calendar component.
311 public ForwardEvent(Calendar source) {
316 /** ForwardHandler handles ForwardEvent. */
318 public interface ForwardHandler extends SerializableEventListener {
320 /** Trigger method for the ForwardEvent. */
321 public static final Method forwardMethod = ReflectTools.findMethod(
322 ForwardHandler.class, "forward", ForwardEvent.class);
325 * This method will be called when date range is moved forward.
330 public void forward(ForwardEvent event);
334 * BackwardEvent is sent when backward navigation button is clicked.
336 @SuppressWarnings("serial")
338 public class BackwardEvent extends CalendarComponentEvent {
340 public static final String EVENT_ID = CalendarEventId.BACKWARD;
343 * BackwardEvent needs only the source source component.
346 * Calendar component.
348 public BackwardEvent(Calendar source) {
353 /** BackwardHandler handles BackwardEvent. */
355 public interface BackwardHandler extends SerializableEventListener {
357 /** Trigger method for the BackwardEvent. */
358 public static final Method backwardMethod = ReflectTools.findMethod(
359 BackwardHandler.class, "backward", BackwardEvent.class);
362 * This method will be called when date range is moved backwards.
367 public void backward(BackwardEvent event);
371 * DateClickEvent is sent when a date is clicked.
373 @SuppressWarnings("serial")
375 public class DateClickEvent extends CalendarComponentEvent {
377 public static final String EVENT_ID = CalendarEventId.DATECLICK;
379 /** Date that was clicked. */
382 /** DateClickEvent needs the target date that was clicked. */
383 public DateClickEvent(Calendar source, Date date) {
391 * @return Clicked date.
393 public Date getDate() {
398 /** DateClickHandler handles DateClickEvent. */
400 public interface DateClickHandler extends SerializableEventListener {
402 /** Trigger method for the DateClickEvent. */
403 public static final Method dateClickMethod = ReflectTools.findMethod(
404 DateClickHandler.class, "dateClick", DateClickEvent.class);
407 * This method will be called when a date is clicked.
410 * DateClickEvent containing the target date.
412 public void dateClick(DateClickEvent event);
416 * EventClick is sent when an event is clicked.
418 @SuppressWarnings("serial")
420 public class EventClick extends CalendarComponentEvent {
422 public static final String EVENT_ID = CalendarEventId.EVENTCLICK;
424 /** Clicked source event. */
425 private CalendarEvent calendarEvent;
427 /** Target source event is needed for the EventClick. */
428 public EventClick(Calendar source, CalendarEvent calendarEvent) {
430 this.calendarEvent = calendarEvent;
434 * Get the clicked event.
436 * @return Clicked event.
438 public CalendarEvent getCalendarEvent() {
439 return calendarEvent;
443 /** EventClickHandler handles EventClick. */
445 public interface EventClickHandler extends SerializableEventListener {
447 /** Trigger method for the EventClick. */
448 public static final Method eventClickMethod = ReflectTools.findMethod(
449 EventClickHandler.class, "eventClick", EventClick.class);
452 * This method will be called when an event is clicked.
455 * EventClick containing the target event.
457 public void eventClick(EventClick event);
461 * WeekClick is sent when week is clicked.
463 @SuppressWarnings("serial")
465 public class WeekClick extends CalendarComponentEvent {
467 public static final String EVENT_ID = CalendarEventId.WEEKCLICK;
476 * WeekClick needs a target year and week.
485 public WeekClick(Calendar source, int week, int year) {
492 * Get week as a integer. See {@link java.util.Calendar} for the allowed
495 * @return Week as a integer.
497 public int getWeek() {
502 * Get year as a integer. See {@link java.util.Calendar} for the allowed
505 * @return Year as a integer
507 public int getYear() {
512 /** WeekClickHandler handles WeekClicks. */
514 public interface WeekClickHandler extends SerializableEventListener {
516 /** Trigger method for the WeekClick. */
517 public static final Method weekClickMethod = ReflectTools.findMethod(
518 WeekClickHandler.class, "weekClick", WeekClick.class);
521 * This method will be called when a week is clicked.
524 * WeekClick containing the target week and year.
526 public void weekClick(WeekClick event);
530 * EventResize is sent when an event is resized.
532 @SuppressWarnings("serial")
534 public class EventResize extends CalendarComponentEvent {
536 public static final String EVENT_ID = CalendarEventId.EVENTRESIZE;
538 private CalendarEvent calendarEvent;
540 private Date startTime;
542 private Date endTime;
544 public EventResize(Calendar source, CalendarEvent calendarEvent,
545 Date startTime, Date endTime) {
547 this.calendarEvent = calendarEvent;
548 this.startTime = startTime;
549 this.endTime = endTime;
555 * @return Target event.
557 public CalendarEvent getCalendarEvent() {
558 return calendarEvent;
562 * @deprecated Use {@link #getNewStart()} instead
564 * @return the new start time
567 public Date getNewStartTime() {
572 * Returns the updated start date/time of the event.
574 * @return The new date for the event
576 public Date getNewStart() {
581 * @deprecated Use {@link #getNewEnd()} instead
583 * @return the new end time
586 public Date getNewEndTime() {
591 * Returns the updates end date/time of the event.
593 * @return The new date for the event
595 public Date getNewEnd() {
601 * Notifier interface for event resizing.
604 public interface EventResizeNotifier extends Serializable {
607 * Set a EventResizeHandler.
610 * EventResizeHandler to be set
612 public void setHandler(EventResizeHandler handler);
616 * Handler for EventResize event.
619 public interface EventResizeHandler extends SerializableEventListener {
621 /** Trigger method for the EventResize. */
622 public static final Method eventResizeMethod = ReflectTools.findMethod(
623 EventResizeHandler.class, "eventResize", EventResize.class);
625 void eventResize(EventResize event);