@Override
  protected void setup(VaadinRequest request) {
    final VerticalLayout uiLayout = new VerticalLayout();
    uiLayout.setMargin(true);
    setContent(uiLayout);

    final VerticalLayout windowLayout = new VerticalLayout();

    final Window testWindow = new Window("WebKitFail", windowLayout);
    testWindow.setWidth(300, Unit.PIXELS);

    GridLayout gl = new GridLayout();
    gl.setHeight(null);
    gl.setWidth(100, Unit.PERCENTAGE);
    windowLayout.addComponent(gl);

    ListSelect listSelect = new ListSelect();
    listSelect.setWidth(100, Unit.PERCENTAGE);
    gl.addComponent(listSelect);
    gl.setMargin(true);

    final Button testButton =
        new Button(
            "Open Window",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                UI.getCurrent().addWindow(testWindow);
              }
            });
    uiLayout.addComponent(testButton);
  }
Exemple #2
0
  public ReceiptForm() {
    // Create our layout (3x3 GridLayout)
    ourLayout = new GridLayout(2, 2);

    // Use top-left margin and spacing
    ourLayout.setMargin(true, false, false, true);
    ourLayout.setSpacing(true);
    ourLayout.setWidth(400, Component.UNITS_PIXELS);

    setLayout(ourLayout);

    setFormFieldFactory(new ReceiptFormFieldFactory());

    // Set up buffering
    setWriteThrough(false); // we want explicit 'apply'
    setInvalidCommitted(false); // no invalid values in datamodel

    lblNote.setSizeUndefined();
    ourLayout.addComponent(lblNote, 0, 0);
    ourLayout.setComponentAlignment(lblNote, Alignment.TOP_RIGHT);
    ourLayout.addComponent(btnSave, 1, 1);

    btnSave.addListener(
        new Button.ClickListener() {

          public void buttonClick(ClickEvent event) {
            commit();
            if (getItemDataSource() instanceof Buffered) {
              ((Buffered) getItemDataSource()).commit();
            }
          }
        });
  }
  private Component createFilterComponent() {
    Panel pnl = new Panel("Cari mahasiswa");
    GridLayout gl = new GridLayout(3, 2);
    gl.setMargin(true);
    FormLayout flKiri = new FormLayout();
    FormLayout flKanan = new FormLayout();
    tfNama = new TextField("Nama");
    tfNimStart = new TextField("Nim mulai");
    tfAngkatan = new TextField("Angkatan");
    flKiri.setSpacing(true);
    flKanan.setSpacing(true);

    Button buttonFilter = new Button("Cari");
    buttonFilter.addClickListener(
        new ClickListener() {

          private static final long serialVersionUID = 1L;

          @Override
          public void buttonClick(ClickEvent event) {
            filter();
          }
        });
    flKiri.addComponents(tfNama, tfNimStart, cbProdi);
    flKanan.addComponents(tfAngkatan, cbPA, buttonFilter);
    gl.addComponent(flKiri, 0, 0);
    gl.addComponent(flKanan, 1, 0);
    gl.setSpacing(true);
    pnl.setContent(gl);
    return pnl;
  }
  protected void addHeader() {
    GridLayout header = new GridLayout(3, 2);
    header.setWidth(100, UNITS_PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    header.setSpacing(true);
    header.setMargin(false, false, true, false);

    // Add image
    Embedded image = new Embedded(null, Images.PROCESS_50);
    header.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(getProcessDisplayName(processDefinition, processInstance));
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    header.addComponent(nameLabel, 1, 0, 2, 0);

    // Add start time
    PrettyTimeLabel startTimeLabel =
        new PrettyTimeLabel(
            i18nManager.getMessage(Messages.PROCESS_START_TIME),
            historicProcessInstance.getStartTime(),
            null,
            true);
    startTimeLabel.addStyleName(ExplorerLayout.STYLE_PROCESS_HEADER_START_TIME);
    header.addComponent(startTimeLabel, 1, 1);

    header.setColumnExpandRatio(1, 1.0f);
    header.setColumnExpandRatio(2, 1.0f);

    panelLayout.addComponent(header);
  }
  private void buildContent() {

    this.cb_Grupo.setWidth("100%");
    this.cb_Auxiliar.setWidth("100%");
    this.cb_Activos.setWidth("100%");

    setColumnExpandRatio(0, 0.3f);
    setColumnExpandRatio(1, 1f);
    setColumnExpandRatio(2, 1f);

    GridLayout gridlFecha = new GridLayout(1, 1);
    gridlFecha.setWidth("100%");
    GridLayout gridlCodigo = new GridLayout(1, 1);
    gridlCodigo.setWidth("100%");
    gridlCodigo.setHeight("100%");
    GridLayout gridlCombos = new GridLayout(1, 3);
    gridlCombos.setWidth("100%");
    gridlCodigo.setMargin(true);
    gridlFecha.setMargin(true);
    gridlCombos.setMargin(true);

    Panel pnFecha = new Panel("Fecha Elaboracion");
    pnFecha.setContent(gridlFecha);
    pnFecha.setStyleName(AitTheme.PANEL_PRINT);
    pnFecha.setIcon(FontAwesome.EDIT);
    pnCodigo = new Panel("Seleccion por codigo");
    pnCodigo.setContent(gridlCodigo);
    pnCodigo.setStyleName(AitTheme.PANEL_PRINT);
    pnCodigo.setIcon(FontAwesome.EDIT);
    pnCombos = new Panel("Seleccion por Grupo y Auxiliar Contable");
    pnCombos.setContent(gridlCombos);
    pnCombos.setStyleName(AitTheme.PANEL_PRINT);
    pnCombos.setIcon(FontAwesome.EDIT);

    pnCodigo.addClickListener(this);
    pnCombos.addClickListener(this);

    gridlFecha.addComponent(dtf_fechaElaboracion, 0, 0);
    gridlCodigo.addComponent(txt_codigoActivo, 0, 0);
    gridlCombos.addComponent(this.cb_Grupo, 0, 0);
    gridlCombos.addComponent(this.cb_Auxiliar, 0, 1);
    gridlCombos.addComponent(this.cb_Activos, 0, 2);

    addComponent(pnFecha, 0, 0);
    addComponent(pnCodigo, 1, 0);
    addComponent(pnCombos, 1, 1, 1, 3);
  }
  @SuppressWarnings("serial")
  @Override
  public void init(VaadinRequest request) {
    GridLayout layout = new GridLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    setContent(layout);

    handleURLParams(request.getParameterMap());

    initContent();
  }
  @AutoGenerated
  private GridLayout buildHeadLayout() {
    // common part: create layout
    headLayout = new GridLayout();
    headLayout.setImmediate(false);
    headLayout.setWidth("-1px");
    headLayout.setHeight("-1px");
    headLayout.setMargin(false);
    headLayout.setSpacing(true);
    headLayout.setColumns(2);
    headLayout.setRows(2);

    // parameterTypeLabel
    parameterTypeLabel = new Label();
    parameterTypeLabel.setImmediate(false);
    parameterTypeLabel.setWidth("-1px");
    parameterTypeLabel.setHeight("-1px");
    parameterTypeLabel.setValue("Type of Parameter");
    headLayout.addComponent(parameterTypeLabel, 0, 0);

    // parameterType
    parameterType = new ComboBox();
    parameterType.setImmediate(false);
    parameterType.setWidth("-1px");
    parameterType.setHeight("-1px");
    headLayout.addComponent(parameterType, 1, 0);

    // parameterNameLabel
    parameterNameLabel = new Label();
    parameterNameLabel.setImmediate(false);
    parameterNameLabel.setWidth("-1px");
    parameterNameLabel.setHeight("-1px");
    parameterNameLabel.setValue("Parameter");
    headLayout.addComponent(parameterNameLabel, 0, 1);
    headLayout.setComponentAlignment(parameterNameLabel, new Alignment(6));

    // parameterName
    parameterName = new TextField();
    parameterName.setImmediate(false);
    parameterName.setWidth("-1px");
    parameterName.setHeight("-1px");
    parameterName.setRequired(true);
    headLayout.addComponent(parameterName, 1, 1);

    return headLayout;
  }
  private Component buildFormContent() {

    VerticalLayout formContent = new VerticalLayout();
    formContent.setSpacing(true);

    Panel frmPanel = new Panel();
    frmPanel.setStyleName(AitTheme.PANEL_FORM);
    frmPanel.setIcon(FontAwesome.EDIT);
    frmPanel.setWidth("100%");
    frmPanel.setCaption("Servidor con Atribuciones de Autorizacion");

    GridLayout gridlFunionario = new GridLayout(3, 1);
    gridlFunionario.addComponent(txtDependencia, 0, 0);
    gridlFunionario.addComponent(txtUnidadOrganizacional, 1, 0);
    gridlFunionario.addComponent(txt_nombre_servidor, 2, 0);

    gridlFunionario.setMargin(true);
    gridlFunionario.setSpacing(true);
    gridlFunionario.setWidth("100%");
    frmPanel.setContent(gridlFunionario);

    formContent.setMargin(true);
    formContent.addComponent(frmPanel);
    Panel gridPanel = new Panel();
    gridPanel.setWidth("100%");
    gridPanel.setCaption("Documentos que Puede Autorizar");
    gridPanel.setContent(this.gridTipoAutorizacion);
    gridPanel.setStyleName(AitTheme.PANEL_GRID);
    gridPanel.setIcon(FontAwesome.TABLE);
    formContent.setMargin(true);

    Panel gridpin = new Panel();
    gridpin.setStyleName(AitTheme.PANEL_FORM);
    gridpin.setIcon(FontAwesome.TABLE);
    gridpin.setWidth("100%");
    gridpin.setCaption("N. PIN");
    gridpin.setContent(this.frm_pin);
    formContent.setMargin(true);

    formContent.addComponent(frmPanel);
    formContent.addComponent(gridPanel);
    formContent.addComponent(gridpin);
    Responsive.makeResponsive(formContent);
    return formContent;
  }
  @AutoGenerated
  private GridLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new GridLayout();
    mainLayout.setStyleName("background");
    mainLayout.setImmediate(false);
    mainLayout.setWidth("480px");
    mainLayout.setHeight("450px");
    mainLayout.setMargin(false);

    // top-level component properties
    setWidth("480px");
    setHeight("450px");

    // logintab
    logintab = buildLogintab();
    mainLayout.addComponent(logintab, 0, 0);

    return mainLayout;
  }
  public BaseCubeAHPBView() throws SQLException {
    mainLayout = new VerticalLayout();
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    contentLayout = new GridLayout(1, 1);
    contentLayout.setMargin(true);
    contentLayout.setSpacing(true);
    contentLayout.setSizeFull();
    setContent(mainLayout);

    Label viewLabel =
        new Label(
            "<div align=\"center\" style=\"font-size:16pt;\"><b>HOUSEHOLD BASE CUBE</b></div>");
    viewLabel.setContentMode(ContentMode.HTML);
    mainLayout.addComponent(viewLabel);

    Table householdFactBaseCubeTable = getHouseholdFactBaseCubeTable();
    contentLayout.addComponent(householdFactBaseCubeTable, 0, 0);
    contentLayout.setComponentAlignment(householdFactBaseCubeTable, Alignment.MIDDLE_CENTER);
    mainLayout.addComponent(contentLayout);
  }
  private VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader addFormSection(
      PhysicalAttributeConfirmActualsFieldSetComponent fieldSet) {
    GridLayout gridLayout = new GridLayout(3, 1);
    gridLayout.setWidth("70%");
    gridLayout.setSpacing(true);
    gridLayout.setStyleName("conx-entity-editor-form");
    gridLayout.setMargin(true, true, false, true);

    Embedded placeholder = new Embedded();
    placeholder.setHeight("22px");
    placeholder.setWidth("1px");

    GridLayout captionLayout = new GridLayout(1, 1);
    captionLayout.setWidth("100%");
    captionLayout.setSpacing(true);
    captionLayout.addComponent(placeholder, 0, 0, 0, 0);
    GridLayout expectedLayout = new GridLayout(2, 1);
    expectedLayout.setWidth("100%");
    expectedLayout.setSpacing(true);
    expectedLayout.addComponent(new VaadinConfirmActualsFormSectionHeader("Expected"), 0, 0, 1, 0);
    GridLayout actualLayout = new GridLayout(2, 1);
    actualLayout.setWidth("100%");
    actualLayout.setSpacing(true);
    actualLayout.addComponent(new VaadinConfirmActualsFormSectionHeader("Actual"), 0, 0, 1, 0);

    gridLayout.addComponent(captionLayout, 0, 0, 0, 0);
    gridLayout.addComponent(expectedLayout, 1, 0, 1, 0);
    gridLayout.addComponent(actualLayout, 2, 0, 2, 0);
    gridLayout.setColumnExpandRatio(0, 0.166f);
    gridLayout.setColumnExpandRatio(1, 0.417f);
    gridLayout.setColumnExpandRatio(2, 0.417f);

    VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader header =
        new VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader(fieldSet, gridLayout);
    innerLayout.addComponent(header);
    innerLayout.addComponent(header.getLayout());
    headers.put(fieldSet, header);
    return header;
  }
 GridLayout getGridLayout() {
   GridLayout grid =
       new GridLayout(3, 1) {
         @Override
         public void addComponent(Component c) {
           super.addComponent(c);
           setComponentAlignment(c, Alignment.MIDDLE_CENTER);
           if (c.getStyleName() != "") {
             ((AbstractComponent) c)
                 .setDescription(
                     c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")");
           } else {
             ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()");
           }
         }
       };
   grid.setWidth("100%");
   grid.setSpacing(true);
   grid.setMargin(true);
   grid.setStyleName("preview-grid");
   return grid;
 }
  protected void addDeploymentName() {

    GridLayout taskDetails = new GridLayout(3, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);
    taskDetails.setMargin(false, false, true, false);

    // Add image
    Embedded image = new Embedded(null, Images.DEPLOYMENT_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add deployment name
    Label nameLabel = new Label();
    if (deployment.getName() != null) {
      nameLabel.setValue(deployment.getName());
    } else {
      nameLabel.setValue(i18nManager.getMessage(Messages.DEPLOYMENT_NO_NAME));
    }
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 2, 0);

    // Add deploy time
    PrettyTimeLabel deployTimeLabel =
        new PrettyTimeLabel(
            i18nManager.getMessage(Messages.DEPLOYMENT_DEPLOY_TIME),
            deployment.getDeploymentTime(),
            null,
            true);
    deployTimeLabel.addStyleName(ExplorerLayout.STYLE_DEPLOYMENT_HEADER_DEPLOY_TIME);
    taskDetails.addComponent(deployTimeLabel, 1, 1);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);

    addDetailComponent(taskDetails);
  }
  protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) {
    Panel paramPanel = new Panel();
    paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(2, 3);
    paramLayout.setSpacing(true);
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    final Map<String, String> valueMap = parameter.getValue();

    final GridLayout mapLayout =
        new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1);
    mapLayout.setColumnExpandRatio(0, .05f);
    mapLayout.setColumnExpandRatio(1, .425f);
    mapLayout.setColumnExpandRatio(2, .05f);
    mapLayout.setColumnExpandRatio(3, .425f);
    mapLayout.setColumnExpandRatio(4, .05f);

    mapLayout.setMargin(true);
    mapLayout.setSpacing(true);
    mapLayout.setWidth("100%");

    int i = 0;

    for (final String key : valueMap.keySet()) {
      final Label keyLabel = new Label("Name:");
      final Label valueLabel = new Label("Value:");

      final TextField keyField = new TextField();
      keyField.setValue(key);
      keyField.setWidth("100%");
      keyField.setNullSettingAllowed(false);
      keyField.addValidator(
          new NonZeroLengthStringValidator("Then configuration value name cannot be empty!"));
      keyField.setValidationVisible(false);

      final TextField valueField = new TextField();
      valueField.setWidth("100%");
      valueField.setValue(valueMap.get(key));
      valueField.setNullSettingAllowed(false);
      valueField.addValidator(
          new NonZeroLengthStringValidator("Then configuration value cannot be empty!"));
      valueField.setValidationVisible(false);

      mapLayout.addComponent(keyLabel, 0, i);
      mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT);
      mapLayout.addComponent(keyField, 1, i);
      mapLayout.addComponent(valueLabel, 2, i);
      mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT);
      mapLayout.addComponent(valueField, 3, i);
      final String mapKey = parameter.getName() + i;
      TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
      pair.key = keyField;
      pair.value = valueField;

      this.mapTextFields.put(mapKey, pair);

      final Button removeButton = new Button("remove");
      removeButton.setStyleName(ValoTheme.BUTTON_LINK);
      removeButton.addClickListener(
          new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
              valueMap.remove(key);
              mapLayout.removeComponent(keyLabel);
              mapLayout.removeComponent(valueLabel);
              mapLayout.removeComponent(keyField);
              mapLayout.removeComponent(valueField);
              mapLayout.removeComponent(removeButton);

              mapTextFields.remove(mapKey);
            }
          });

      mapLayout.addComponent(removeButton, 4, i);

      i++;
    }

    final Button addButton = new Button("add");
    addButton.setStyleName(ValoTheme.BUTTON_LINK);
    addButton.addClickListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
            final Label keyLabel = new Label("Name:");
            final Label valueLabel = new Label("Value:");

            final TextField keyField = new TextField();
            keyField.setWidth("100%");
            keyField.setNullSettingAllowed(false);
            keyField.addValidator(
                new NonZeroLengthStringValidator("Then configuration value name cannot be empty!"));
            keyField.setValidationVisible(false);

            final TextField valueField = new TextField();
            valueField.setWidth("100%");
            valueField.setNullSettingAllowed(false);
            valueField.addValidator(
                new NonZeroLengthStringValidator("Then configuration value cannot be empty!"));
            valueField.setValidationVisible(false);

            mapLayout.insertRow(mapLayout.getRows());

            mapLayout.removeComponent(addButton);
            mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2);
            mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT);
            mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2);
            mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2);
            mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT);
            mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2);

            final String mapKey = parameter.getName() + mapTextFields.size();
            TextFieldKeyValuePair pair = new TextFieldKeyValuePair();
            pair.key = keyField;
            pair.value = valueField;

            mapTextFields.put(mapKey, pair);

            final Button removeButton = new Button("remove");
            removeButton.setStyleName(ValoTheme.BUTTON_LINK);
            removeButton.addClickListener(
                new Button.ClickListener() {
                  public void buttonClick(ClickEvent event) {
                    mapLayout.removeComponent(keyLabel);
                    mapLayout.removeComponent(valueLabel);
                    mapLayout.removeComponent(keyField);
                    mapLayout.removeComponent(valueField);

                    mapLayout.removeComponent(removeButton);

                    mapTextFields.remove(mapKey);
                  }
                });

            mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2);

            mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);
          }
        });

    mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1);

    Panel mapPanel = new Panel();
    mapPanel.setStyleName(ValoTheme.PANEL_BORDERLESS);
    mapPanel.setContent(mapLayout);

    Button saveButton = new Button("Save");
    saveButton.addStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
            try {
              for (TextFieldKeyValuePair textField : mapTextFields.values()) {
                textField.key.validate();
                textField.value.validate();
              }

              usernameField.validate();
              passwordField.validate();
            } catch (InvalidValueException e) {
              for (TextFieldKeyValuePair textField : mapTextFields.values()) {
                textField.key.setValidationVisible(true);
                textField.value.setValidationVisible(true);
                usernameField.setValidationVisible(true);
                passwordField.setValidationVisible(true);
              }

              Notification.show("Validation errors have occurred!", Type.ERROR_MESSAGE);

              return;
            }

            HashMap<String, String> map = new HashMap<String, String>();

            logger.info("Saving map: " + mapTextFields.size());

            for (String key : mapTextFields.keySet()) {
              if (key.startsWith(parameter.getName())) {
                TextFieldKeyValuePair pair = mapTextFields.get(key);

                logger.info("Saving for key: " + key);

                if (pair.key.getValue() != "") {
                  map.put(pair.key.getValue(), pair.value.getValue());
                }
              }
            }

            parameter.setValue(map);
            userParam.setValue(usernameField.getValue());
            passwordParam.setValue(passwordField.getValue());

            PlatformConfigurationPanel.this.configurationManagement.saveConfiguration(
                platformConfiguration);

            Notification notification =
                new Notification(
                    "Saved",
                    "The configuration has been saved successfully!",
                    Type.HUMANIZED_MESSAGE);
            notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE);
            notification.show(Page.getCurrent());
          }
        });

    Button deleteButton = new Button("Re-create");
    deleteButton.addStyleName(ValoTheme.BUTTON_SMALL);
    deleteButton.addClickListener(
        new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
            configurationManagement.deleteConfiguration(platformConfiguration);

            refresh();
          }
        });

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight("100%");
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(200, Unit.PIXELS);
    buttonLayout.setMargin(true);
    buttonLayout.addComponent(saveButton);
    buttonLayout.addComponent(deleteButton);

    paramLayout.addComponent(mapPanel, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER);
    paramLayout.addComponent(buttonLayout, 0, 2, 1, 2);
    paramLayout.setComponentAlignment(buttonLayout, Alignment.TOP_CENTER);
    paramPanel.setContent(paramLayout);

    return paramPanel;
  }
  protected Panel createTextFieldPanel(ConfigurationParameter parameter, Validator validator) {
    Panel paramPanel = new Panel();
    paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    paramPanel.setWidth("100%");

    GridLayout paramLayout = new GridLayout(3, 3);
    paramLayout.setSpacing(true);
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label configLabel = new Label("Platform Configuration");
    configLabel.addStyleName(ValoTheme.LABEL_HUGE);
    configLabel.setSizeUndefined();
    paramLayout.addComponent(configLabel, 0, 0, 1, 0);
    paramLayout.setComponentAlignment(configLabel, Alignment.TOP_LEFT);

    Label label = new Label(parameter.getName());
    label.setIcon(VaadinIcons.COG);
    label.addStyleName(ValoTheme.LABEL_LARGE);
    label.addStyleName(ValoTheme.LABEL_BOLD);
    label.setSizeUndefined();
    paramLayout.addComponent(label, 0, 1, 1, 1);
    paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

    logger.info(parameter.getName() + " " + parameter.getValue());
    Label valueLabel = new Label("Value:");
    valueLabel.setSizeUndefined();
    usernameField = new TextField();
    usernameField.addValidator(validator);
    usernameField.setNullSettingAllowed(true);
    usernameField.setNullRepresentation("");
    usernameField.setValidationVisible(false);
    usernameField.setWidth("80%");
    usernameField.setId(parameter.getName());

    if (parameter instanceof ConfigurationParameterIntegerImpl) {
      StringToIntegerConverter plainIntegerConverter =
          new StringToIntegerConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
              NumberFormat format = super.getFormat(locale);
              format.setGroupingUsed(false);
              return format;
            };
          };

      // either set for the field or in your field factory for multiple fields
      usernameField.setConverter(plainIntegerConverter);
    } else if (parameter instanceof ConfigurationParameterLongImpl) {
      StringToLongConverter plainLongConverter =
          new StringToLongConverter() {
            protected java.text.NumberFormat getFormat(Locale locale) {
              NumberFormat format = super.getFormat(locale);
              format.setGroupingUsed(false);
              return format;
            };
          };

      // either set for the field or in your field factory for multiple fields
      usernameField.setConverter(plainLongConverter);
    }

    BeanItem<ConfigurationParameter> parameterItem =
        new BeanItem<ConfigurationParameter>(parameter);

    if (parameter.getValue() != null) {
      usernameField.setPropertyDataSource(parameterItem.getItemProperty("value"));
    }

    paramLayout.addComponent(valueLabel, 0, 2);
    paramLayout.addComponent(usernameField, 1, 2);
    paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT);

    paramPanel.setContent(paramLayout);

    return paramPanel;
  }
  private void initUI() {
    addStyleName(Reindeer.WINDOW_LIGHT);
    setModal(true);
    setHeight("90%");
    setWidth("60%");
    center();

    HorizontalLayout bottom = new HorizontalLayout();
    bottom.setStyleName(ExplorerLayout.THEME);
    bottom.setSizeFull();
    // bottom.setMargin(true);
    bottom.setSpacing(true);
    bottom.addStyleName(Runo.LAYOUT_DARKER);
    this.setContent(bottom);

    scheduleEventFieldGroup = new FieldGroup();
    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
      scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }

    line = new GridLayout(4, 20);
    line.addStyleName("v-gridlayout");
    line.setWidth("100%");
    line.setSpacing(true);
    line.setMargin(true);

    final Label lbTitle = CommonFieldHandler.createLable("计划名称:");
    line.addComponent(lbTitle);
    line.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT);
    final TextField txtTitle = new TextField();
    txtTitle.setWidth("80%");
    scheduleEventFieldGroup.bind(txtTitle, "name");
    line.addComponent(txtTitle, 1, 0, 3, 0);
    line.setComponentAlignment(txtTitle, Alignment.MIDDLE_LEFT);

    Label label2 = CommonFieldHandler.createLable("开始时间:");
    line.addComponent(label2, 0, 1, 0, 1);
    line.setComponentAlignment(label2, Alignment.MIDDLE_RIGHT);
    // 创建一个时间后台变化的listener
    BlurListener startTimeListener = createTimeReCountListener();
    DateField startDateField = CommonFieldHandler.createDateField("", false);
    scheduleEventFieldGroup.bind(startDateField, "startDate");
    startDateField.addBlurListener(startTimeListener);
    line.addComponent(startDateField, 1, 1, 1, 1);
    line.setComponentAlignment(startDateField, Alignment.MIDDLE_LEFT);

    Label label3 = CommonFieldHandler.createLable("估算时间:");
    line.addComponent(label3, 2, 1, 2, 1);
    line.setComponentAlignment(label3, Alignment.MIDDLE_RIGHT);
    HorizontalLayout hlay = new HorizontalLayout();
    final TextField estimateField = new TextField();
    estimateField.setValue("1");
    estimateField.setWidth("60px");
    estimateField.setNullSettingAllowed(false);
    BlurListener timeReCountListener = createTimeReCountListener();
    estimateField.addBlurListener(timeReCountListener);
    scheduleEventFieldGroup.bind(estimateField, "estimate");
    hlay.addComponent(estimateField);
    Map<Object, String> data = new HashMap();
    data.put(0, "天");
    data.put(1, "时");
    data.put(2, "分");
    // WW_TODO 估算时间单位
    ComboBox unit_cb = createComboBox(data, "55px");
    scheduleEventFieldGroup.bind(unit_cb, "estimateUnit");
    hlay.addComponent(unit_cb);
    line.addComponent(hlay, 3, 1, 3, 1);
    line.setComponentAlignment(hlay, Alignment.MIDDLE_LEFT);

    Label label4 = CommonFieldHandler.createLable("到期时间:");
    line.addComponent(label4, 0, 2, 0, 2);
    line.setComponentAlignment(label4, Alignment.MIDDLE_RIGHT);
    completionDateField = CommonFieldHandler.createDateField("", false);
    line.addComponent(completionDateField, 1, 2, 1, 2);
    line.setComponentAlignment(completionDateField, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(completionDateField, "completionDate");
    //		line.setExpandRatio(completionDateField, 1.0f);

    Label label6 = CommonFieldHandler.createLable("消耗时间:");
    line.addComponent(label6, 2, 2, 2, 2);
    line.setComponentAlignment(label6, Alignment.MIDDLE_RIGHT);
    TextField gs1 = new TextField();
    gs1.setValue("20%");
    gs1.setInputPrompt("50%");
    scheduleEventFieldGroup.bind(gs1, "useup");
    line.addComponent(gs1, 3, 2, 3, 2);
    line.setComponentAlignment(gs1, Alignment.MIDDLE_LEFT);

    Label label5 = CommonFieldHandler.createLable("优先级:");
    //		label.setWidth("80px");
    line.addComponent(label5, 0, 3, 0, 3);
    line.setComponentAlignment(label5, Alignment.MIDDLE_RIGHT);
    Map<Object, String> dtp = new HashMap();
    dtp.put(0, "底");
    dtp.put(1, "中");
    dtp.put(2, "高");
    ComboBox selectPriority = createComboBox(dtp, "100px");
    //		NativeSelect select = new NativeSelect();
    //		select.addItem("无");
    //		select.addItem("0(最低)");
    //		String itemId = "1(中)";
    //		select.addItem(itemId);
    //		select.addItem("2(高)");
    selectPriority.setNullSelectionAllowed(false);
    selectPriority.select(2);
    scheduleEventFieldGroup.bind(selectPriority, "priority");
    line.addComponent(selectPriority, 1, 3, 1, 3);
    line.setComponentAlignment(selectPriority, Alignment.MIDDLE_LEFT);

    Label label1 = CommonFieldHandler.createLable("完成百分比:");
    line.addComponent(label1, 2, 3, 2, 3);
    line.setComponentAlignment(label1, Alignment.MIDDLE_RIGHT);
    TextField tf = new TextField();
    tf.setInputPrompt("50%");
    line.addComponent(tf, 3, 3, 3, 3);
    line.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);

    Label label7 = CommonFieldHandler.createLable("关联日程:");
    line.addComponent(label7, 0, 4, 0, 4);
    line.setComponentAlignment(label7, Alignment.MIDDLE_RIGHT);
    CheckBox relatedCalendar_cb = new CheckBox();
    relatedCalendar_cb.setValue(false);
    line.addComponent(relatedCalendar_cb, 1, 4, 1, 4);
    line.setComponentAlignment(relatedCalendar_cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(relatedCalendar_cb, "relatedCalendar");

    Label lbStatus = CommonFieldHandler.createLable("计划状态:");
    lbStatus.setWidth("20px");
    line.addComponent(lbStatus, 2, 4, 2, 4);
    line.setComponentAlignment(lbStatus, Alignment.MIDDLE_RIGHT);
    Map<Object, String> sta = new HashMap();
    sta.put(0, "新建");
    sta.put(1, "完成");
    sta.put(2, "关闭");
    sta.put(3, "取消");
    ComboBox sectStatus = createComboBox(sta, "100px");
    sectStatus.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectStatus, "status");
    line.addComponent(sectStatus, 3, 4, 3, 4);
    line.setComponentAlignment(sectStatus, Alignment.MIDDLE_LEFT);

    Label label8 = CommonFieldHandler.createLable("关联外部任务:");
    label8.setWidth("20px");
    line.addComponent(label8, 0, 5, 0, 5);
    line.setComponentAlignment(label8, Alignment.MIDDLE_RIGHT);
    CheckBox cb = new CheckBox();
    cb.setValue(true);
    line.addComponent(cb, 1, 5, 1, 5);
    line.setComponentAlignment(cb, Alignment.MIDDLE_LEFT);
    scheduleEventFieldGroup.bind(cb, "relatedTask");

    Label label9 = CommonFieldHandler.createLable("外部任务类型:");
    label9.setWidth("20px");
    line.addComponent(label9, 2, 5, 2, 5);
    line.setComponentAlignment(label9, Alignment.MIDDLE_RIGHT);
    Map<Object, String> oat = new HashMap();
    oat.put(0, "外包任务");
    oat.put(1, "外包任务-类型2");
    ComboBox select2 = createComboBox(oat, "150px");
    //		NativeSelect select2 = new NativeSelect();
    //		select2.addItem("外包任务");
    //		select2.addItem("外包任务-类型2");
    select2.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(select2, "type");
    line.addComponent(select2, 3, 5, 3, 5);
    line.setComponentAlignment(select2, Alignment.MIDDLE_LEFT);
    // select2.select("Timed");

    Label lbOwnGrp = CommonFieldHandler.createLable("计划分配团队:");
    lbOwnGrp.setWidth("20px");
    line.addComponent(lbOwnGrp, 0, 6, 0, 6);
    line.setComponentAlignment(lbOwnGrp, Alignment.MIDDLE_RIGHT);

    //		NativeSelect sectOwnGrp = new NativeSelect();
    Map<Object, String> groupsMap =
        teamService.queryTeamOfUser(LoginHandler.getLoggedInUser().getId());
    groupsMap.put("", "请选择");
    ComboBox sectOwnGrp = createComboBox(groupsMap, "150px");
    //		for (String p : groupsMap.keySet()) {
    //			String title = groupsMap.get(p);
    //			sectOwnGrp.addItem(p);
    //			sectOwnGrp.setItemCaption(p, title);
    //		}
    sectOwnGrp.setNullSelectionAllowed(false);
    ValueChangeListener valueChangeListener = createValueChangeListener();
    sectOwnGrp.addValueChangeListener(valueChangeListener);
    sectOwnGrp.setImmediate(true);
    scheduleEventFieldGroup.bind(sectOwnGrp, "assignedTeam");
    line.addComponent(sectOwnGrp, 1, 6, 1, 6);
    line.setComponentAlignment(sectOwnGrp, Alignment.MIDDLE_LEFT);

    final Label lbOwner = CommonFieldHandler.createLable("计划分配用户:");
    lbOwner.setWidth("20px");
    line.addComponent(lbOwner, 2, 6, 2, 6);
    line.setComponentAlignment(lbOwner, Alignment.MIDDLE_RIGHT);
    //		sectOwner = new NativeSelect();
    //		sectOwner.addItem("请选择");
    sectOwner.setNullSelectionAllowed(false);
    scheduleEventFieldGroup.bind(sectOwner, "assignedUser");
    line.addComponent(sectOwner, 3, 6, 3, 6);
    line.setComponentAlignment(sectOwner, Alignment.MIDDLE_LEFT);

    final Label lbDesc = CommonFieldHandler.createLable("计划描述:");
    lbDesc.setWidth("15px");
    line.addComponent(lbDesc, 0, 7, 0, 7);
    line.setComponentAlignment(lbDesc, Alignment.MIDDLE_RIGHT);
    final TextArea taDesc = CommonFieldHandler.createTextArea("");
    taDesc.setWidth("85%");
    taDesc.setHeight("290px");
    scheduleEventFieldGroup.bind(taDesc, "description");
    line.addComponent(taDesc, 1, 7, 3, 13);
    line.setComponentAlignment(taDesc, Alignment.MIDDLE_LEFT);

    //		CKEditorConfig config = new CKEditorConfig();

    final Button updateSave = new Button("保存");
    updateSave.addClickListener(
        new ClickListener() {
          @SuppressWarnings("unchecked")
          public void buttonClick(ClickEvent event) {
            // WW_TODO 修改保存到数据库
            Todo fieldGroupTodo = saveFieldGroupToDB();
            fireEvent(
                new SubmitEvent(
                    updateSave,
                    SubmitEvent.SUBMITTED,
                    scheduleEventFieldGroup.getItemDataSource()));

            // close popup window
            close();
            /*
             * Todo fieldGroupTodo = saveFieldGroupToDB(); //reflash current
             * Item copyBeanValueToContainer(hContainer,(BeanItem<Todo>)(
             * scheduleEventFieldGroup.getItemDataSource())); //刷新日历
             * main.refreshCalendarView(); Notification.show("保存成功",
             * Notification.Type.HUMANIZED_MESSAGE); //如果有外部流程,启动外部流程 if
             * (fieldGroupTodo.getRelatedTask()) { ViewToolManager
             * .showPopupWindow(new ActivityStartPopupWindow( "1111")); }
             */
            if (fieldGroupTodo.getRelatedTask()) {
              ViewToolManager.showPopupWindow(new ActivityStartPopupWindow("1111"));
            }
          }
        });
    line.addComponent(updateSave, 3, 14, 3, 14);
    line.setComponentAlignment(updateSave, Alignment.MIDDLE_RIGHT);
    //		line.setExpandRatio(updateSave, 1.0f);

    bottom.addComponent(line);
  }
