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 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;
  }
Exemple #3
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();
            }
          }
        });
  }
  public GridLayout initialize() {

    LOG.debug("Initializing the category and post view");
    buildCategoryTree();
    buildCategoryCRUDAccordion();

    postCRUDAccordion = postView.buildPostCRUDAccordion();
    postCRUDAccordion.setHeight("100%");
    postViewGrid = postView.buildPostViewGrid();

    topLayout.setImmediate(true);
    topLayout.setHeight("100%");
    topLayout.setWidth("100%");
    topLayout.setSpacing(true);

    // first row of the grid layout
    topLayout.addComponent(categoryAccordionCRUD);
    topLayout.addComponent(topTreeLayout);
    topLayout.addComponent(postCRUDAccordion); // builds the CRUD accordion for Posts management

    // second row of the grid layout
    topLayout.addComponent(
        postViewGrid,
        0,
        1,
        2,
        1); // builds the Grid for the Posts view which spans over 3 columns of the row
    topLayout.setComponentAlignment(postViewGrid, Alignment.TOP_LEFT);

    return topLayout;
  }
  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;
  }
  private void refresh() {
    this.platformConfigurationConfiguredResource = new PlatformConfigurationConfiguredResource();

    this.platformConfiguration =
        this.configurationManagement.getConfiguration(this.platformConfigurationConfiguredResource);

    // create the configuration if it does not already exist!
    if (platformConfiguration == null) {
      this.platformConfigurationConfiguredResource.setConfiguration(new PlatformConfiguration());
      platformConfiguration =
          this.configurationManagement.createConfiguration(platformConfigurationConfiguredResource);
    }

    final List<ConfigurationParameter> parameters =
        (List<ConfigurationParameter>) platformConfiguration.getParameters();

    GridLayout layout = new GridLayout();
    layout.setWidth("100%");
    layout.setSpacing(true);

    Panel userPanel = null;
    Panel passwordPanel = null;
    Panel mapPanel = null;

    for (ConfigurationParameter parameter : parameters) {
      if (parameter.getName().equals("webServiceUserAccount")) {
        userParam = parameter;
        userPanel =
            this.createTextFieldPanel(
                parameter,
                new NonZeroLengthStringValidator("The web service user account must be entered!"));
      } else if (parameter.getName().equals("webServiceUserPassword")) {
        passwordParam = parameter;
        passwordPanel =
            this.createPasswordFieldPanel(
                parameter,
                new NonZeroLengthStringValidator("The web service user password must be entered!"));
      }
      if (parameter.getName().equals("configurationMap")) {
        mapPanel = this.createMapPanel((ConfigurationParameterMapImpl) parameter);
      }
    }

    layout.addComponent(userPanel);
    layout.addComponent(passwordPanel);
    layout.addComponent(mapPanel);

    this.setContent(layout);
  }
  private GridLayout getLayout() {

    final GridLayout layout = new GridLayout(4, 5);
    layout.setSpacing(true);
    TextField postalAddress = getTextField("Postal PersonAddress", "postalAddress");
    TextField postalCode = getTextField("Postal Code", "postalCode");
    TextField physicalAddress = getTextField("Physical PersonAddress", "physicalAddress");
    TextField addressType = getTextField("PersonAddress Type", "addressTypeId");

    layout.addComponent(postalAddress, 0, 0);
    layout.addComponent(physicalAddress, 1, 0);
    layout.addComponent(addressType, 0, 1);
    layout.addComponent(postalCode, 1, 1);
    layout.addComponent(getButtons(), 0, 2, 1, 2);
    return layout;
  }
  @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;
  }
  public EditSanctionActsFormUp(EditSanctionActsSubWindow editSanctionActsSubWindow) {
    this.editSanctionActsSubWindow = editSanctionActsSubWindow;
    this.loadSanctionActSubWindow = editSanctionActsSubWindow.getLoadSanctionActSubWindow();
    removeAllComponents();
    setMargin(true);
    gridLayout.setWidth("95%");
    gridLayout.setHeight("65%");
    gridLayout.setImmediate(true);
    // gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    initializeDivisionComboBox();
    initializeEnrollmentTextField();
    initializeStateLcTextField();
    //		initializeTrimesterComponents();

    addComponent(gridLayout);
  }
  public LoginModule() {

    setMargin(true);
    setSpacing(true);
    grid.setSizeFull();
    grid.setSpacing(true);

    final TextField username = new TextField();
    username.setValue("username");
    username.setWidth("120px");
    username.setStyleName("small");
    grid.addComponent(username, 0, 0);

    final PasswordField password = new PasswordField();
    password.setValue("password");
    password.setWidth("120px");
    password.setStyleName("small");
    grid.addComponent(password, 0, 1);

    Button button = new Button("Login");
    button.setWidth("120px");
    button.setStyleName("small");
    button.addListener(
        new Button.ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            login.setUsername(username.getValue().toString());
            login.setPassword(password.getValue().toString());
            String user = login.getUsername();
            String pass = login.getPassword();
            // login.setResult(authLog.login(user, pass));
            boolean result = authLog.login(user, pass);
            if (result == true) {
              label.setCaption("Successfully Login");
            } else {
              label.setCaption("SQL Error");
            }
          }
        });
    grid.addComponent(button, 0, 2);
    panel.addComponent(grid);
    addComponent(panel);
    addComponent(label);
  }
  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;
  }
