Exemplo n.º 1
0
 private void updateCalendarEventForm(CalendarEvent event) {
   BeanItem<CalendarEvent> item = new BeanItem<>(event);
   scheduleEventFieldLayout.removeAllComponents();
   scheduleEventFieldGroup = new FieldGroup();
   initFormFields(scheduleEventFieldLayout, event.getClass());
   scheduleEventFieldGroup.setBuffered(true);
   scheduleEventFieldGroup.setItemDataSource(item);
   scheduledEventBinder.readBean(event);
 }
Exemplo n.º 2
0
 @SuppressWarnings("unchecked")
 private BasicEvent getFormCalendarEvent() {
   BeanItem<CalendarEvent> item =
       (BeanItem<CalendarEvent>) scheduleEventFieldGroup.getItemDataSource();
   CalendarEvent event = item.getBean();
   return (BasicEvent) event;
 }
Exemplo n.º 3
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);
  }
Exemplo n.º 4
0
  private void initFormFields(Layout formLayout, Class<? extends CalendarEvent> eventClass) {

    startDateField = createDateField("Start date");
    endDateField = createDateField("End date");

    final CheckBox allDayField = createCheckBox("All-day");
    allDayField.addValueChangeListener(
        event -> {
          if (event.getValue()) {
            setFormDateResolution(Resolution.DAY);
          } else {
            setFormDateResolution(Resolution.MINUTE);
          }
        });

    captionField = createTextField("Caption");
    final TextField whereField = createTextField("Where");
    final TextArea descriptionField = createTextArea("Description");
    descriptionField.setRows(3);

    final ComboBox styleNameField = createStyleNameComboBox();

    formLayout.addComponent(startDateField);
    formLayout.addComponent(endDateField);
    formLayout.addComponent(allDayField);
    formLayout.addComponent(captionField);
    if (eventClass == CalendarTestEvent.class) {
      formLayout.addComponent(whereField);
    }
    formLayout.addComponent(descriptionField);
    formLayout.addComponent(styleNameField);

    scheduleEventFieldGroup.bind(startDateField, "start");
    scheduleEventFieldGroup.bind(endDateField, "end");
    scheduleEventFieldGroup.bind(captionField, "caption");
    scheduleEventFieldGroup.bind(descriptionField, "description");
    if (eventClass == CalendarTestEvent.class) {
      scheduleEventFieldGroup.bind(whereField, "where");
    }
    scheduleEventFieldGroup.bind(styleNameField, "styleName");
    scheduledEventBinder.bind(allDayField, CalendarEvent::isAllDay, null);
  }
Exemplo n.º 5
0
 private void discardCalendarEvent() {
   scheduleEventFieldGroup.discard();
   scheduledEventBinder.readBean(getFormCalendarEvent());
   removeWindow(scheduleEventPopup);
 }