Exemple #17
0
  private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
      for (String mail : lstMail) {
        if (StringUtils.isNotBlank(mail)) {
          if (mail.indexOf("<") > -1) {
            String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
            if (strMail != null && !strMail.equalsIgnoreCase("null")) {}

          } else {

          }
        }
      }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    HorizontalLayout controlsLayout = new HorizontalLayout();
    controlsLayout.setWidth("100%");

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    controlsLayout.addComponent(uploadExt);
    controlsLayout.setExpandRatio(uploadExt, 1.0f);

    controlsLayout.setSpacing(true);

    Button cancelBtn =
        new Button(
            AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {
                MailFormWindow.this.close();
              }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn =
        new Button(
            "Send",
            new Button.ClickListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(ClickEvent event) {

                if (tokenFieldMailTo.getListRecipient().size() <= 0
                    || subject.getValue().equals("")) {
                  NotificationUtil.showErrorNotification(
                      "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
                  return;
                }
                if (AppContext.getUser().getEmail() != null
                    && AppContext.getUser().getEmail().length() > 0) {
                  ExtMailService systemMailService =
                      ApplicationContextUtil.getSpringBean(ExtMailService.class);

                  List<File> listFile = attachments.files();
                  List<EmailAttachementSource> emailAttachmentSource = null;
                  if (listFile != null && listFile.size() > 0) {
                    emailAttachmentSource = new ArrayList<>();
                    for (File file : listFile) {
                      emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                  }

                  systemMailService.sendHTMLMail(
                      AppContext.getUser().getEmail(),
                      AppContext.getUser().getDisplayName(),
                      tokenFieldMailTo.getListRecipient(),
                      tokenFieldMailCc.getListRecipient(),
                      tokenFieldMailBcc.getListRecipient(),
                      subject.getValue().toString(),
                      noteArea.getValue().toString(),
                      emailAttachmentSource);
                  MailFormWindow.this.close();
                } else {
                  NotificationUtil.showErrorNotification(
                      "Your email is empty value, please fulfil it before sending email!");
                }
              }
            });
    sendBtn.setIcon(FontAwesome.SEND);
    sendBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
  }
  private void buildCategoryCRUDAccordion() {

    // Setting editable properties of various fields
    txtParent.setEnabled(false);
    txtUpdCreDate.setEnabled(false);
    txtUpdCreator.setEnabled(false);
    txtUpdParent.setEnabled(false);
    txtUpdModDate.setEnabled(false);
    txtDelName.setEnabled(false);
    txtDelDesc.setEnabled(false);
    txtDelCreDate.setEnabled(false);
    txtDelCreator.setEnabled(false);
    txtDelParent.setEnabled(false);
    txtDelModDate.setEnabled(false);

    // "Create category" fields added
    createGridLayout.addComponent(lblParent);
    createGridLayout.addComponent(txtParent);
    createGridLayout.addComponent(lblName);
    createGridLayout.addComponent(txtName);
    createGridLayout.addComponent(lblDesc);
    createGridLayout.addComponent(txtDesc);
    createGridLayout.addComponent(btnCreate);

    // "Update category" fields added
    updateGridLayout.addComponent(lblUpdName);
    updateGridLayout.addComponent(txtUpdName);
    updateGridLayout.addComponent(lblUpdDesc);
    updateGridLayout.addComponent(txtUpdDesc);
    updateGridLayout.addComponent(lblUpdCreDate);
    updateGridLayout.addComponent(txtUpdCreDate);
    updateGridLayout.addComponent(lblUpdCreator);
    updateGridLayout.addComponent(txtUpdCreator);
    updateGridLayout.addComponent(lblUpdParent);
    updateGridLayout.addComponent(txtUpdParent);
    updateGridLayout.addComponent(lblUpdModDate);
    updateGridLayout.addComponent(txtUpdModDate);
    updateGridLayout.addComponent(btnUpdate);

    // "Delete category" fields added
    deleteGridLayout.addComponent(lblDelName);
    deleteGridLayout.addComponent(txtDelName);
    deleteGridLayout.addComponent(lblDelDesc);
    deleteGridLayout.addComponent(txtDelDesc);
    deleteGridLayout.addComponent(lblDelCreDate);
    deleteGridLayout.addComponent(txtDelCreDate);
    deleteGridLayout.addComponent(lblDelCreator);
    deleteGridLayout.addComponent(txtDelCreator);
    deleteGridLayout.addComponent(lblDelParent);
    deleteGridLayout.addComponent(txtDelParent);
    deleteGridLayout.addComponent(lblDelModDate);
    deleteGridLayout.addComponent(txtDelModDate);
    deleteGridLayout.addComponent(btnDelete);

    createGridLayout.setSizeFull();
    createGridLayout.setMargin(true);
    updateGridLayout.setSizeFull();
    updateGridLayout.setMargin(true);
    deleteGridLayout.setSizeFull();
    deleteGridLayout.setMargin(true);

    categoryAccordionCRUD.setSizeFull();
    categoryAccordionCRUD.setHeight("100%");
    categoryAccordionCRUD.addTab(createGridLayout, "Create category");
    categoryAccordionCRUD.addTab(updateGridLayout, "Update category");
    categoryAccordionCRUD.addTab(deleteGridLayout, "Delete category");
  }
Exemple #19
0
  @Override
  public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(3, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    companyEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(Company.class));
    companyEditor.setCaption("Site");
    companyEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(companyEditor, 0, 0);

    invoicingAddressEditor =
        new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    invoicingAddressEditor.setCaption("Invoicing Address");
    invoicingAddressEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(invoicingAddressEditor, 1, 0);

    deliveryAddressEditor =
        new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    deliveryAddressEditor.setCaption("Delivery Address");
    deliveryAddressEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(deliveryAddressEditor, 2, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addListener(
        new ClickListener() {
          /** Serial version UID. */
          private static final long serialVersionUID = 1L;

          @Override
          public void buttonClick(final ClickEvent event) {
            companyEditor.commit();
            invoicingAddressEditor.commit();
            deliveryAddressEditor.commit();
            entityManager.getTransaction().begin();
            try {
              entity = entityManager.merge(entity);
              entityManager.persist(entity);
              entityManager.getTransaction().commit();
              entityManager.detach(entity);
            } catch (final Throwable t) {
              if (entityManager.getTransaction().isActive()) {
                entityManager.getTransaction().rollback();
              }
              throw new RuntimeException("Failed to save entity: " + entity, t);
            }
          }
        });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addListener(
        new ClickListener() {
          /** Serial version UID. */
          private static final long serialVersionUID = 1L;

          @Override
          public void buttonClick(final ClickEvent event) {
            companyEditor.discard();
            invoicingAddressEditor.discard();
            deliveryAddressEditor.discard();
          }
        });
  }