Exemple #1
0
  @Test
  public void testFormAdd() throws Exception {
    Form form = new Form(request);
    assertEquals(0, form.size());

    Button button = Button.button("OK");
    form.add(button);
    assertEquals(1, form.size());

    TextField field = new TextField("name");
    form.add(field, "Name");
    form.add(null); // ignored
    form.add(null, "Name"); // ignored
    assertEquals(2, form.size());
    assertSame(field, form.get(1));
    assertSame(field, form.get("name"));
    assertNull(form.get("x"));
    assertNull(form.get(null));
    try {
      // cannot add twice
      form.add(field);
      fail();
    } catch (IllegalStateException e) {
    }

    form.setRequired(true);
    assertTrue(field.isRequired());
    form.setReadOnly(true);
    assertTrue(field.isReadOnly());

    assertTrue(form.validate(true));

    form.remove(field);
    assertEquals(1, form.size());
  }
Exemple #2
0
 private void createMailInput(Form<T> form) {
   TextField<String> emailField = new TextField<String>("user.email");
   emailField.add(EmailAddressValidator.getInstance());
   emailField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(emailField);
   form.add(new AjaxFormComponentFeedbackIndicator("emailValidationError", emailField));
 }
Exemple #3
0
  @Test
  public void testButton() {
    Form form = new Form(request);
    Button button;

    button = Button.button("OK");
    assertOut(button, "<button>OK</button>");
    assertEquals(null, button.getName());
    form.add(button);
    assertEquals(form.getName() + "_button", button.getName());

    button = Button.reset("Reset");
    button.setDisabled();
    assertOut(button, "<button type='reset' disabled>Reset</button>");

    button = Button.submit("Submit");
    button.setName("submit");
    assertOut(button, "<button type='submit' name='submit' value='Submit'>Submit</button>");
    form.add(button);
    assertEquals("submit", button.getName());
    Button defaultButton = button;
    assertSame(form.getDefaultButton(), button);

    button = Button.inputButton("OK");
    assertOut(button, "<input type='button' value='OK'>");

    button = Button.inputReset("Reset");
    assertOut(button, "<input type='reset' value='Reset'>");

    button = Button.inputSubmit("Submit");
    button.setOnClick("alert()");
    assertOut(button, "<input type='submit' value='Submit' onclick='alert()'>");
    button.end(out);
    out.assertOut("");
    form.add(button);
    assertSame(defaultButton, form.getDefaultButton());

    // misc
    assertTrue(button.read(null));
    assertEquals(Control.Category.BUTTON, button.getCategory());

    assertFalse(defaultButton.isClicked());
    setParam(form.getName(), "");
    assertTrue(defaultButton.isClicked());
    assertFalse(button.isClicked());
    setParam(form.getName(), "reload");
    assertFalse(defaultButton.isClicked());
    setParam(defaultButton.getName(), "x");
    assertFalse(defaultButton.isClicked());
    setParam(defaultButton.getName(), defaultButton.getValue());
    assertTrue(defaultButton.isClicked());

    setParam(defaultButton.getName(), null);
    assertFalse(defaultButton.isDirectlyClicked());
    setParam(defaultButton.getName(), "x");
    assertFalse(defaultButton.isDirectlyClicked());
    setParam(defaultButton.getName(), defaultButton.getValue());
    assertTrue(defaultButton.isDirectlyClicked());
  }
Exemple #4
0
 private void createUsernameInput(Form<T> form) {
   RequiredTextField<String> usernameField = new RequiredTextField<String>("user.username");
   form.add(usernameField);
   usernameField.add(new StringValidator(0, 32));
   usernameField.add(new DuplicateUsernameValidator());
   usernameField.setLabel(new ResourceModel("admin.user.username"));
   usernameField.add(new ValidatingFormComponentAjaxBehavior());
   form.add(new AjaxFormComponentFeedbackIndicator("userValidationError", usernameField));
 }
Exemple #5
0
  private void createNameInput(Form<T> form) {
    TextField<String> firstNameField = new TextField<String>("user.firstName");
    form.add(firstNameField);

    TextField<String> lastNameField = new RequiredTextField<String>("user.lastName");
    form.add(lastNameField);
    lastNameField.setLabel(new ResourceModel("admin.user.lastName"));
    lastNameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("lastNameValidationError", lastNameField));
  }
Exemple #6
0
 private void createRoleInput(Form<T> form) {
   ListMultipleChoice<UserRole> userRoles =
       new ListMultipleChoice<UserRole>("user.userRoles", getUserRoles(), new UserRoleRenderer());
   userRoles.setMaxRows(4);
   userRoles.setLabel(new ResourceModel("admin.user.roles"));
   userRoles.setRequired(true);
   userRoles.add(new ValidatingFormComponentAjaxBehavior());
   form.add(userRoles);
   form.add(new AjaxFormComponentFeedbackIndicator("rolesValidationError", userRoles));
 }
