/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.v7.ui.components.calendar.handler;
import java.util.Date;
import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResize;
import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
import com.vaadin.v7.ui.components.calendar.event.EditableCalendarEvent;
/**
* Implements basic functionality needed to enable event resizing.
*
* @since 7.1
* @author Vaadin Ltd.
*/
@SuppressWarnings("serial")
@Deprecated
public class BasicEventResizeHandler implements EventResizeHandler {
/*
* (non-Javadoc)
*
* @see
* com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler
* #eventResize
* (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize)
*/
@Override
public void eventResize(EventResize event) {
CalendarEvent calendarEvent = event.getCalendarEvent();
if (calendarEvent instanceof EditableCalendarEvent) {
Date newStartTime = event.getNewStart();
Date newEndTime = event.getNewEnd();
EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent;
setDates(editableEvent, newStartTime, newEndTime);
}
}
/**
* Set the start and end dates for the event
*
* @param event
* The event that the start and end dates should be set
* @param start
* The start date
* @param end
* The end date
*/
protected void setDates(EditableCalendarEvent event, Date start, Date end) {
event.setStart(start);
event.setEnd(end);
}
}