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.EventResize;
21 import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
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 event resizing.
31 @SuppressWarnings("serial")
33 public class BasicEventResizeHandler implements EventResizeHandler {
39 * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler
41 * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize)
44 public void eventResize(EventResize event) {
45 CalendarEvent calendarEvent = event.getCalendarEvent();
47 if (calendarEvent instanceof EditableCalendarEvent) {
48 Date newStartTime = event.getNewStart();
49 Date newEndTime = event.getNewEnd();
51 EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent;
53 setDates(editableEvent, newStartTime, newEndTime);
58 * Set the start and end dates for the event.
61 * The event that the start and end dates should be set
67 protected void setDates(EditableCalendarEvent event, Date start, Date end) {
68 event.setStart(start);