Exemple #7
0
  @Override
  protected void onInitialize() {
    super.onInitialize();

    IModel<T> userModel = getPanelModel();

    T manageUserBackingBean = getPanelModelObject();
    User user = manageUserBackingBean.getUser();

    boolean editMode = user.getPK() != null;

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder(BORDER, WebGeo.AUTO);
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<T> form = new Form<T>(FORM, userModel);

    createUsernameInput(form);
    createNameInput(form);
    createMailInput(form);
    createPasswordInput(userModel, manageUserBackingBean, form);
    createDepartmentInput(form);
    createRoleInput(form);
    createActiveInput(form);

    // show assignments
    CheckBox showAssignments = new CheckBox("showAssignments");
    showAssignments.setMarkupId("showAssignments");
    showAssignments.setVisible(!manageUserBackingBean.isEditMode());
    form.add(showAssignments);

    // data save label
    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));

    boolean deletable = user.isDeletable();

    FormConfig formConfig =
        FormConfig.forForm(form)
            .withDelete(deletable)
            .withDeleteEventType(USER_DELETED)
            .withSubmitTarget(this)
            .withSubmitEventType(editMode ? USER_UPDATED : USER_CREATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);

    onFormCreated(form);
  }
Exemple #8
0
  private void createPasswordInput(IModel<T> userModel, T manageUserBackingBean, Form<T> form) {
    Label label = new Label("passwordEditLabel", new ResourceModel("admin.user.editPassword"));
    label.setVisible(manageUserBackingBean.isEditMode());
    form.add(label);

    PasswordFieldFactory.createOptionalPasswordFields(
        form, new PropertyModel<String>(userModel, "user.password"));
  }
Exemple #9
0
  public CustomerFormPanel(String id, CompoundPropertyModel<CustomerAdminBackingBean> model) {
    super(id, model);

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder("border");
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<CustomerAdminBackingBean> form =
        new Form<CustomerAdminBackingBean>("customerForm", model);

    // name
    RequiredTextField<String> nameField = new RequiredTextField<String>("customer.name");
    form.add(nameField);

    nameField.add(StringValidator.lengthBetween(0, 64));
    nameField.setLabel(new ResourceModel("admin.customer.name"));
    nameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("nameValidationError", nameField));

    // code
    final RequiredTextField<String> codeField = new RequiredTextField<String>("customer.code");
    form.add(codeField);
    codeField.add(StringValidator.lengthBetween(0, 16));
    codeField.setLabel(new ResourceModel("admin.customer.code"));
    codeField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new UniqueCustomerValidator(nameField, codeField));
    form.add(new AjaxFormComponentFeedbackIndicator("codeValidationError", codeField));

    // description
    TextArea<String> textArea = new KeepAliveTextArea("customer.description");
    textArea.setLabel(new ResourceModel("admin.customer.description"));
    form.add(textArea);

    // active
    form.add(new CheckBox("customer.active"));

    // data save label
    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));

    //

    boolean deletable = model.getObject().getCustomer().isDeletable();
    FormConfig formConfig =
        new FormConfig()
            .forForm(form)
            .withDelete(deletable)
            .withSubmitTarget(this)
            .withDeleteEventType(CustomerAjaxEventType.CUSTOMER_DELETED)
            .withSubmitEventType(CustomerAjaxEventType.CUSTOMER_UPDATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);
  }
Exemple #10
0
  protected void createDepartmentInput(Form<T> form) {
    Fragment f = new Fragment("dept", "department", this);

    DropDownChoice<UserDepartment> userDepartment =
        new DropDownChoice<UserDepartment>(
            "user.userDepartment",
            getUserDepartments(),
            new ChoiceRenderer<UserDepartment>("name"));
    userDepartment.setRequired(true);
    userDepartment.setLabel(new ResourceModel("admin.user.department"));
    userDepartment.add(new ValidatingFormComponentAjaxBehavior());
    f.add(userDepartment);
    f.add(new AjaxFormComponentFeedbackIndicator("departmentValidationError", userDepartment));
    form.add(f);
  }
    /** Construct. */
    public StringArrayPage() {

      form = new Form<Void>("form");
      add(form);

      form.add(
          new TextField<String[]>("array", new PropertyModel<String[]>(this, "array")) {
            private static final long serialVersionUID = 1L;

            @Override
            protected IConverter<?> createConverter(Class<?> type) {
              return new StringArrayConverter();
            }
          }.setConvertEmptyInputStringToNull(false));
    }
Exemple #12
0
  @Test
  public void testFileField() {
    FileField field = new FileField("photo");

    Form form = new Form(request);
    assertFalse(form.isMultipartEncoded());
    form.add(field);
    assertTrue(form.isMultipartEncoded());

    assertOut(field, "<input type='file' name='photo'>");

    Upload upload = mock(Upload.class);
    when(request.getUploads("photo")).thenReturn(new Upload[] {upload});
    field.read(request);
    assertSame(upload, field.getUpload());
  }
Exemple #13
0
  @Test
  public void testFormRead() throws Exception {
    Form form = new Form(request);

    TextField field = new TextField("name");
    form.add(field, "Name");
    field.setRequired(true);

    form.clearErrorControl();
    when(request.getRequest()).thenReturn(request);
    when(request.getParameter("name")).thenReturn(null);
    assertFalse(form.read());
    assertFalse(form.isOk());
    assertSame(field, form.getErrorControl());

    when(request.getParameter("name")).thenReturn("John");
    assertTrue(form.read());
    assertTrue(form.isOk());
    assertNull(form.getErrorControl());
  }
