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.handler;
18 import java.util.Date;
20 import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventMoveHandler;
21 import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.MoveEvent;
22 import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
23 import com.vaadin.v7.ui.components.calendar.event.EditableCalendarEvent;
26 * Implements basic functionality needed to enable moving events.
31 @SuppressWarnings("serial")
33 public class BasicEventMoveHandler implements EventMoveHandler {
39 * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler
41 * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent)
44 public void eventMove(MoveEvent event) {
45 CalendarEvent calendarEvent = event.getCalendarEvent();
47 if (calendarEvent instanceof EditableCalendarEvent) {
49 EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent;
51 Date newFromTime = event.getNewStart();
54 long length = editableEvent.getEnd().getTime()
55 - editableEvent.getStart().getTime();
56 setDates(editableEvent, newFromTime,
57 new Date(newFromTime.getTime() + length));
62 * Set the start and end dates for the event.
65 * The event that the start and end dates should be set
71 protected void setDates(EditableCalendarEvent event, Date start, Date end) {
72 event.setStart(start);