Exemple #12
0
  private void initLayout() {
    this.setSizeFull();
    this.setSpacing(true);
    this.addComponent(this.header);

    HorizontalLayout toolBarLayout = new HorizontalLayout();
    toolBarLayout.setWidth(100, UNITS_PERCENTAGE);
    toolBarLayout.setSpacing(true);
    this.addComponent(toolBarLayout);

    toolBarLayout.addComponent(this.statusIcon);
    toolBarLayout.addComponent(this.statusLabel);
    toolBarLayout.setExpandRatio(this.statusLabel, 1.0f);
    toolBarLayout.addComponent(this.activationButton);
    toolBarLayout.setComponentAlignment(this.activationButton, Alignment.MIDDLE_RIGHT);
    toolBarLayout.addComponent(this.deleteButton);
    toolBarLayout.setComponentAlignment(this.deleteButton, Alignment.MIDDLE_RIGHT);

    GridLayout detailTabLayout = new GridLayout(2, 2);
    // detailTabLayout.setMargin(new MarginInfo(false, true, true, false));
    detailTabLayout.setSpacing(true);
    detailTabLayout.setSizeFull();
    this.addComponent(detailTabLayout);
    this.setExpandRatio(detailTabLayout, 1.0f);

    this.profileForm.setWidth(100, UNITS_PERCENTAGE);
    this.profileForm.getLayout().addStyleName("gaemvnrepo-form");
    // this.profileForm.addStyleName("gaemvnrepo-form");
    this.profileForm.getLayout().setMargin(true);
    detailTabLayout.addComponent(this.profileForm, 0, 0);

    this.authenticationForm.setWidth(100, UNITS_PERCENTAGE);
    this.authenticationForm.getLayout().addStyleName("gaemvnrepo-form");
    // this.authenticationForm.addStyleName("gaemvnrepo-form");
    this.authenticationForm.getLayout().setMargin(true);
    detailTabLayout.addComponent(this.authenticationForm, 1, 0);
    // detailTabLayout.setRowExpandRatio(0, 0.7f);

    detailTabLayout.addComponent(this.saveButton, 1, 1);
    detailTabLayout.setComponentAlignment(this.saveButton, Alignment.TOP_RIGHT);
    detailTabLayout.setRowExpandRatio(1, 1.0f);
  }
  private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 2);
    layoutSearchPane.setSpacing(true);

    group = new ValueComboBox(false, "Campaign Name", "Start Date", "End Date");
    group.select("Campaign Name");
    group.setImmediate(true);
    group.addValueChangeListener(
        new Property.ValueChangeListener() {
          @Override
          public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Campaign Name")) {
              addTextFieldSearch();
            } else if (searchType.equals("Start Date")) {
              addDateFieldSearch();
            } else if (searchType.equals("End Date")) {
              addDateFieldSearch();
            }
          }
        });

    layoutSearchPane.addComponent(group, 1, 0);
    layoutSearchPane.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            doSearch();
          }
        });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
  }
  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);
  }
 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;
  }