Exemple #14
0
  public UserAdminFormPanel(
      String id,
      CompoundPropertyModel<UserBackingBean> userModel,
      List<UserRole> roles,
      List<UserDepartment> departments) {
    super(id, userModel);

    GreySquaredRoundedBorder greyBorder = new GreySquaredRoundedBorder(BORDER);
    add(greyBorder);

    setOutputMarkupId(true);

    final Form<UserBackingBean> form = new Form<UserBackingBean>(FORM, userModel);

    // username
    RequiredTextField<String> usernameField = new RequiredTextField<String>("user.username");
    form.add(usernameField);
    usernameField.add(new StringValidator(0, 32));
    usernameField.add(new DuplicateUsernameValidator());
    usernameField.setLabel(new ResourceModel("admin.user.username"));
    usernameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("userValidationError", usernameField));

    // user info
    TextField<String> firstNameField = new TextField<String>("user.firstName");
    form.add(firstNameField);

    TextField<String> lastNameField = new RequiredTextField<String>("user.lastName");
    form.add(lastNameField);
    lastNameField.setLabel(new ResourceModel("admin.user.lastName"));
    lastNameField.add(new ValidatingFormComponentAjaxBehavior());
    form.add(new AjaxFormComponentFeedbackIndicator("lastNameValidationError", lastNameField));

    form.add(new EmailInputSnippet("email"));

    // password
    Label label = new Label("passwordEditLabel", new ResourceModel("admin.user.editPassword"));
    label.setVisible(userModel.getObject().getAdminAction() == AdminAction.EDIT);
    form.add(label);

    PasswordFieldFactory.createOptionalPasswordFields(
        form, new PropertyModel<String>(userModel, "user.password"));

    // department
    DropDownChoice<UserDepartment> userDepartment =
        new DropDownChoice<UserDepartment>(
            "user.userDepartment", departments, new ChoiceRenderer<UserDepartment>("name"));
    userDepartment.setRequired(true);
    userDepartment.setLabel(new ResourceModel("admin.user.department"));
    userDepartment.add(new ValidatingFormComponentAjaxBehavior());
    form.add(userDepartment);
    form.add(new AjaxFormComponentFeedbackIndicator("departmentValidationError", userDepartment));

    // user roles
    ListMultipleChoice<UserRole> userRoles =
        new ListMultipleChoice<UserRole>("user.userRoles", roles, new UserRoleRenderer());
    userRoles.setMaxRows(4);
    userRoles.setLabel(new ResourceModel("admin.user.roles"));
    userRoles.setRequired(true);
    userRoles.add(new ValidatingFormComponentAjaxBehavior());
    form.add(userRoles);
    form.add(new AjaxFormComponentFeedbackIndicator("rolesValidationError", userRoles));

    // active
    form.add(new CheckBox("user.active"));

    // data save label
    form.add(new ServerMessageLabel("serverMessage", "formValidationError"));

    boolean deletable = userModel.getObject().getUser().isDeletable();

    FormConfig formConfig =
        new FormConfig()
            .forForm(form)
            .withDelete(deletable)
            .withSubmitTarget(this)
            .withDeleteEventType(UserEditAjaxEventType.USER_DELETED)
            .withSubmitEventType(UserEditAjaxEventType.USER_UPDATED);

    FormUtil.setSubmitActions(formConfig);

    greyBorder.add(form);
  }
  private void jbInit() throws Exception {
    itemsGrid.setMaxNumberOfRowsOnInsert(50);
    impAllItemsButton.setToolTipText(
        ClientSettings.getInstance().getResources().getResource("import all items"));
    impAllItemsButton.addActionListener(
        new SupplierDetailFrame_impAllItemsButton_actionAdapter(this));

    detailPanel.setLayout(gridBagLayout4);
    itemsGrid.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    supplierPanel.setVOClassName("org.jallinone.purchases.suppliers.java.DetailSupplierVO");
    supplierPanel.addLinkedPanel(organizationPanel);
    titledBorder1 = new TitledBorder("");
    titledBorder2 = new TitledBorder("");
    subjectPanel.setLayout(gridBagLayout1);
    supplierPanel.setBorder(titledBorder1);
    supplierPanel.setLayout(gridBagLayout2);
    titledBorder1.setTitle(ClientSettings.getInstance().getResources().getResource("supplier"));
    titledBorder1.setTitleColor(Color.blue);
    labelSupplierCode.setText("supplierCodePUR01");
    labelPay.setText("payment terms");
    labelBank.setText("bank");
    controlSupplierCode.setAttributeName("supplierCodePUR01");
    controlSupplierCode.setCanCopy(false);
    controlSupplierCode.setLinkLabel(labelSupplierCode);
    controlSupplierCode.setMaxCharacters(20);
    //    controlSupplierCode.setRequired(true);
    controlSupplierCode.setTrimText(true);
    controlSupplierCode.setUpperCase(true);
    controlSupplierCode.setEnabledOnEdit(false);
    controlPayment.setAttributeName("paymentCodeReg10PUR01");
    controlPayment.setCanCopy(true);
    controlPayment.setLinkLabel(labelPay);
    controlPayment.setMaxCharacters(20);
    controlPayment.setRequired(true);
    controlPayDescr.setAttributeName("paymentDescriptionSYS10");
    controlPayDescr.setCanCopy(true);
    controlPayDescr.setEnabledOnInsert(false);
    controlPayDescr.setEnabledOnEdit(false);
    controlBank.setAttributeName("bankCodeReg12PUR01");
    controlBank.setCanCopy(true);
    controlBank.setLinkLabel(labelBank);
    controlBank.setMaxCharacters(20);
    controlBankDescr.setAttributeName("descriptionREG12");
    controlBankDescr.setCanCopy(true);
    controlBankDescr.setEnabledOnInsert(false);
    controlBankDescr.setEnabledOnEdit(false);
    refPanel.setLayout(borderLayout1);
    hierarPanel.setLayout(borderLayout4);
    treeGridItemsPanel.setLayout(borderLayout3);
    itemsSplitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    itemsSplitPane.setDividerSize(5);
    itemsPanel.setLayout(borderLayout5);
    itemButtonsPanel.setLayout(flowLayout2);
    flowLayout2.setAlignment(FlowLayout.LEFT);
    itemsGrid.setAutoLoadData(false);
    itemsGrid.setDeleteButton(deleteButton1);
    itemsGrid.setEditButton(editButton1);
    itemsGrid.setExportButton(exportButton1);
    itemsGrid.setFunctionId("PUR01");
    itemsGrid.setMaxSortedColumns(3);
    itemsGrid.setInsertButton(insertButton1);
    itemsGrid.setNavBar(navigatorBar1);
    itemsGrid.setReloadButton(reloadButton1);
    itemsGrid.setSaveButton(saveButton1);
    itemsGrid.setValueObjectClassName("org.jallinone.purchases.items.java.SupplierItemVO");
    insertButton1.setText("insertButton1");
    editButton1.setText("editButton1");
    saveButton1.setText("saveButton1");
    reloadButton1.setText("reloadButton1");
    deleteButton1.setText("deleteButton1");
    itemHierarsPanel.setLayout(gridBagLayout3);
    labelHierar.setText("item hierarchies");
    colItemCode.setColumnFilterable(true);
    colItemCode.setColumnName("itemCodeItm01PUR02");
    colItemCode.setColumnSortable(true);
    colItemCode.setEditableOnInsert(true);
    colItemCode.setHeaderColumnName("itemCodeITM01");
    colItemCode.setPreferredWidth(90);
    colItemCode.setSortVersus(org.openswing.swing.util.java.Consts.ASC_SORTED);
    colItemCode.setMaxCharacters(20);
    colItemDescr.setColumnFilterable(true);
    colItemDescr.setColumnName("descriptionSYS10");
    colItemDescr.setColumnSortable(true);
    colItemDescr.setHeaderColumnName("itemDescriptionSYS10");
    colItemDescr.setPreferredWidth(200);
    colSupplierItemCode.setMaxCharacters(20);
    colSupplierItemCode.setTrimText(true);
    colSupplierItemCode.setUpperCase(true);
    colSupplierItemCode.setColumnFilterable(true);
    colSupplierItemCode.setColumnName("supplierItemCodePUR02");
    colSupplierItemCode.setColumnSortable(true);
    colSupplierItemCode.setEditableOnEdit(true);
    colSupplierItemCode.setEditableOnInsert(true);
    colSupplierItemCode.setHeaderColumnName("supplierItemCodePUR02");
    colSupplierItemCode.setPreferredWidth(120);
    colUmCode.setColumnDuplicable(true);
    colUmCode.setColumnFilterable(true);
    colUmCode.setColumnName("umCodeReg02PUR02");
    colUmCode.setEditableOnEdit(true);
    colUmCode.setEditableOnInsert(true);
    colUmCode.setHeaderColumnName("umCodeReg02PUR02");
    colUmCode.setMaxCharacters(20);
    colMinQty.setDecimals(2);
    colMinQty.setGrouping(false);
    colMinQty.setColumnDuplicable(true);
    colMinQty.setColumnFilterable(true);
    colMinQty.setColumnSortable(true);
    colMinQty.setEditableOnEdit(true);
    colMinQty.setEditableOnInsert(true);
    colMinQty.setPreferredWidth(80);
    colMinQty.setColumnName("minPurchaseQtyPUR02");
    colMultipleQty.setGrouping(false);
    colMultipleQty.setColumnDuplicable(true);
    colMultipleQty.setColumnFilterable(true);
    colMultipleQty.setColumnSortable(true);
    colMultipleQty.setEditableOnEdit(true);
    colMultipleQty.setEditableOnInsert(true);
    colMultipleQty.setPreferredWidth(80);
    colMultipleQty.setColumnName("multipleQtyPUR02");
    subjectPanel.add(
        organizationPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    this.setTitle(ClientSettings.getInstance().getResources().getResource("supplier detail"));
    buttonsPanel.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.LEFT);
    insertButton.setText("insertButton1");
    editButton.setText("editButton1");
    saveButton.setEnabled(false);
    saveButton.setText("saveButton1");
    reloadButton.setText("reloadButton1");
    deleteButton.setText("deleteButton1");

    labelCompanyCode.setText("companyCodeSys01REG04");
    controlCompanyCode.setAttributeName("companyCodeSys01REG04");
    controlCompanyCode.setLinkLabel(labelCompanyCode);
    controlCompanyCode.setRequired(true);
    controlCompanyCode.setEnabledOnEdit(false);

    this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
    buttonsPanel.add(insertButton, null);
    buttonsPanel.add(editButton, null);
    buttonsPanel.add(saveButton, null);
    buttonsPanel.add(reloadButton, null);
    buttonsPanel.add(deleteButton, null);
    buttonsPanel.add(navigatorBar, null);
    //    tabbedPane.add(subjectPanel,   "generic data");
    this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    supplierPanel.add(
        labelCompanyCode,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlCompanyCode,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));

    //    tabbedPane.add(supplierPanel,    "supplierPanel");
    supplierPanel.add(
        labelSupplierCode,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlSupplierCode,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPay,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        controlPayment,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlPayDescr,
        new GridBagConstraints(
            2,
            2,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPricelist,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelBank,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 5),
            0,
            0));
    supplierPanel.add(
        controlBank,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlBankDescr,
        new GridBagConstraints(
            2,
            4,
            2,
            3,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));

    supplierPanel.add(
        labelDebit,
        new GridBagConstraints(
            0,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    supplierPanel.add(
        labelPurchase,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 15, 5),
            0,
            0));
    supplierPanel.add(
        controlDebitsCode,
        new GridBagConstraints(
            1,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlDebitsDescr,
        new GridBagConstraints(
            2,
            5,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    supplierPanel.add(
        controlCostsCode,
        new GridBagConstraints(
            1,
            6,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            40,
            0));
    supplierPanel.add(
        controlCostsDescr,
        new GridBagConstraints(
            2,
            6,
            2,
            3,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));

    labelDebit.setText("debits account");
    labelPurchase.setText("purchase costs account");
    controlDebitsCode.setAttributeName("debitAccountCodeAcc02PUR01");
    controlDebitsDescr.setAttributeName("debitAccountDescrPUR01");
    controlCostsCode.setAttributeName("costsAccountCodeAcc02PUR01");
    controlCostsDescr.setAttributeName("costsAccountDescrPUR01");

    detailPanel.add(
        subjectPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
    detailPanel.add(
        supplierPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    tabbedPane.add(detailPanel, "supplier data");

    tabbedPane.add(refPanel, "references");
    refPanel.add(referencesPanel, BorderLayout.CENTER);
    tabbedPane.add(hierarPanel, "hierarchies");
    hierarPanel.add(hierarchiesPanel, BorderLayout.CENTER);
    tabbedPane.add(treeGridItemsPanel, "supplierItems");
    treeGridItemsPanel.add(itemsSplitPane, BorderLayout.CENTER);
    itemsSplitPane.add(treePanel, JSplitPane.LEFT);
    itemsSplitPane.add(itemsPanel, JSplitPane.RIGHT);
    itemsPanel.add(itemButtonsPanel, BorderLayout.NORTH);
    itemsPanel.add(itemsGrid, BorderLayout.CENTER);
    itemsGrid.getColumnContainer().add(colItemCode, null);
    itemButtonsPanel.add(insertButton1, null);
    itemButtonsPanel.add(editButton1, null);
    itemButtonsPanel.add(saveButton1, null);
    itemButtonsPanel.add(reloadButton1, null);
    itemButtonsPanel.add(deleteButton1, null);
    itemButtonsPanel.add(exportButton1, null);
    itemButtonsPanel.add(navigatorBar1, null);
    itemButtonsPanel.add(impAllItemsButton, null);

    controlDebitsCode.setLinkLabel(labelDebit);
    controlDebitsCode.setMaxCharacters(20);
    controlDebitsCode.setRequired(true);
    controlDebitsDescr.setEnabledOnInsert(false);
    controlDebitsDescr.setEnabledOnEdit(false);
    controlCostsCode.setLinkLabel(labelPurchase);
    controlCostsCode.setMaxCharacters(20);
    controlCostsCode.setRequired(true);
    controlCostsDescr.setEnabledOnInsert(false);
    controlCostsDescr.setEnabledOnEdit(false);

    treeGridItemsPanel.add(itemHierarsPanel, BorderLayout.NORTH);
    itemHierarsPanel.add(
        labelHierar,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 0),
            0,
            0));
    itemHierarsPanel.add(
        controlHierarchy,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            100,
            0));
    tabbedPane.add(supplierPricelistPanel, "supplierPricelistPanel");
    itemsGrid.getColumnContainer().add(colItemDescr, null);
    itemsGrid.getColumnContainer().add(colSupplierItemCode, null);
    itemsGrid.getColumnContainer().add(colUmCode, null);
    itemsGrid.getColumnContainer().add(colMinQty, null);
    itemsGrid.getColumnContainer().add(colMultipleQty, null);

    tabbedPane.setTitleAt(
        0, ClientSettings.getInstance().getResources().getResource("supplier data"));
    tabbedPane.setTitleAt(1, ClientSettings.getInstance().getResources().getResource("references"));
    tabbedPane.setTitleAt(
        2, ClientSettings.getInstance().getResources().getResource("hierarchies"));
    tabbedPane.setTitleAt(
        3, ClientSettings.getInstance().getResources().getResource("supplierItems"));
    tabbedPane.setTitleAt(
        4, ClientSettings.getInstance().getResources().getResource("supplierPricelists"));
    itemsSplitPane.setDividerLocation(200);
  }
  private void jbInit() throws Exception {
    hierarTreePanel.setEnabled(false);
    warehousePanel.setLayout(borderLayout1);
    warehouseForm.setVOClassName("org.jallinone.warehouse.java.WarehouseVO");
    this.setTitle(ClientSettings.getInstance().getResources().getResource("warehouse detail"));
    buttonsPanel.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.LEFT);
    insertButton.setText("insertButton1");
    reloadButton.setText("reloadButton1");
    deleteButton.setText("deleteButton1");
    warehouseForm.setInsertButton(insertButton);
    warehouseForm.setCopyButton(copyButton);
    warehouseForm.setEditButton(editButton);
    warehouseForm.setReloadButton(reloadButton);
    warehouseForm.setDeleteButton(deleteButton);
    warehouseForm.setSaveButton(saveButton);
    warehouseForm.setFunctionId("WAR01");
    warehouseForm.setLayout(gridBagLayout1);
    controlZip.setAttributeName("zipWAR01");
    controlZip.setCanCopy(true);
    controlZip.setLinkLabel(labelZip);
    controlZip.setMaxCharacters(20);
    controlProv.setAttributeName("provinceWAR01");
    controlProv.setCanCopy(true);
    controlProv.setLinkLabel(labelProv);
    controlProv.setMaxCharacters(20);
    controlProv.setTrimText(true);
    controlProv.setUpperCase(true);
    controlCity.setAttributeName("cityWAR01");
    controlCity.setCanCopy(true);
    controlCity.setLinkLabel(labelCity);
    controlAddress.setAttributeName("addressWAR01");
    controlAddress.setCanCopy(true);
    controlAddress.setLinkLabel(labelAddress);
    labelAddress.setText("address");
    controlCountry.setAttributeName("countryWAR01");
    controlCountry.setCanCopy(true);
    controlCountry.setLinkLabel(labelCountry);
    controlCountry.setMaxCharacters(20);
    controlCountry.setTrimText(true);
    controlCountry.setUpperCase(true);
    labelZip.setText("zip");
    labelCity.setText("city");
    labelCountry.setText("country");
    labelProv.setText("prov");
    controlWarCode.setAttributeName("warehouseCodeWAR01");
    controlWarCode.setLinkLabel(labelWarCode);
    controlWarCode.setMaxCharacters(20);
    controlWarCode.setRequired(true);
    controlWarCode.setRpadding(false);
    controlWarCode.setTrimText(true);
    controlWarCode.setUpperCase(true);
    controlWarCode.setEnabledOnEdit(false);
    labelWarCode.setText("warehouseCodeWAR01");
    labelDescr.setText("descriptionWAR01");
    controlDescr.setAttributeName("descriptionWAR01");
    controlDescr.setLinkLabel(labelDescr);
    controlDescr.setRequired(true);
    labelCompanyCode.setText("companyCodeSys01WAR01");
    controlCompaniesCombo.setAttributeName("companyCodeSys01WAR01");
    controlCompaniesCombo.setCanCopy(true);
    controlCompaniesCombo.setLinkLabel(labelCompanyCode);
    controlCompaniesCombo.setRequired(true);
    controlCompaniesCombo.setEnabledOnEdit(false);
    labelRoles.setText("edit/delete warehouse role");
    controlRoles.setAttributeName("progressiveSys04WAR01");
    controlRoles.setDomainId("USERROLES");
    controlRoles.setLinkLabel(labelRoles);
    locationsPanel.setLayout(borderLayout2);
    tabbedPane.add(warehousePanel, "warehousePanel");
    this.getContentPane().add(buttonsPanel, BorderLayout.NORTH);
    this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    warehouseForm.add(
        labelZip,
        new GridBagConstraints(
            3,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelCity,
        new GridBagConstraints(
            0,
            4,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelAddress,
        new GridBagConstraints(
            0,
            3,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlAddress,
        new GridBagConstraints(
            2,
            3,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlCity,
        new GridBagConstraints(
            2,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            100,
            0));
    warehouseForm.add(
        controlZip,
        new GridBagConstraints(
            4,
            4,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlWarCode,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            100,
            0));
    warehousePanel.add(warehouseForm, BorderLayout.CENTER);
    buttonsPanel.add(insertButton, null);
    buttonsPanel.add(copyButton, null);
    buttonsPanel.add(editButton, null);
    buttonsPanel.add(saveButton, null);
    buttonsPanel.add(reloadButton, null);
    buttonsPanel.add(deleteButton, null);
    buttonsPanel.add(navigatorBar, null);
    warehouseForm.add(
        labelWarCode,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelDescr,
        new GridBagConstraints(
            0,
            2,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlDescr,
        new GridBagConstraints(
            2,
            2,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlCountry,
        new GridBagConstraints(
            4,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelCountry,
        new GridBagConstraints(
            3,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelProv,
        new GridBagConstraints(
            0,
            5,
            1,
            2,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    warehouseForm.add(
        controlProv,
        new GridBagConstraints(
            2,
            5,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelCompanyCode,
        new GridBagConstraints(
            0,
            0,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    tabbedPane.add(locationsPanel, "locationsPanel");
    locationsPanel.add(split, BorderLayout.CENTER);
    split.setDividerLocation(150);
    split.add(hierarTreePanel, JSplitPane.LEFT);
    split.add(availPanel, JSplitPane.RIGHT);
    tabbedPane.add(bookedItemsPanel, "bookedItemsPanel");
    tabbedPane.add(orderedItemsPanel, "orderedItemsPanel");
    hierarTreePanel.setFunctionId("WAR01");
    tabbedPane.setTitleAt(
        0, ClientSettings.getInstance().getResources().getResource("warehouse detail"));
    tabbedPane.setTitleAt(1, ClientSettings.getInstance().getResources().getResource("positions"));
    tabbedPane.setTitleAt(
        2, ClientSettings.getInstance().getResources().getResource("bookedItemsPanel"));
    tabbedPane.setTitleAt(
        3, ClientSettings.getInstance().getResources().getResource("orderedItemsPanel"));

    warehouseForm.add(
        controlCompaniesCombo,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        controlRoles,
        new GridBagConstraints(
            2,
            6,
            1,
            2,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 5, 5),
            0,
            0));
    warehouseForm.add(
        labelRoles,
        new GridBagConstraints(
            0,
            7,
            2,
            1,
            0.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
Exemple #17
0
  private Element makeForm() {
    Composite comp = new Composite();
    Form frm = new Form(srvURL(myServletDescr()));
    frm.method("POST");

    frm.add("<br><center>");
    Input reload = new Input(Input.Submit, KEY_ACTION, ACTION_RELOAD_CONFIG);
    setTabOrder(reload);
    frm.add(reload);
    frm.add(" ");
    Input backup = new Input(Input.Submit, KEY_ACTION, ACTION_MAIL_BACKUP);
    setTabOrder(backup);
    frm.add(backup);
    frm.add(" ");
    Input crawlplug = new Input(Input.Submit, KEY_ACTION, ACTION_CRAWL_PLUGINS);
    setTabOrder(crawlplug);
    frm.add(crawlplug);
    frm.add("</center>");
    ServletDescr d1 = AdminServletManager.SERVLET_HASH_CUS;
    if (isServletRunnable(d1)) {
      frm.add("<br><center>" + srvLink(d1, d1.heading) + "</center>");
    }
    Input findUrl = new Input(Input.Submit, KEY_ACTION, ACTION_FIND_URL);
    Input findUrlText = new Input(Input.Text, KEY_URL);
    findUrlText.setSize(50);
    setTabOrder(findUrl);
    setTabOrder(findUrlText);
    frm.add("<br><center>" + findUrl + " " + findUrlText + "</center>");

    Input thrw = new Input(Input.Submit, KEY_ACTION, ACTION_THROW_IOEXCEPTION);
    Input thmsg = new Input(Input.Text, KEY_MSG);
    setTabOrder(thrw);
    setTabOrder(thmsg);
    frm.add("<br><center>" + thrw + " " + thmsg + "</center>");

    frm.add("<br><center>AU Actions: select AU</center>");
    Composite ausel = ServletUtil.layoutSelectAu(this, KEY_AUID, formAuid);
    frm.add("<br><center>" + ausel + "</center>");
    setTabOrder(ausel);

    Input v3Poll =
        new Input(
            Input.Submit,
            KEY_ACTION,
            (showForcePoll ? ACTION_FORCE_START_V3_POLL : ACTION_START_V3_POLL));
    Input crawl =
        new Input(
            Input.Submit,
            KEY_ACTION,
            (showForceCrawl ? ACTION_FORCE_START_CRAWL : ACTION_START_CRAWL));

    frm.add("<br><center>");
    frm.add(v3Poll);
    frm.add(" ");
    frm.add(crawl);
    if (CurrentConfig.getBooleanParam(PARAM_ENABLE_DEEP_CRAWL, DEFAULT_ENABLE_DEEP_CRAWL)) {
      Input deepCrawl =
          new Input(
              Input.Submit,
              KEY_ACTION,
              (showForceCrawl ? ACTION_FORCE_START_DEEP_CRAWL : ACTION_START_DEEP_CRAWL));
      Input depthText = new Input(Input.Text, KEY_REFETCH_DEPTH, formDepth);
      depthText.setSize(4);
      setTabOrder(depthText);
      frm.add(" ");
      frm.add(deepCrawl);
      frm.add(depthText);
    }
    Input checkSubstance = new Input(Input.Submit, KEY_ACTION, ACTION_CHECK_SUBSTANCE);
    frm.add("<br>");
    frm.add(checkSubstance);
    if (metadataMgr != null) {
      Input reindex =
          new Input(
              Input.Submit,
              KEY_ACTION,
              (showForceReindexMetadata ? ACTION_FORCE_REINDEX_METADATA : ACTION_REINDEX_METADATA));
      frm.add(" ");
      frm.add(reindex);
      Input disableIndexing = new Input(Input.Submit, KEY_ACTION, ACTION_DISABLE_METADATA_INDEXING);
      frm.add(" ");
      frm.add(disableIndexing);
    }
    frm.add("</center>");

    comp.add(frm);
    return comp;
  }
Exemple #18
0
 private void createActiveInput(Form<T> form) {
   CheckBox activeCheckbox = new CheckBox("user.active");
   activeCheckbox.setMarkupId("active");
   form.add(activeCheckbox);
 }
  private JPanel createForm() {
    JCheckBox enabledCheckBox = new JCheckBox(Finder.getString("vhost.ssl.edit.enable"));

    new CheckBoxPropertySynchronizer(enabledProperty, enabledCheckBox);
    ChangeIndicator enabledChange = new ChangeIndicator();
    enabledProperty.addChangeListener(enabledChange);

    JLabel iPLabel = new JLabel(Finder.getString("vhost.ssl.edit.ip"));
    JTextField iPField = GUIUtil.createTextField();
    new TextComponentPropertySynchronizer<String, JTextComponent>(ipProperty, iPField);
    ChangeIndicator iPChange = new ChangeIndicator();
    ipProperty.addChangeListener(iPChange);

    JLabel portLabel = new JLabel(Finder.getString("vhost.ssl.edit.port"));

    SpinnerNumberModel portModel = new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1);
    JSpinner portSpinner = new JSpinner(portModel);

    JComponent editor = portSpinner.getEditor();
    if (editor instanceof JSpinner.DefaultEditor) {
      JTextField field = ((JSpinner.DefaultEditor) editor).getTextField();
      field.setColumns(5);
      field.setHorizontalAlignment(JTextField.RIGHT);
    }

    new SpinnerNumberModelPropertySynchronizer(portProperty, portModel, false);
    portProperty.save();

    ChangeIndicator portChange = new ChangeIndicator();
    portProperty.addChangeListener(portChange);

    JLabel certLabel = new JLabel(Finder.getString("vhost.ssl.edit.certificate"));

    BrowsableFilePanel certPanel = new BrowsableFilePanel();
    certPanel.setOpaque(false);
    fileChoosers.add(certPanel.getFileChooser());

    new TextComponentPropertySynchronizer<String, JTextComponent>(
        certProperty, certPanel.getField());
    ChangeIndicator certChange = new ChangeIndicator();
    certProperty.addChangeListener(certChange);

    JLabel keyLabel = new JLabel(Finder.getString("vhost.ssl.edit.key"));

    BrowsableFilePanel keyPanel = new BrowsableFilePanel();
    keyPanel.setOpaque(false);
    fileChoosers.add(keyPanel.getFileChooser());

    new TextComponentPropertySynchronizer<String, JTextComponent>(keyProperty, keyPanel.getField());
    ChangeIndicator keyChange = new ChangeIndicator();
    keyProperty.addChangeListener(keyChange);

    JPanel formPanel = new JPanel();
    formPanel.setOpaque(false);

    Form form = new Form(formPanel, VerticalAnchor.TOP);

    int hGap = GUIUtil.getHalfGap();
    int sGap = 3 * hGap;
    int indent = GUIUtil.getTextXOffset(enabledCheckBox);

    ColumnLayoutConstraint c = new ColumnLayoutConstraint(HorizontalAnchor.FILL, hGap);

    RowLayoutConstraint r = new RowLayoutConstraint(VerticalAnchor.CENTER, hGap);

    HasAnchors a = new SimpleHasAnchors(HorizontalAnchor.LEFT, VerticalAnchor.CENTER);

    form.addRow(HorizontalAnchor.LEFT, c);
    form.add(enabledCheckBox, r);
    form.add(enabledChange, r);

    form.addTable(2, hGap, hGap, HorizontalAnchor.LEFT, c.setGap(sGap));
    form.add(iPLabel, a);
    form.add(getRow(hGap, iPField, iPChange), a);
    form.add(portLabel, a);
    form.add(getRow(hGap, portSpinner, portChange), a);
    form.add(certLabel, a);
    form.add(getRow(hGap, certPanel, certChange), a);
    form.add(keyLabel, a);
    form.add(getRow(hGap, keyPanel, keyChange), a);

    return formPanel;
  }
Exemple #20
0
  public OldNewReleasePage(PageParameters pp, String info) {
    super(pp, info);

    setActiveMenu(Menu.RELEASES);
    add(new FeedbackPanel("feedbackMessage"));

    Form newReleaseForm =
        new Form("form-newrelease", new CompoundPropertyModel(newRelease)) {
          @Override
          protected void onSubmit() {
            System.out.println("Submit: " + newRelease);
            PVTDataAccessObject dao = PVTApplication.getDAO();
            dao.getPvtModel().addRelease(newRelease);
            dao.persist();

            setResponsePage(new ReleasesPage(pp, "Release: " + newRelease.getName() + " Created."));
          }
        };

    List<String> productNames = new ArrayList<>();
    for (Product p : PVTApplication.getDAO().getPvtModel().getProducts()) {
      productNames.add(p.getName());
    }

    DropDownChoice<String> productDropDownChoice =
        new DropDownChoice<String>(
            "productName",
            Model.ofList(productNames),
            new ChoiceRenderer<String>("toString", "toString") {}) {
          @Override
          public boolean isNullValid() {
            return true;
          }
        };
    productDropDownChoice.setRequired(true);
    newReleaseForm.add(productDropDownChoice);

    TextField<String> nameTextField = new TextField<String>("name");
    nameTextField.setRequired(true);

    newReleaseForm.add(nameTextField);
    newReleaseForm.add(new TextArea<String>("distributions"));
    newReleaseForm.add(new TextArea<String>("description"));
    newReleaseForm.add(
        new CheckBoxMultipleChoice<String>(
            "jobs",
            Model.ofList(
                Arrays.asList("ZipDiff", "Version convention", "JDK version compatible"))));

    newReleaseForm.add(
        new IFormValidator() {
          public FormComponent<?>[] getDependentFormComponents() {
            return new FormComponent[] {nameTextField, productDropDownChoice};
          }

          public void validate(Form<?> form) {
            PVTDataAccessObject dao = PVTApplication.getDAO();
            boolean existed = false;
            for (Release rel : dao.getPvtModel().getReleases()) {
              if (rel.getName().equalsIgnoreCase(nameTextField.getInput())
                  && rel.getProductId().equalsIgnoreCase(productDropDownChoice.getInput())) {
                existed = true;
                break;
              }
            }
            if (existed) {
              ValidationError error = new ValidationError();
              error.setMessage(
                  "The Release "
                      + productDropDownChoice.getInput()
                      + "-"
                      + nameTextField.getInput()
                      + " is already existed");
              nameTextField.error(error);
            }
          }
        });

    add(newReleaseForm);
  }