Java 类com.vaadin.ui.components.calendar.CalendarComponentEvents.MoveEvent 实例源码

项目:scoutmaster    文件:ScoutsContainerEventProvider.java   
@Override
public void eventMove(final MoveEvent event)
{
    final ScoutCalEvent calendarEvent = (ScoutCalEvent) event.getCalendarEvent();
    Event eventEntity = calendarEvent.getEntity();

    final Date newStart = event.getNewStart();

    final Date oldStart = eventEntity.getEventStartDateTime();
    eventEntity.setEventStartDateTime(newStart);

    final long duration = eventEntity.getEventEndDateTime().getTime() - oldStart.getTime();

    final Date newEndTime = new Date(newStart.getTime() + duration);
    eventEntity.setEventEndDateTime(newEndTime);
    eventChange(new EventChangeEvent(calendarEvent));
    try
    {
        final EventDao daoEvent = new DaoFactory().getEventDao();
        eventEntity = daoEvent.merge(eventEntity);
        calendarEvent.eventEntity = eventEntity;
    }
    catch (final Exception e)
    {
        this.logger.error(e, e);
        SMNotification.show(e, Type.ERROR_MESSAGE);
    }
}