Exemple #19
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);
  }
Exemple #20
0
    @Override
    public void valueChange(ValueChangeEvent event) {
      rm = (ReportModel) box.getValue();
      if (rm != null) {
        columnLayout.setVisible(true);
        columnLayout.setImmediate(true);
        reportColumnStepDesc.setVisible(true);
        List<ReportColumn> columnFields = rm.getReportTables().iterator().next().getReportColumns();
        gridLayout.removeAllComponents();
        gridLayout.requestRepaintAll();
        gridLayout.setRows(columnFields.size());
        gridLayout.setSpacing(true);

        for (final ReportColumn columnField : columnFields) {
          if (columnField.getColumnLabel() != null) {
            ReportColumnCard reportColumnCard =
                new ReportColumnCard(columnField) {
                  @Override
                  public void layoutClick(LayoutClickEvent event) {
                    if (clearDuplicateRelateColumnResult(columnField)) {
                      System.out.println(
                          "User click related column: " + columnField.getColumnLabel());
                      ReportColumn reportColumn = new ReportColumn();
                      reportColumn.setColumnName(columnField.getColumnName());
                      reportColumn.setColumnLabel(columnField.getColumnLabel());
                      reportColumn.setColumnUseMode(
                          ReportConfiguration.ReportColumnType.OutputColumn.toString());
                      if (ReportModelPool.findReportModelByCurrentUser(user)
                              .getSubTableSelectedColumns()
                          == null) {
                        HashSet<ReportColumn> reportColumns = new HashSet<ReportColumn>();
                        reportColumns.add(reportColumn);
                        ReportModelPool.findReportModelByCurrentUser(user)
                            .setSubTableSelectedColumns(reportColumns);
                      } else {
                        ReportModelPool.findReportModelByCurrentUser(user)
                            .getSubTableSelectedColumns()
                            .add(reportColumn);
                      }
                    }
                  }
                };
            gridLayout.addComponent(reportColumnCard);
          }
        }
        this.addComponent(columnLayout);
        ReportTable selectSubReportTable = rm.getReportTables().iterator().next();
        ReportModelPool.findReportModelByCurrentUser(user)
            .getReportTables()
            .add(selectSubReportTable);
        boolean removeStepflg = false;
        for (WizardStep step : w.getSteps()) {
          if (step.getCaption() != null) {
            if (step.getCaption().equals("Report Filter Step")) {
              removeStepflg = true;
            }
          }
        }
        if (removeStepflg) {
          w.removeStep("Report Filter Step");
        }
        w.removeStep("Preview Step");
        w.addStep(new ReportFilterStep(w, user), "Report Filter Step");
        w.addStep(new PreviewStep(w, user), "Preview Step");
      }
    }
  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 #22
