示例#1
0
 /* Removes the event from the data source and fires change event. */
 private void deleteCalendarEvent() {
   BasicEvent event = getFormCalendarEvent();
   if (dataSource.containsEvent(event)) {
     dataSource.removeEvent(event);
   }
   removeWindow(scheduleEventPopup);
 }
示例#2
0
  /* Adds/updates the event in the data source and fires change event. */
  private void commitCalendarEvent() throws CommitException, ValidationException {
    scheduleEventFieldGroup.commit();
    BasicEvent event = getFormCalendarEvent();
    scheduledEventBinder.writeBean(event);
    if (event.getEnd() == null) {
      event.setEnd(event.getStart());
    }
    if (!dataSource.containsEvent(event)) {
      dataSource.addEvent(event);
    }

    removeWindow(scheduleEventPopup);
  }
示例#3
0
  private void addInitialEvents() {
    Date originalDate = calendar.getTime();
    Date today = getToday();

    // Add a event that last a whole week

    Date start = resolveFirstDateOfWeek(today, calendar);
    Date end = resolveLastDateOfWeek(today, calendar);
    CalendarTestEvent event = getNewEvent("Whole week event", start, end);
    event.setAllDay(true);
    event.setStyleName("color4");
    event.setDescription("Description for the whole week event.");
    dataSource.addEvent(event);

    // Add a allday event
    calendar.setTime(start);
    calendar.add(GregorianCalendar.DATE, 3);
    start = calendar.getTime();
    end = start;
    event = getNewEvent("Allday event", start, end);
    event.setAllDay(true);
    event.setDescription("Some description.");
    event.setStyleName("color3");
    dataSource.addEvent(event);

    // Add a second allday event
    calendar.add(GregorianCalendar.DATE, 1);
    start = calendar.getTime();
    end = start;
    event = getNewEvent("Second allday event", start, end);
    event.setAllDay(true);
    event.setDescription("Some description.");
    event.setStyleName("color2");
    dataSource.addEvent(event);

    calendar.add(GregorianCalendar.DATE, -3);
    calendar.set(GregorianCalendar.HOUR_OF_DAY, 9);
    calendar.set(GregorianCalendar.MINUTE, 30);
    start = calendar.getTime();
    calendar.add(GregorianCalendar.HOUR_OF_DAY, 5);
    calendar.set(GregorianCalendar.MINUTE, 0);
    end = calendar.getTime();
    event = getNewEvent("Appointment", start, end);
    event.setWhere("Office");
    event.setStyleName("color1");
    event.setDescription("A longer description, which should display correctly.");
    dataSource.addEvent(event);

    calendar.add(GregorianCalendar.DATE, 1);
    calendar.set(GregorianCalendar.HOUR_OF_DAY, 11);
    calendar.set(GregorianCalendar.MINUTE, 0);
    start = calendar.getTime();
    calendar.add(GregorianCalendar.HOUR_OF_DAY, 8);
    end = calendar.getTime();
    event = getNewEvent("Training", start, end);
    event.setStyleName("color2");
    dataSource.addEvent(event);

    calendar.add(GregorianCalendar.DATE, 4);
    calendar.set(GregorianCalendar.HOUR_OF_DAY, 9);
    calendar.set(GregorianCalendar.MINUTE, 0);
    start = calendar.getTime();
    calendar.add(GregorianCalendar.HOUR_OF_DAY, 9);
    end = calendar.getTime();
    event = getNewEvent("Free time", start, end);
    dataSource.addEvent(event);

    calendar.setTime(originalDate);
  }