Exemplo n.º 1
0
  /*
   * (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 ce = event.getCalendarEvent();
    if (eventCache.contains(ce)) {
      int index;
      if (ce instanceof ContainerCalendarEvent) {
        index = ((ContainerCalendarEvent) ce).getContainerIndex();
      } else {
        index = container.indexOfId(ce);
      }

      long eventLength = ce.getEnd().getTime() - ce.getStart().getTime();
      Date newEnd = new Date(event.getNewStart().getTime() + eventLength);

      ignoreContainerEvents();
      Item item = container.getItem(container.getIdByIndex(index));
      item.getItemProperty(startDateProperty).setValue(event.getNewStart());
      item.getItemProperty(endDateProperty).setValue(newEnd);
      listenToContainerEvents();
    }
  }
Exemplo n.º 2
0
  @Override
  public void eventMove(MoveEvent event) {
    MyEvent calendarEvent = (MyEvent) event.getCalendarEvent();
    Calendar cal = event.getComponent();
    cal.removeEvent(calendarEvent);
    Date oldStart = calendarEvent.getStart();
    Date oldEnd = calendarEvent.getEnd();
    long duration = oldEnd.getTime() - oldStart.getTime();

    Date newStart = event.getNewStart();
    calendarEvent.setStart(newStart);
    Date newEnd = new Date(newStart.getTime() + duration);
    calendarEvent.setEnd(newEnd);
    cal.addEvent(calendarEvent);
  }