0
  private void createEditorArea() {
    Panel editorArea = new Panel();

    GridLayout grid = new GridLayout(2, 3);
    grid.setSizeFull();
    grid.setSpacing(true);
    keyLabel = new Label();
    keyLabel.setValue(Messages.getString("PropertiesEditor_NO_SELECTION_LABEL")); // $NON-NLS-1$
    grid.addComponent(keyLabel, 0, 0, 1, 0);
    grid.setColumnExpandRatio(0, 1.0f);
    grid.setColumnExpandRatio(1, 1.0f);
    orignal = new TextArea();
    orignal.setRows(3);
    orignal.setReadOnly(true);
    orignal.setWidth(100, TextArea.UNITS_PERCENTAGE);

    grid.addComponent(orignal);

    translated = new TextArea();
    translated.setRows(3);
    translated.setInvalidCommitted(true);
    translated.setWidth(100, TextArea.UNITS_PERCENTAGE);

    translated.setNullRepresentation(""); // $NON-NLS-1$
    translated.addListener((TextChangeListener) this);
    translated.setWriteThrough(true);
    translated.setImmediate(true);
    translated.setTextChangeEventMode(TextChangeEventMode.LAZY);
    translated.setTextChangeTimeout(500);

    grid.addComponent(translated);

    orignalComment = new TextArea();
    orignalComment.setReadOnly(true);
    orignalComment.setWidth(100, TextArea.UNITS_PERCENTAGE);
    orignalComment.setRows(3);
    orignalComment.setNullRepresentation(""); // $NON-NLS-1$
    grid.addComponent(orignalComment);

    translatedComment = new TextArea();
    translatedComment.setImmediate(true);
    translatedComment.setWidth(100, TextArea.UNITS_PERCENTAGE);
    translatedComment.setRows(3);

    translatedComment.setNullRepresentation(""); // $NON-NLS-1$
    translatedComment.setInputPrompt(
        Messages.getString("PropertiesEditor_COMMENT_INPUT_PROMPT")); // $NON-NLS-1$
    translatedComment.setWriteThrough(true);
    translatedComment.addListener((TextChangeListener) this);
    grid.addComponent(translatedComment);

    safeButton = new Button();
    safeButton.setEnabled(false);
    safeButton.setCaption(
        Messages.getString("PropertiesEditor_SAVE_BUTTON_CAPTION")); // $NON-NLS-1$
    safeButton.addListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {

            setDirty(false);
            PropertyPersistenceService propertyPersistence =
                MainDashboard.getCurrent().getPropertyPersistence();
            propertyPersistence.saveProperties(descriptor, target);
            layout
                .getWindow()
                .showNotification(
                    Messages.getString("PropertiesEditor_SAVED_CONFIRMATION_DIALOG_TITLE"),
                    descriptor.getLocation().lastSegment()); // $NON-NLS-1$
          }
        });
    editorArea.setContent(grid);

    HorizontalLayout buttonArea = new HorizontalLayout();
    buttonArea.setSpacing(true);
    layout.addComponent(editorArea);
    layout.setExpandRatio(editorArea, 0);
    buttonArea.addComponent(safeButton);

    Button editTemplate =
        new Button(
            Messages.getString("PropertiesEditor_EDIT_TEMPLATE_BUTTON_CAPTION")); // $NON-NLS-1$
    editTemplate.addListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            BreadCrumb crumb = MainDashboard.getCurrent().getBreadcrumbs();
            crumb.walkTo("?master"); // $NON-NLS-1$
          }
        });
    buttonArea.addComponent(editTemplate);
    layout.addComponent(buttonArea);
    layout.setExpandRatio(buttonArea, 0);
  }
