com.vaadin.v7.ui.components.calendar.handler.BasicEventMoveHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-compatibility-server Show documentation
Show all versions of vaadin-compatibility-server Show documentation
Vaadin 7 compatibility package for Vaadin 8
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See for the full
* license.
*/
package com.vaadin.v7.ui.components.calendar.handler;
import java.util.Date;
import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventMoveHandler;
import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.MoveEvent;
import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
import com.vaadin.v7.ui.components.calendar.event.EditableCalendarEvent;
/**
* Implements basic functionality needed to enable moving events.
*
* @since 7.1
* @author Vaadin Ltd.
*/
@SuppressWarnings("serial")
@Deprecated
public class BasicEventMoveHandler implements EventMoveHandler {
/*
* (non-Javadoc)
*
* @see
* com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler
* #eventMove
* (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent)
*/
@Override
public void eventMove(MoveEvent event) {
CalendarEvent calendarEvent = event.getCalendarEvent();
if (calendarEvent instanceof EditableCalendarEvent) {
EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent;
Date newFromTime = event.getNewStart();
// Update event dates
long length = editableEvent.getEnd().getTime()
- editableEvent.getStart().getTime();
setDates(editableEvent, newFromTime,
new Date(newFromTime.getTime() + length));
}
}
/**
* 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);
}
}