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;
  }
Example #2
0
  @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);
  }
  @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;
  }
Example #5
0
    public void attach() {
      this.addStyleName("custom-report-step-caption");
      Label caption = new Label("Select Reference Table");
      caption.setStyleName("caption");
      this.addComponent(caption);
      box.setWidth(fieldWidth);
      box.setImmediate(true);
      box.addStyleName("custom-report-step-box");
      BeanItemContainer<ReportModel> container =
          new BeanItemContainer<ReportModel>(ReportModel.class);
      container.addAll(getReportModels());
      box.setContainerDataSource(container);
      box.setItemCaptionPropertyId("tableLabel");
      box.addListener(this);
      this.addComponent(box);
      columnLayout.setSpacing(true);
      columnLayout.setVisible(false);

      //			List<ReportTable> relateReportTables=null;
      //			if(getEditableReportTable()!=null){
      //				for(Iterator<ReportModel> it=container.getItemIds().iterator();it.hasNext();){
      //					rm=(ReportModel) it.next();
      //					if(rm.getTableName().equals(getEditableReportTable().getTableName())){
      //						box.setValue(rm);
      //						mainReportTable=rm.getReportTables().iterator().next();
      //						relateReportTables=buildEditableRelatedTableInfo();
      //						break;
      //					}
      //				}
      //				box.setValue(getEditableReportTable().getTableName());
      //				rm.getReportTables().addAll(relateReportTables);
      //			}

      if (relateReportTables != null && isEditableFlg) {
        columnLayout.setVisible(true);
        columnLayout.setImmediate(true);
        //				columnLayout.addComponent(gridLayout);

        //				box.setValue(getEditableReportTable().getTableName());
        //				rm.getReportTables().addAll(relateReportTables);

        for (ReportTable relateRT : relateReportTables) {
          for (Iterator<ReportModel> it = container.getItemIds().iterator(); it.hasNext(); ) {
            ReportModel tempRm = it.next();
            if (tempRm.getTableName().equals(relateRT.getTableName())) {
              box.setValue(tempRm);
              break;
            }
          }
          List<ReportColumn> columnFields = relateRT.getReportColumns();

          for (final ReportColumn columnField : columnFields) {
            if (columnField.getColumnLabel() != null) {
              ReportColumnCard reportColumnCard =
                  new ReportColumnCard(columnField) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void layoutClick(LayoutClickEvent event) {
                      ReportColumn reportColumn = columnField;
                      reportColumn.setColumnUseMode(
                          ReportConfiguration.ReportColumnType.OutputColumn.toString());
                      rm.getSubTableSelectedColumns().add(reportColumn);
                    }
                  };

              for (ReportColumn rc : relateRT.getReportColumns()) {
                if (rc.getColumnUseMode() != null
                    && rc.getColumnUseMode()
                        .equals(ReportConfiguration.ReportColumnType.OutputColumn.toString())) {
                  if (rc.getColumnName().equals(columnField.getColumnName())) {
                    reportColumnCard.getCheckBox().setValue(true);
                  }
                }
              }

              gridLayout.addComponent(reportColumnCard);
            }
          }
        }
      }

      this.addComponent(columnLayout);
      reportColumnLabel.setStyleName("custom-report-step-column-caption");
      reportColumnLabel.setVisible(false);
      reportColumnStepDesc.setStyleName("custom-report-step-column-desc");
      reportColumnStepDesc.setVisible(false);
      this.addComponent(reportColumnLabel);
      this.addComponent(reportColumnStepDesc);
      gridLayout.setSizeFull();
      gridLayout.setImmediate(true);
      gridLayout.addStyleName("custom-report-step-column-gridlayout");
      this.addComponent(gridLayout);
    }
Example #6
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;
  }