Exemple #23
0
  /**
   * Builds main layout
   *
   * @return mainLayout VerticalLayout with all dialog components
   */
  @AutoGenerated
  private VerticalLayout buildMainLayout(final boolean newUser) {

    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setWidth("380px");

    users = userFacade.getAllUsers();

    userDetailsLayout = new GridLayout(2, 5);
    userDetailsLayout.setImmediate(false);
    userDetailsLayout.setSpacing(true);

    userFullName = new TextField();
    userFullName.setImmediate(true);
    userFullName.setWidth("250px");
    userFullName.addValidator(
        new Validator() {
          private static final long serialVersionUID = 1L;

          @Override
          public void validate(Object value) throws InvalidValueException {
            if (value != null
                && (value.getClass() == String.class && !((String) value).isEmpty())) {

              String inputFullName = (String) value;

              Pattern namePattern1 =
                  Pattern.compile(
                      "([A-Za-zŽžÝýŮůÚúŤťŠšŘřÓóŇňÍíĚěÉéĎďČčÁáÄäÖößÜüÀàÈèÙùÂâÊêÎîÔôÛûÇçËëÏïÜüŸÿ]+\\s*)+",
                      Pattern.UNICODE_CASE);
              Matcher m = namePattern1.matcher(inputFullName);
              if (!m.matches()) {
                ex =
                    new InvalidValueException(
                        "Full user name must start with a letter and can only consists of letters and spaces.");
                throw ex;
              }
              if ((m.end() - m.start()) < 2) {

                ex = new InvalidValueException("Full user name must contains more than one symbol");
                throw ex;
              }
            }
          }
        });

    userDetailsLayout.addComponent(new Label("Full user name:"), 0, 0);
    userDetailsLayout.addComponent(userFullName, 1, 0);

    userName = new TextField();
    userName.setImmediate(true);
    userName.setWidth("250px");
    userName.addValidator(
        new Validator() {
          private static final long serialVersionUID = 1L;

          @Override
          public void validate(Object value) throws InvalidValueException {
            if (value.getClass() == String.class && !((String) value).isEmpty()) {

              String inputName = (String) value;
              for (User user : users) {
                if (user.getUsername().equals(inputName)) {
                  if (selectUser == null || (selectUser.getId() != user.getId())) {
                    ex = new InvalidValueException("user with this user name is already exist");
                    throw ex;
                  }
                }
              }

              return;
            }
            ex = new InvalidValueException("user name field must be filled");
            throw ex;
          }
        });

    userDetailsLayout.addComponent(new Label("User name:"), 0, 1);
    userDetailsLayout.addComponent(userName, 1, 1);

    password = new PasswordField();
    password.setImmediate(true);
    password.setWidth("250px");
    password.addFocusListener(
        new FocusListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void focus(FocusEvent event) {
            password.setValue("");
            passwordConfim.setValue("");
            passChanged = true;
          }
        });

    Label passLabel = new Label("Password:"******"250px");
    Label confirmLabel = new Label("Password<br>confirmation:");
    passwordConfim.addFocusListener(
        new FocusListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void focus(FocusEvent event) {
            passwordConfim.setValue("");
            passChanged = true;
          }
        });

    confirmLabel.setContentMode(ContentMode.HTML);

    userDetailsLayout.addComponent(confirmLabel, 0, 3);
    userDetailsLayout.addComponent(passwordConfim, 1, 3);

    userEmail = new TextField();
    userEmail.setImmediate(true);
    userEmail.setWidth("250px");
    userEmail.addValidator(
        new Validator() {
          private static final long serialVersionUID = 1L;

          @Override
          public void validate(Object value) throws InvalidValueException {

            if (value.getClass() == String.class && !((String) value).isEmpty()) {
              String inputEmail = (String) value;
              if (!inputEmail.matches(
                  "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})")) {
                ex = new InvalidValueException("wrong mail format");
                throw ex;
              }
              return;
            }
            ex = new InvalidValueException("e-mail field must be filled");
            throw ex;
          }
        });

    userDetailsLayout.addComponent(new Label("E-mail:"), 0, 4);
    userDetailsLayout.addComponent(userEmail, 1, 4);

    userDetailsLayout.setColumnExpandRatio(0, 0.3f);
    userDetailsLayout.setColumnExpandRatio(1, 0.7f);

    roleSelector = new TwinColSelect();
    roleSelector.addItem(Role.ROLE_ADMIN);
    roleSelector.addItem(Role.ROLE_USER);

    roleSelector.setNullSelectionAllowed(true);
    roleSelector.setMultiSelect(true);
    roleSelector.setImmediate(true);
    roleSelector.setWidth("335px");
    roleSelector.setHeight("200px");
    roleSelector.setLeftColumnCaption("Defined Roles:");
    roleSelector.setRightColumnCaption("Set Roles:");
    roleSelector.addValueChangeListener(
        new ValueChangeListener() {

          private static final long serialVersionUID = 1L;

          @Override
          public void valueChange(ValueChangeEvent event) {

            Set<Object> selectedRoles = (Set<Object>) roleSelector.getValue();
            Iterator<Object> it = selectedRoles.iterator();
            Set<Role> role = new HashSet<>();
            while (it.hasNext()) {
              Object selectRole = it.next();
              if (selectRole.equals(Role.ROLE_ADMIN)) {
                role.add(Role.ROLE_ADMIN);
                role.add(Role.ROLE_USER);
                roleSelector.setValue(role);
              }
            }
          }
        });
    // roleSelector is mandatory component
    roleSelector.addValidator(
        new Validator() {
          private static final long serialVersionUID = 1L;

          @Override
          public void validate(Object value) throws InvalidValueException {

            if (!"[]".equals(value.toString())) {
              return;
            }
            ex = new InvalidValueException("at least one role must be set");
            throw ex;
          }
        });

    // Layout with buttons Save and Cancel
    HorizontalLayout buttonBar = new HorizontalLayout();
    //		buttonBar.setMargin(true);

    // Save button
    Button createUser = new Button();
    createUser.setCaption("Save");
    createUser.setWidth("90px");
    createUser.setImmediate(true);
    createUser.addClickListener(
        new ClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void buttonClick(ClickEvent event) {
            String errorText = "";
            // validation
            // User name, password,e-mail and roles should be filled
            // email should be in correct format
            try {
              userFullName.validate();

            } catch (Validator.InvalidValueException e) {
              errorText = errorText + e.getMessage();
            }

            try {
              userName.validate();

            } catch (Validator.InvalidValueException e) {
              if (!errorText.equals("")) {
                errorText = errorText + ", " + e.getMessage();
              } else {
                errorText = errorText + e.getMessage();
              }
            }

            try {
              userEmail.validate();

            } catch (Validator.InvalidValueException e) {
              if (!errorText.equals("")) {
                errorText = errorText + ", " + e.getMessage();
              } else {
                errorText = errorText + e.getMessage();
              }
            }

            try {
              roleSelector.validate();

            } catch (Validator.InvalidValueException e) {
              if (!errorText.equals("")) {
                errorText = errorText + ", " + e.getMessage();
              } else {
                errorText = errorText + e.getMessage();
              }
            }

            if (!errorText.equals("")) {
              errorText = errorText + ".";
              Notification.show(
                  "Failed to save settings. Reason:", errorText, Notification.Type.ERROR_MESSAGE);
              return;
            }

            // checking if the dialog was open from the User table
            // if no, create new user record

            if (newUser) {
              String userPassword;

              if (passwordConfim.getValue().equals(password.getValue())) {
                if (!passwordConfim.getValue().isEmpty()) {
                  userPassword = password.getValue();
                } else {
                  userPassword = createPassword();
                }
              } else {
                Notification.show(
                    "Password confirmation is wrong",
                    "The typed pasword is different than the retyped password",
                    Notification.Type.ERROR_MESSAGE);
                return;
              }

              EmailAddress email = new EmailAddress(userEmail.getValue().trim());
              user = userFacade.createUser(userName.getValue().trim(), userPassword, email);
              user.setFullName(userFullName.getValue().trim());

            } else {
              user = selectUser;
              user.setFullName(userFullName.getValue().trim());
              user.setUsername(userName.getValue().trim());
              if (passChanged) {
                if (passwordConfim.getValue().equals(password.getValue())) {
                  if (!passwordConfim.getValue().isEmpty()) {
                    user.setPassword(password.getValue());
                  } else {
                    user.setPassword(createPassword());
                  }
                } else {
                  Notification.show(
                      "Password confirmation is wrong",
                      "The typed pasword is different than the retyped password",
                      Notification.Type.ERROR_MESSAGE);
                  return;
                }
              }

              EmailAddress email = new EmailAddress(userEmail.getValue().trim());
              user.setEmail(email);
            }

            @SuppressWarnings("unchecked")
            Set<Object> selectedRoles = (Set<Object>) roleSelector.getValue();
            Iterator<Object> it = selectedRoles.iterator();
            roles = new HashSet<>();
            while (it.hasNext()) {
              Object selectRole = it.next();
              if (selectRole.equals(Role.ROLE_ADMIN)) {
                roles.add(Role.ROLE_ADMIN);
              } else {
                roles.add(Role.ROLE_USER);
              }
            }

            user.setRoles(roles);

            // store user record to DB
            userFacade.save(user);

            close();
          }
        });

    buttonBar.addComponent(createUser);

    Button cancelButton =
        new Button(
            "Cancel",
            new Button.ClickListener() {
              /** Closes Scheduling pipeline window */
              private static final long serialVersionUID = 1L;

              @Override
              public void buttonClick(Button.ClickEvent event) {
                close();
              }
            });
    cancelButton.setWidth("90px");
    buttonBar.addComponent(cancelButton);

    mainLayout.addComponent(userDetailsLayout);
    mainLayout.addComponent(roleSelector);
    mainLayout.addComponent(buttonBar);
    //		mainLayout.setComponentAlignment(buttonBar, Alignment.MIDDLE_RIGHT);

    return mainLayout;
  }
Exemple #24
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();
          }
        });
  }