Exemplo n.º 1
0
  private final ContentPanel createPropertiesContent() {
    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    panel.setButtonAlign(HorizontalAlignment.RIGHT);
    panel.setStyleAttribute("padding", "20");

    KeyListener keyListener =
        new KeyListener() {
          public void componentKeyUp(ComponentEvent event) {
            editor.markDirty();
          }
        };

    name = new TextField<String>();
    name.setFieldLabel(constants.name());
    name.setEmptyText(constants.groupName());
    name.setAllowBlank(false);
    name.setMinLength(2);
    name.addKeyListener(keyListener);
    name.setStyleAttribute("marginTop", "5");
    name.setStyleAttribute("marginBottom", "5");
    panel.add(name);

    description = new TextArea();
    description.setPreventScrollbars(true);
    description.setFieldLabel(constants.description());
    description.addKeyListener(keyListener);
    description.setStyleAttribute("marginTop", "5");
    description.setStyleAttribute("marginBottom", "5");
    panel.add(description);

    return panel;
  }
Exemplo n.º 2
0
  private void setReadonlyFields(boolean enable) {

    // Name
    userName.setReadOnly(enable);
    firstName.setReadOnly(enable);
    lastName.setReadOnly(enable);

    password.setAllowBlank(enable);
    password.setReadOnly(enable);
    passwordNew.setReadOnly(enable);
    passwordConfirm.setReadOnly(enable);
    passwordHint.setReadOnly(enable);

    // Address
    address.setReadOnly(enable);
    city.setReadOnly(enable);
    zip.setReadOnly(enable);
    state.setEditable(!enable);
    state.getListView().disableEvents(enable);
    country.setEditable(!enable);
    country.getListView().disableEvents(enable);

    // Phone
    phoneNumber.setReadOnly(enable);

    // Other
    email.setReadOnly(enable);
    emailConfirm.setReadOnly(enable);
    webSite.setReadOnly(enable);
  }
Exemplo n.º 3
0
  private TextField<String> getJobnameTextField() {
    if (jobnameTextField == null) {
      jobnameTextField = new TextField<String>();
      jobnameTextField.setAllowBlank(false);
      jobnameTextField.setWidth("100");
      jobnameTextField.setFieldLabel("Jobname");
      jobnameTextField.setValidator(
          new Validator() {

            public String validate(Field<?> field, String value) {

              if (field == jobnameTextField) {

                if (value.indexOf(" ") >= 0) {
                  return "Jobname contains whitespace";
                }

                if (UserEnvironment.getInstance().getAllJobnames().contains(value)) {
                  return "Jobname already exists.";
                }
              }
              return null;
            }
          });
      jobnameTextField.addListener(
          Events.KeyUp,
          new Listener<BaseEvent>() {

            public void handleEvent(BaseEvent be) {
              userTypedInTextField = true;
            }
          });
    }
    return jobnameTextField;
  }
  public LatestVirtualReportItemsPanel() {
    setHeading("Virtual Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Virtual ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Virtual ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            String virtualId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "virtual",
                virtualId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    getVirtualStore().removeAll();
                    if (result.size() > 0) virtualStore.add(result);
                  }
                });
          }
        });

    virtualStore = new GroupingStore<MonitoringResource>();
    virtualStore.groupBy("resource_type");
    cm = new ColumnModel(OptimisResource.getColumnConfig());
    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(true);
    view.setForceFit(true);
    view.setGroupRenderer(
        new GridGroupRenderer() {
          public String render(GroupColumnData data) {
            String f = cm.getColumnById(data.field).getHeader();
            String l = data.models.size() == 1 ? "Item" : "Items";
            return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
          }
        });

    virtualGrid = new Grid<MonitoringResource>(virtualStore, cm);
    virtualGrid.setTitle(" Service Resources ");
    virtualGrid.setView(view);
    virtualGrid.setBorders(true);
    virtualGrid.getView().setForceFit(true);
    add(virtualGrid);
  }
  public LatestPhysicalReportItemsPanel() {
    setHeading("Physical Level Monitoring");
    setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    ToolBar toolBarBottom = new ToolBar();
    Button reflesh = new Button("Refresh");
    reflesh.setIcon(IconHelper.createStyle("icon-email-add"));
    id = new TextField<String>();
    id.setFieldLabel("Physical ID");
    id.setAllowBlank(false);
    toolBar.add(new LabelToolItem("Physical ID: "));
    toolBar.add(id);
    toolBar.add(reflesh);
    setTopComponent(toolBar);
    lt = new LabelField("");
    setToolBar4Status("");
    toolBarBottom.add(lt);
    setBottomComponent(toolBarBottom);
    reflesh.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            setToolBar4Status("Loading data, please wait...");
            String physicalId = id.getValue();
            service = (MonitoringManagerWebServiceAsync) Registry.get("guiservice");
            service.getMonitoringResources(
                "physical",
                physicalId,
                new AsyncCallback<List<MonitoringResource>>() {
                  public void onFailure(Throwable caught) {
                    setToolBar4Status("Connection failed by loading data, please try again.");
                    Dispatcher.forwardEvent(MainEvents.Error, caught);
                  }

                  public void onSuccess(List<MonitoringResource> result) {
                    setToolBar4Status("");
                    getStore().removeAll();
                    if (result.size() > 0) {
                      store.add(result);
                    } else {
                      setToolBar4ErrorStatus("No data found.");
                    }
                  }
                });
          }
        });

    cm = new ColumnModel(OptimisResource.getColumnConfig());
    store = new ListStore<MonitoringResource>();
    grid = new Grid<MonitoringResource>(store, cm);
    grid.setTitle(" Physical Level Resources ");
    grid.setBorders(true);
    grid.getView().setForceFit(true);
    add(grid);
    setLayout(new FitLayout());
  }
Exemplo n.º 6
0
 /**
  * Instantiates a new prompt top dialog.
  *
  * @param builder the builder
  */
 protected PromptTopDialog(final Builder builder) {
   super(builder);
   promptLabel = new Label();
   promptLabel.addStyleName("kune-Margin-Medium-b");
   if (builder.promptLines > 1) {
     textField = new TextArea();
     textField.setHeight(20 * builder.promptLines);
   } else {
     textField = new TextField<String>();
   }
   if (TextUtils.notEmpty(builder.textFieldStyle)) {
     textField.addStyleName(builder.textFieldStyle);
   }
   textField.setRegex(builder.regex);
   textField.getMessages().setRegexText(builder.regexText);
   textField.getMessages().setMinLengthText(builder.minLengthText);
   textField.getMessages().setMaxLengthText(builder.maxLengthText);
   textField.setTabIndex(1);
   textField.setId(builder.textboxId);
   if (TextUtils.notEmpty(builder.emptyText)) {
     textField.setEmptyText(builder.emptyText);
   }
   if (builder.textFieldWidth != 0) {
     textField.setWidth(builder.textFieldWidth);
   }
   if (builder.minLength != 0) {
     textField.setMinLength(builder.minLength);
   }
   if (builder.maxLength != 0) {
     textField.setMaxLength(builder.maxLength);
   }
   if (builder.promptWidth != 0) {
     textField.setWidth(builder.promptWidth);
   }
   textField.setAllowBlank(builder.allowBlank);
   textField.addListener(
       Events.OnKeyPress,
       new Listener<FieldEvent>() {
         @Override
         public void handleEvent(final FieldEvent fe) {
           if (fe.getEvent().getKeyCode() == 13) {
             builder.onEnter.onEnter();
           }
         }
       });
   if (TextUtils.notEmpty(builder.promptText)) {
     promptLabel.setText(builder.promptText);
   }
   super.getInnerPanel().add(promptLabel);
   super.getInnerPanel().add(textField);
 }
Exemplo n.º 7
0
  public void addOtherComponent() {
    fieldSet = new FieldSet();
    fieldSet.setHeading("Additional Information");
    fieldSet.setCheckboxToggle(true);

    FormLayout layout = new FormLayout();
    layout.setLabelWidth(150);
    layout.setPadding(10);
    fieldSet.setLayout(layout);

    passAdministrationUserRole = new TextField<String>();
    passAdministrationUserRole.setAllowBlank(false);
    passAdministrationUserRole.setFieldLabel("Password Administration");
    passAdministrationUserRole.setPassword(true);
    fieldSet.add(passAdministrationUserRole);

    repeatPassAdministrationUserRole = new TextField<String>();
    repeatPassAdministrationUserRole.setAllowBlank(false);
    repeatPassAdministrationUserRole.setFieldLabel("Repeat Password");
    repeatPassAdministrationUserRole.setPassword(true);

    repeatPassAdministrationUserRole.setValidator(
        new Validator<String, Field<String>>() {

          public String validate(Field<String> field, String value) {
            if (passAdministrationUserRole.getValue() != null) {
              if (!field.getValue().equalsIgnoreCase(passAdministrationUserRole.getValue()))
                return "Attention! The two passwords must match.";
            }
            return null;
          }
        });

    fieldSet.add(repeatPassAdministrationUserRole);

    this.formPanel.add(fieldSet);
  }
Exemplo n.º 8
0
  private final ContentPanel createPropertiesPanel() {
    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    panel.setButtonAlign(HorizontalAlignment.RIGHT);
    panel.setStyleAttribute("padding", "20");

    serverName = new TextField<String>();
    serverName.setFieldLabel("Server Name");
    serverName.setEmptyText("Please enter the server name");
    serverName.setAllowBlank(false);
    serverName.setMinLength(1);
    panel.add(serverName);

    return panel;
  }
Exemplo n.º 9
0
  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);

    tfTitle.setFieldLabel("Title");
    tfTitle.setAllowBlank(false);
    tfTitle.getMessages().setBlankText("Title is required");

    taDescription.setFieldLabel("Description");
    taDescription.setAllowBlank(false);
    taDescription.getMessages().setBlankText("Description is required");

    tfLink.setFieldLabel("Link");
    tfLink.setAllowBlank(false);
    tfLink.setRegex("^http\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)?$");
    tfLink.getMessages().setBlankText("Link is required");
    tfLink
        .getMessages()
        .setRegexText("The link field must be a URL e.g. http://www.example.com/rss.xml");

    add(tfTitle);
    add(taDescription);
    add(tfLink);
  }
Exemplo n.º 10
0
  private void createFields() {
    GroupRef groupRef = (GroupRef) groupRefBeanModel.getBean();

    nameField = new TextField<String>();
    nameField.setName("name");
    nameField.setFieldLabel("Name");
    nameField.setAllowBlank(false);
    if (groupRef.getGroup().getName() != null) {
      nameField.setValue(groupRef.getGroup().getName());
    }

    AdapterField screenField = new AdapterField(createScreenPairList(groupRef));
    screenField.setFieldLabel("Screen");
    form.add(nameField);
    form.add(screenField);
  }
Exemplo n.º 11
0
  private FormPanel setupUserLeftForm(String title, int tabIndex) {

    FormPanel formPanel = new FormPanel();
    formPanel.setTitle(title);
    formPanel.setHeaderVisible(false);
    formPanel.setBodyBorder(false);
    formPanel.setWidth(400);
    //	    formPanel.setLabelAlign(LabelAlign.TOP); // default is LEFT
    formPanel.setLabelWidth(150);

    // Name fields
    FieldSet namefieldSet = new FieldSet();
    namefieldSet.setHeading("Username");
    namefieldSet.setCollapsible(true);
    namefieldSet.setBorders(false);
    FormLayout namelayout = new FormLayout();
    namelayout.setLabelWidth(150);
    //		    namelayout.setDefaultWidth(180); // It is the real function to set the textField width.
    // Default width is 200
    namefieldSet.setLayout(namelayout);

    userName = new TextField<String>();
    userName.setFieldLabel("Username");
    userName.setAllowBlank(false);
    //              userName.setReadOnly(true);
    userName.disable();
    userName.setTabIndex(tabIndex++);

    namefieldSet.add(userName);

    // Password fields
    FieldSet passwordfieldSet = new FieldSet();
    passwordfieldSet.setHeading("Password");
    passwordfieldSet.setCollapsible(true);
    passwordfieldSet.setBorders(false);
    FormLayout passwordlayout = new FormLayout();
    passwordlayout.setLabelWidth(150);
    passwordfieldSet.setLayout(passwordlayout);

    password = new TextField<String>();
    password.setFieldLabel("Current Password");
    password.setAllowBlank(false);
    password.setPassword(true);
    password.setTabIndex(tabIndex++);

    passwordNew = new TextField<String>();
    passwordNew.setFieldLabel("New Password");
    passwordNew.setPassword(true);
    passwordNew.setTabIndex(tabIndex++);

    passwordConfirm = new TextField<String>();
    passwordConfirm.setFieldLabel("Confirm Password");
    passwordConfirm.setPassword(true);
    passwordConfirm.setTabIndex(tabIndex++);

    passwordHint = new TextField<String>();
    passwordHint.setFieldLabel("Password Hint");
    passwordHint.setTabIndex(tabIndex++);

    passwordfieldSet.add(password);
    passwordfieldSet.add(passwordNew);
    passwordfieldSet.add(passwordConfirm);
    passwordfieldSet.add(passwordHint);

    FieldSet userInfofieldSet = new FieldSet();
    userInfofieldSet.setHeading("User Info");
    userInfofieldSet.setCollapsible(true);
    userInfofieldSet.setBorders(false);
    FormLayout userInfolayout = new FormLayout();
    userInfolayout.setLabelWidth(150);
    userInfofieldSet.setLayout(userInfolayout);

    firstName = new TextField<String>();
    firstName.setFieldLabel("First Name");
    firstName.setAllowBlank(false);
    // firstName.setLabelStyle("font-size:12px; margin-left: 20px");
    firstName.setTabIndex(tabIndex++);

    lastName = new TextField<String>();
    lastName.setFieldLabel("Last Name");
    lastName.setAllowBlank(false);
    lastName.setTabIndex(tabIndex++);

    userInfofieldSet.add(firstName);
    userInfofieldSet.add(lastName);

    formPanel.add(namefieldSet);
    formPanel.add(passwordfieldSet);
    formPanel.add(userInfofieldSet);

    return formPanel;
  }
Exemplo n.º 12
0
  private void createForm() {
    FormLayout layout = new FormLayout();
    layout.setLabelAlign(LabelAlign.TOP);
    fp.setLayout(layout);
    fp.setFrame(false);
    fp.setHeaderVisible(false);
    fp.setAutoWidth(true);
    fp.setBodyBorder(true);
    fp.setButtonAlign(HorizontalAlignment.CENTER);

    eMail = new TextField<String>();
    eMail.setFieldLabel("E-mail address"); // ID
    eMail.setValue("*****@*****.**");
    eMail.setAllowBlank(false);

    eMail.setRegex("^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$");
    fp.add(eMail);

    pass = new TextField<String>();
    pass.setPassword(true);
    pass.setValue("pass");
    pass.setFieldLabel("Password");
    fp.add(pass);

    fp.addButton(loginButton);
    fp.addButton(newAccountButton);

    loginButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {

            ArrayList eventData = new ArrayList();
            if (!eMail.isValid()) {
              eventData = new ArrayList();
              eventData.add("e-mail is invalid!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else if (eMail.getValue() == null) {
              eventData = new ArrayList();
              eventData.add("Please enter your e-mail address!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else if (pass.getValue() == null) {
              eventData = new ArrayList();
              eventData.add("Please enter the password!");
              Dispatcher.get().dispatch(MainEvents.login, eventData);
              return;
            } else service = (ServiceManagerWebServiceAsync) Registry.get("guiservice");

            String email = eMail.getValue();
            String password = pass.getValue();
            service.loginUser(
                email,
                password,
                new AsyncCallback<ArrayList<Object>>() {
                  public void onFailure(Throwable caught) {
                    System.out.println("loginUser: error");
                  }

                  public void onSuccess(ArrayList<Object> result) {
                    System.out.println("loginUser: success; result.get(0) = \n" + result.get(0));
                    System.out.println("loginUser: session_id = \n" + result.get(1));
                    session_id = (String) result.get(1);
                    ArrayList eventData = new ArrayList();
                    if (!result
                        .get(0)
                        .equals(
                            "User/pass are wrong! Please correct input data or register an account")) {
                      eventData.add("Please select the option");
                      eventData.add(result.get(0));
                      Dispatcher.get().dispatch(MainEvents.login, eventData);
                      fp.remove(eMail);
                      fp.remove(pass);
                      fp.clear();
                      remove(fp);
                      FormLayout layout = new FormLayout();
                      layout.setLabelAlign(LabelAlign.TOP);
                      fp = new FormPanel();
                      fp.setLayout(layout);
                      fp.setFrame(false);
                      fp.setHeaderVisible(false);
                      fp.setAutoWidth(true);
                      fp.setBodyBorder(true);
                      fp.setButtonAlign(HorizontalAlignment.CENTER);
                      fp.addText((String) result.get(0));
                      fp.addButton(logoutButton);
                      add(fp);
                    } else {
                      eventData.add("You need to log in");
                      eventData.add(result.get(0));
                      Dispatcher.get().dispatch(MainEvents.newAccount, eventData);
                    }

                    layout(true);
                  }
                });
          }
        });

    logoutButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            fp.clear();
            remove(fp);
            FormLayout layout = new FormLayout();
            layout.setLabelAlign(LabelAlign.TOP);
            fp = new FormPanel();
            fp.setLayout(layout);
            fp.setFrame(false);
            fp.setHeaderVisible(false);
            fp.setAutoWidth(true);
            fp.setBodyBorder(true);
            fp.setButtonAlign(HorizontalAlignment.CENTER);

            fp.add(eMail);
            fp.add(pass);
            fp.addButton(loginButton);
            fp.addButton(newAccountButton);
            add(fp);

            layout(true);

            ArrayList eventData = new ArrayList();
            eventData.add("You are logged out!");
            eventData.add("You are logged out, " + eMail.getValue() + "!");
            Dispatcher.get().dispatch(MainEvents.logout, eventData);

            service.logoutUser(
                session_id,
                eMail.getValue(),
                new AsyncCallback<Boolean>() {
                  public void onFailure(Throwable caught) {
                    System.out.println("logoutUser: error");
                  }

                  public void onSuccess(Boolean result) {
                    System.out.println("logoutUser: success");
                  }
                });
          }
        });

    newAccountButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            ArrayList eventData = new ArrayList();
            eventData.add("Please select the option");
            Dispatcher.get().dispatch(MainEvents.newAccount, eventData);
          }
        });

    /*
    skipButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
    	@Override
    	public void componentSelected(ButtonEvent ce) {
    		ArrayList eventData = new ArrayList();
    		eventData.add("Please select the option");
    		Dispatcher.get().dispatch(MainEvents.login, eventData);
    	}

    });
    */
    this.add(fp);
  }
Exemplo n.º 13
0
  private FormPanel createForm() {
    final FormPanel panel = new FormPanel();
    panel.setLabelWidth(100);
    panel.setHeaderVisible(false);

    TextField<String> code = new TextField<String>();
    code.setName("containerNo");
    code.setFieldLabel("集装箱号");
    code.setAllowBlank(false);
    panel.add(code);

    final ComboBox<BeanModel> size = new ComboBox<BeanModel>();
    size.setTabIndex(9);
    size.setName("size");
    size.setForceSelection(true);
    size.setEmptyText("请选择...");
    size.setDisplayField("size");
    size.setFieldLabel("尺寸");
    size.setStore(containerSizeStore);
    size.setTypeAhead(true);
    size.setTriggerAction(TriggerAction.ALL);
    size.setAllowBlank(false);
    panel.add(size);

    size.addListener(
        Events.Blur,
        new Listener<FieldEvent>() {
          @Override
          public void handleEvent(FieldEvent be) {
            formBindings.getModel().set("valentNum", size.getValue().get("valentNum"));
          }
        });

    ComboBox<BeanModel> type = new ComboBox<BeanModel>();
    type.setTabIndex(9);
    type.setName("type");
    type.setForceSelection(true);
    type.setEmptyText("请选择...");
    type.setDisplayField("code");
    type.setFieldLabel("类型");
    type.setStore(ironChestStore);
    type.setTypeAhead(true);
    type.setTriggerAction(TriggerAction.ALL);
    panel.add(type);

    ComboBox<BeanModel> bracket = new ComboBox<BeanModel>();
    bracket.setTabIndex(9);
    bracket.setName("bracket");
    bracket.setForceSelection(true);
    bracket.setEmptyText("请选择...");
    bracket.setDisplayField("code");
    bracket.setFieldLabel("车架编号");
    bracket.setStore(bracketStore);
    bracket.setTypeAhead(true);
    bracket.setTriggerAction(TriggerAction.ALL);
    panel.add(bracket);

    formBindings = new FormBinding(panel, true);

    formBindings
        .getBinding(size)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return containerSizeStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });
    formBindings
        .getBinding(type)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return ironChestStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });
    formBindings
        .getBinding(bracket)
        .setConverter(
            new Converter() {
              @Override
              public Object convertFieldValue(Object value) {
                if (value == null) {
                  return null;
                }
                return ((BeanModel) value).get("code").toString();
              }

              @Override
              public Object convertModelValue(Object value) {
                if (value != null) {
                  return bracketStore.findModel("code", (String) value);
                } else {
                  return null;
                }
              }
            });

    formBindings.setStore((Store<BeanModel>) grid.getStore());

    panel.setReadOnly(true);

    panel.setButtonAlign(HorizontalAlignment.CENTER);

    saveButton = new Button("保存");
    saveButton.setVisible(false);
    saveButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) return;
            save();
          }
        });
    panel.addButton(saveButton);

    cancelButton = new Button("取消");
    cancelButton.setVisible(false);
    cancelButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            resetState();
          }
        });
    panel.addButton(cancelButton);

    updateButton = new Button("更新");
    updateButton.disable();
    updateButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!panel.isValid()) return;
            update();
          }
        });
    panel.addButton(updateButton);

    resetButton = new Button("取消");
    resetButton.disable();
    resetButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            store.rejectChanges();
            resetState();
          }
        });
    panel.addButton(resetButton);

    panel.setBorders(false);
    panel.setBodyBorder(false);

    return panel;
  }
Exemplo n.º 14
0
  /**
   * Remember user/pass implementation <a href=
   * "http://stackoverflow.com/questions/1245174/is-it-possible-to-implement-cross-browser-username-password-autocomplete-in-gxt"
   * >based in this</a> and <a href=
   * "http://www.sencha.com/forum/showthread.php?72027-Auto-complete-login-form" >this</a>.
   */
  public SignInForm(final I18nTranslationService i18n) {
    final Listener<FieldEvent> enterListener =
        new Listener<FieldEvent>() {
          @Override
          public void handleEvent(final FieldEvent fe) {
            if (fe.getEvent().getKeyCode() == 13) {
              onAcceptCallback.onSuccess();
            }
          }
        };

    super.addStyleName("kune-Margin-Large-trbl");
    loginNickOrEmailField =
        new TextField<String>() {
          @Override
          protected void onRender(final Element target, final int index) {
            if (el() == null) {
              setElement(Document.get().getElementById("usernamerender"));
            }
            super.onRender(target, index);
          }

          @Override
          protected void setAriaState(final String stateName, final String stateValue) {}
        };
    loginNickOrEmailField.setFieldLabel(i18n.t("Username"));
    loginNickOrEmailField.setName(USER_FIELD_ID);
    loginNickOrEmailField.setWidth(DEF_SMALL_FIELD_WIDTH);
    loginNickOrEmailField.setAllowBlank(false);
    loginNickOrEmailField.setValidationDelay(3000);
    loginNickOrEmailField.setId(USER_FIELD_ID);
    loginNickOrEmailField.setTabIndex(100);
    loginNickOrEmailField.addStyleName("k-lower");
    loginNickOrEmailField.render(RootPanel.get(LOGIN_ID).getElement());
    ComponentHelper.doAttach(loginNickOrEmailField);
    super.add(loginNickOrEmailField);
    loginNickOrEmailField.addListener(Events.OnKeyPress, enterListener);

    loginPassField =
        new TextField<String>() {
          @Override
          protected void onRender(final Element target, final int index) {
            if (el() == null) {
              final String elementId = "passwordrender";
              setElement(Document.get().getElementById(elementId));
            }
            super.onRender(target, index);
          }

          @Override
          protected void setAriaState(final String stateName, final String stateValue) {}
        };
    loginPassField.setFieldLabel(i18n.t("Password"));
    loginPassField.setName(PASSWORD_FIELD_ID);
    loginPassField.setWidth(DEF_MEDIUM_FIELD_WIDTH);
    loginPassField.setPassword(true);
    loginPassField.setAllowBlank(false);
    loginPassField.setValidationDelay(3000);
    loginPassField.setId(PASSWORD_FIELD_ID);
    loginPassField.setTabIndex(101);
    loginPassField.render(RootPanel.get(LOGIN_ID).getElement());
    ComponentHelper.doAttach(loginPassField);
    loginPassField.addListener(Events.OnKeyPress, enterListener);
    super.add(loginPassField);
  }
Exemplo n.º 15
0
  /**
   * 客户资料
   *
   * @return
   */
  private LayoutContainer CreateCCodeDetailPanel() {
    LayoutContainer main = new LayoutContainer();
    TableLayout tl = new TableLayout(2);

    main.setLayout(new TableLayout(2));
    BaseFormPanel leftpanel = new BaseFormPanel(store);
    leftpanel.setLayout(new FormLayout());
    FormData fd = new FormData(200, 30);
    leftpanel.setHeaderVisible(false);
    leftpanel.setBodyBorder(false);

    BaseFormPanel rightpanel = new BaseFormPanel(store);
    rightpanel.setBodyBorder(false);
    rightpanel.setHeaderVisible(false);

    TextField<String> ccode = new TextField<String>();
    ccode.setName("ccode");
    ccode.setAllowBlank(false);
    ccode.setFieldLabel("编码");

    TextField<String> name = new TextField<String>();
    name.setName("cname");
    name.setAllowBlank(false);
    name.setFieldLabel("名称");

    TextField<String> shortcode = new TextField<String>();
    shortcode.setName("shortcode");
    shortcode.setFieldLabel("简码");
    TextField<String> ccodesource = new TextField<String>();
    ccodesource.setName("ccodesource");
    ccodesource.setFieldLabel("客户来源");

    TextField<String> ncode = new TextField<String>();
    ncode.setName("ncode");
    ncode.setFieldLabel("国别");

    TextField<String> httpurl = new TextField<String>();
    httpurl.setName("httpurl");
    httpurl.setFieldLabel("网址");

    DateField setupdate = new DateField();
    setupdate.setName("setupdate");
    setupdate.setFieldLabel("成立时间");
    TextField<String> registercapital = new TextField<String>();
    registercapital.setName("registercapital");
    registercapital.setFieldLabel("注册资金");

    TextField<String> employeenum = new TextField<String>();
    employeenum.setName("employeenum");
    employeenum.setFieldLabel("雇用人数");

    TextField<String> branchorgnum = new TextField<String>();
    branchorgnum.setName("branchorgnum");
    branchorgnum.setFieldLabel("分支机构数");

    TextField<String> artperson = new TextField<String>();
    artperson.setName("artperson");
    artperson.setFieldLabel("法人代表");

    TextField<String> taxno = new TextField<String>();
    taxno.setName("taxno");
    taxno.setFieldLabel("税务登记号");

    TextField<String> partner = new TextField<String>();
    partner.setName("partner");
    partner.setFieldLabel("合伙人");

    /*
     * TextField<String> artno = new TextField<String>();
     * artno.setName("artno"); artno.setFieldLabel("企业代码");
     */

    TextField<String> comholsdatedesc = new TextField<String>();
    comholsdatedesc.setName("comholsdatedesc");
    comholsdatedesc.setFieldLabel("公司特殊假日");

    BaseGrid gudong = CreateCCodeGudongPanel();
    gudong.setAutoHeight(true);
    gudong.setAutoWidth(true);
    leftpanel.add(ccode, fd);
    rightpanel.add(name, fd);
    leftpanel.add(shortcode, fd);
    rightpanel.add(ccodesource, fd);
    leftpanel.add(httpurl, fd);
    rightpanel.add(setupdate, fd);
    leftpanel.add(registercapital, fd);
    rightpanel.add(employeenum, fd);
    leftpanel.add(branchorgnum, fd);
    rightpanel.add(artperson, fd);
    leftpanel.add(taxno, fd);
    rightpanel.add(partner, fd);
    leftpanel.add(comholsdatedesc, fd);

    TableData td = new TableData();
    td.setColspan(1);
    td.setRowspan(1);
    // 对齐方式
    td.setHorizontalAlign(HorizontalAlignment.LEFT);
    td.setVerticalAlign(VerticalAlignment.TOP);
    // rightpanel.add(gudong,td2);
    leftpanel.inited();
    rightpanel.inited();
    FieldSet fieldSet = new FieldSet();
    fieldSet.setHeading("股东占股比例");
    fieldSet.add(gudong);
    main.add(leftpanel, td);
    main.add(rightpanel, td);
    main.add(fieldSet, td);
    return main;
  }
Exemplo n.º 16
0
  private void createNewUSerDialog() {
    setButtons("");
    setLayout(new FitLayout());
    setHeading(HarvesterUI.CONSTANTS.addUser());
    setIcon(HarvesterUI.ICONS.add16());
    setResizable(false);
    setModal(true);
    setSize(600, 200);
    setBodyBorder(false);
    FormData formData = new FormData("95%");

    newUserFormPanel = new DefaultFormPanel();
    newUserFormPanel.setHeaderVisible(false);

    newUserFormPanel.setLayout(new EditableFormLayout(175));

    userNameField = new TextField<String>();
    userNameField.setFieldLabel(HarvesterUI.CONSTANTS.username() + HarvesterUI.REQUIRED_STR);
    userNameField.setId("userNameField");
    userNameField.setMinLength(4);
    userNameField.setAllowBlank(false);
    newUserFormPanel.add(userNameField, formData);

    Validator usernameValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$"))
              return HarvesterUI.CONSTANTS.usernameValidateMessage();
            return null;
          }
        };
    userNameField.setValidator(usernameValidator);

    emailField = new TextField<String>();
    emailField.setFieldLabel(HarvesterUI.CONSTANTS.email() + HarvesterUI.REQUIRED_STR);
    emailField.setId("emailField");
    emailField.setAllowBlank(false);
    newUserFormPanel.add(emailField, formData);

    Validator emailValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"))
              return HarvesterUI.CONSTANTS.emailValidateMessage();
            return null;
          }
        };
    emailField.setValidator(emailValidator);

    roleCombo = new SimpleComboBox<String>();
    roleCombo.setEditable(false);
    roleCombo.setFieldLabel(HarvesterUI.CONSTANTS.role() + HarvesterUI.REQUIRED_STR);
    roleCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
    for (UserRole userRole : UserRole.values()) {
      if (userRole != UserRole.ANONYMOUS) roleCombo.add(userRole.name());
    }
    roleCombo.setValue(roleCombo.getStore().getAt(0));
    newUserFormPanel.add(roleCombo, formData);

    saveButton =
        new Button(
            HarvesterUI.CONSTANTS.save(),
            HarvesterUI.ICONS.save_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                AsyncCallback<User> callback =
                    new AsyncCallback<User>() {
                      public void onFailure(Throwable caught) {
                        new ServerExceptionDialog(
                                "Failed to get response from server", caught.getMessage())
                            .show();
                      }

                      public void onSuccess(User user) {
                        AsyncCallback<ResponseState> callback =
                            new AsyncCallback<ResponseState>() {
                              public void onFailure(Throwable caught) {
                                new ServerExceptionDialog(
                                        "Failed to get response from server", caught.getMessage())
                                    .show();
                              }

                              public void onSuccess(ResponseState result) {
                                unmask();
                                if (result == ResponseState.USER_ALREADY_EXISTS) {
                                  HarvesterUI.UTIL_MANAGER.getErrorBox(
                                      HarvesterUI.CONSTANTS.newUser(),
                                      HarvesterUI.CONSTANTS.usernameAlreadyExists());
                                  return;
                                }
                                hide();
                                userManagementGrid.getStore().add(newUser);
                                HarvesterUI.UTIL_MANAGER.getSaveBox(
                                    HarvesterUI.CONSTANTS.newUser(),
                                    HarvesterUI.CONSTANTS.saveNewUserSuccess());
                                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
                              }
                            };
                        mask(HarvesterUI.CONSTANTS.saveUserMask());
                        newUserFormPanel.submit();
                        String role = roleCombo.getValue().getValue().trim();
                        String userName = userNameField.getValue().trim();
                        String email = emailField.getValue().trim();
                        String password = "******";
                        newUser = new User(userName, password, role, email, 15);
                        service.saveNewUser(newUser, callback);
                      }
                    };
                String userName = userNameField.getValue();
                service.getUser(userName, callback);
              }
            });
    newUserFormPanel.addButton(saveButton);
    newUserFormPanel.addButton(
        new Button(
            HarvesterUI.CONSTANTS.cancel(),
            HarvesterUI.ICONS.cancel_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                hide();
                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
              }
            }));

    newUserFormPanel.setButtonAlign(Style.HorizontalAlignment.CENTER);

    FormButtonBinding binding = new FormButtonBinding(newUserFormPanel);
    binding.addButton(saveButton);

    add(newUserFormPanel);
  }
Exemplo n.º 17
0
  private FormPanel setupUserRightForm(String title, int tabIndex) {

    FormPanel formPanel = new FormPanel();
    formPanel.setTitle(title);
    formPanel.setHeaderVisible(false);
    formPanel.setBodyBorder(false);
    formPanel.setWidth(400);
    //	    formPanel.setLabelAlign(LabelAlign.RIGHT); // default is LEFT
    formPanel.setLabelWidth(150);

    // Address fields
    FieldSet addressfieldSet = new FieldSet();
    addressfieldSet.setHeading("Address");
    addressfieldSet.setCollapsible(true);
    addressfieldSet.setBorders(false);
    FormLayout addresslayout = new FormLayout();
    addresslayout.setLabelWidth(150);
    addressfieldSet.setLayout(addresslayout);

    address = new TextField<String>();
    address.setFieldLabel("Address");
    address.setTabIndex(tabIndex++);

    city = new TextField<String>();
    city.setFieldLabel("City");
    city.setAllowBlank(false);
    city.setTabIndex(tabIndex++);

    state = new ComboBox<State>();
    state.setFieldLabel("State");
    state.setEmptyText("Select a state...");
    state.setDisplayField("name");
    state.setWidth(150);
    state.setStore(states);
    state.setTypeAhead(true);
    state.setTriggerAction(TriggerAction.ALL);
    state.setTabIndex(tabIndex++);

    zip = new TextField<String>();
    zip.setFieldLabel("Zip Code");
    zip.setAllowBlank(false);
    zip.setTabIndex(tabIndex++);

    country = new ComboBox<Country>();
    country.setFieldLabel("Country");
    country.setEmptyText("Select a country...");
    country.setDisplayField("name");
    country.setTemplate(InputFormat.getFlagTemplate());
    country.setWidth(100);
    country.setStore(countries);
    country.setTypeAhead(true);
    country.setTriggerAction(TriggerAction.ALL);
    country.setTabIndex(tabIndex++);

    addressfieldSet.add(address);
    addressfieldSet.add(city);
    addressfieldSet.add(state);
    addressfieldSet.add(zip);
    addressfieldSet.add(country);

    FieldSet otherfieldSet = new FieldSet();
    otherfieldSet.setHeading("Other");
    otherfieldSet.setCollapsible(true);
    otherfieldSet.setBorders(false);
    FormLayout otherlayout = new FormLayout();
    otherlayout.setLabelWidth(150);
    otherfieldSet.setLayout(otherlayout);

    phoneNumber = new TextField<String>();
    phoneNumber.setFieldLabel("Phone Number");
    phoneNumber.setToolTip("xxx-xxxx");
    phoneNumber.setTabIndex(tabIndex++);

    email = new TextField<String>();
    email.setFieldLabel("Email");
    email.setAllowBlank(false);
    email.setRegex(InputFormat.EMAIL_FORMATS);
    email.getMessages().setRegexText("Invalid email format");
    //		    email.setAutoValidate(true);
    email.setToolTip("*****@*****.**");
    email.setTabIndex(tabIndex++);

    emailConfirm = new TextField<String>();
    emailConfirm.setFieldLabel("Confirm Email");
    emailConfirm.setRegex(InputFormat.EMAIL_FORMATS);
    emailConfirm.getMessages().setRegexText("Invalid email format");
    //		    email.setAutoValidate(true);
    emailConfirm.setToolTip("*****@*****.**");
    emailConfirm.setTabIndex(tabIndex++);

    webSite = new TextField<String>();
    webSite.setFieldLabel("Website");
    webSite.setTabIndex(tabIndex++);

    otherfieldSet.add(phoneNumber);
    otherfieldSet.add(email);
    otherfieldSet.add(emailConfirm);
    otherfieldSet.add(webSite);

    formPanel.add(addressfieldSet);
    formPanel.add(otherfieldSet);

    return formPanel;
  }
Exemplo n.º 18
0
  /** * 主窗口 */
  void initmainpanel() {

    w = new BaseFormPanel(getStore());
    w.setHeaderVisible(false);
    Label cardno_l = new Label("卡号:");
    cardno_l.setWidth("50");
    Label cname_l = new Label("名字:");
    cname_l.setWidth("50");
    Label sex_l = new Label("性别:");
    sex_l.setWidth("50");
    Label edu_l = new Label("学历:");
    Label bird_l = new Label("出生日期:");

    Label mobil_l = new Label("手机号:");
    Label idno_l = new Label("身份证号:");
    Label mark_l = new Label("备注:");

    cardno_t = new TextField<String>();
    cardno_t.setAllowBlank(false);
    cardno_t.addListener(Events.Change, this);
    cname_t = new TextField<String>();
    cname_t.setAllowBlank(false);

    //		passwordc_t.setAllowBlank(false);
    //		password_t.setAllowBlank(false);
    //
    // TextField<String> sex_t = new TextField<String>();
    // BaseGridEditor sex_t= CodeNameMapFactory.aa();
    BaseComboBoxForm<BaseModelData> sex_t = CodeNameMapFactory.createSexInput_F();
    TextField<String> edu_t = new TextField<String>();
    // CodeNameMapFactory codenamemap = new CodeNameMapFactory();

    // BaseGridEditor<String> edu_t =codenamemap.createSexInput_G();

    // createBocdeInput_F
    DateField bird_t = new DateField();
    bird_t.setAutoWidth(true);

    bird_t.getPropertyEditor().setFormat(DateTimeFormat.getFormat("yyyy-M-d H:mm:ss"));
    TextField<String> mobil_t = new TextField<String>();
    mobil_t.setAllowBlank(false);
    TextField<String> idno_t = new TextField<String>();

    TextArea mark_t = new TextArea();
    mark_t.setSize(420, 40);
    // TextField<String> password_t = new TextField<String>();

    password_t.setPassword(true);
    passwordc_t.setPassword(true);
    // password_t.setToolTip("将光标放到此处,并由会员录入自己的密码");
    ccode_t = new TextField<String>();
    // ccode_t.setEnabled(false);
    ccode_t.setVisible(false);
    icode_t = new TextField<String>();
    icode_t.setVisible(false);

    cardno_t.setName("s_cardno");
    cname_t.setName("cname");
    password_t.setName("password");

    sex_t.setName("s_sex");
    edu_t.setName("s_edu");
    bird_t.setName("s_birid");
    mobil_t.setName("s_mobil");
    idno_t.setName("s_idno");
    mark_t.setName("s_mark");
    ccode_t.setName("ccode");
    icode_t.setName("icode");
    // password_t.setName("password");

    TableLayout tl = new TableLayout(4);
    tl.setWidth("600");
    w.setLayout(tl);
    TableData td = new TableData();
    td.setColspan(1);
    // td.setWidth("2000");
    td.setMargin(100);
    td.setPadding(5);
    td.setRowspan(1);

    TableData td2 = new TableData();
    td2.setColspan(3);
    // td.setWidth("2000");
    td2.setMargin(100);
    td2.setPadding(5);
    td2.setRowspan(1);

    w.add(cardno_l, td);
    w.add(cardno_t, td);
    w.add(cname_l, td);
    w.add(cname_t, td);

    w.add(mobil_l, td);
    w.add(mobil_t, td);
    w.add(sex_l, td);
    w.add(sex_t, td);

    w.add(new Label("密码:"), td);
    w.add(password_t, td);
    w.add(new Label("重新录入密码:"), td);
    w.add(passwordc_t, td);

    w.add(edu_l, td);
    w.add(edu_t, td);
    w.add(bird_l, td);
    w.add(bird_t, td);

    w.add(idno_l, td);
    w.add(idno_t, td);
    w.add(new Label(""), td);
    w.add(new Label(""), td);
    w.add(mark_l, td);
    w.add(mark_t, td2);

    w.add(new Label("销售人员:"), td);
    BaseComboBoxForm<BaseModelData> cbf = createBcode_filter();
    cbf.setName("rbcode");
    cbf.setAllowBlank(false);
    w.add(cbf, td2);

    w.add(ccode_t, td);
    w.add(icode_t, td);
    w.setBottomComponent(addfinace);

    addfinace.addListener(Events.Select, this);
    addfinace.setEnabled(false);
    w.inited();

    // w.setAutoHeight(true);
    // w.setAutoWidth(true);
    // w.setSize(661, 300);

    cardno_t.addListener(Events.Change, this);
    cname_t.addListener(Events.Change, this);

    // mobil_t.addListener(Events.Change, this);

    cardno_t.setValidateOnBlur(true);
    cname_t.setValidateOnBlur(true);
  }
  @Override
  protected void onRender(Element parent, int index) {

    super.onRender(parent, index);

    setLayout(new CenterLayout());

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    configs.add(sm.getColumn());

    ColumnConfig column = new ColumnConfig();
    column.setId("ragioneSociale");
    column.setHeader("Ragione Sociale");
    column.setWidth(120);

    TextField<String> text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cognome");
    column.setHeader("Cognome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("nome");
    column.setHeader("Nome");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("cf");
    column.setHeader("Codice Fiscale");
    column.setWidth(120);

    text = new TextField<String>();
    // text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("piva");
    column.setHeader("Partita IVA");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    column = new ColumnConfig();
    column.setId("denominazione");
    column.setHeader("Denominazione");
    column.setWidth(120);

    text = new TextField<String>();
    text.setAllowBlank(false);
    column.setEditor(new CellEditor(text));
    configs.add(column);

    caricaDati();

    ColumnModel cm = new ColumnModel(configs);

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Anagrafica aziende");
    cp.setFrame(true);
    // cp.setIcon(Resources.ICONS.table());
    cp.setSize(Consts.LarghezzaFinestra, Consts.AltezzaFinestra);
    cp.setLayout(new FitLayout());

    final EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm);
    grid.setSelectionModel(sm);
    grid.setAutoExpandColumn("nome");
    grid.setBorders(true);
    grid.setClicksToEdit(EditorGrid.ClicksToEdit.TWO);
    cp.add(grid);

    ToolBar toolBar = new ToolBar();
    Button addButton = new Button("Aggiungi azienda");
    addButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/add2.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    addButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            BeanModelFactory factory = BeanModelLookup.get().getFactory(Azienda.class);
            Azienda azienda =
                new Azienda(
                    "NuovoNome",
                    "NuovoCognome",
                    "nuovaRS",
                    "nuovoCF",
                    "nuovaPIVA",
                    "NuovaDenominazione");
            BeanModel model = factory.createModel(azienda);

            grid.stopEditing();
            aziende.add(azienda);
            store.insert(model, 0);
            grid.startEditing(store.indexOf(model), 0);
          }
        });
    toolBar.add(addButton);
    toolBar.add(new SeparatorToolItem());

    Button remove = new Button("Rimuovi selezionati");
    remove.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/delete2.png",
            Consts.ICON_WIDTH_SMALL,
            Consts.ICON_HEIGHT_SMALL));
    remove.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            if (!(sm.getSelectedItems()).isEmpty()) {
              MessageBox.confirm(
                  "Confirm",
                  "Sei sicuro di voler eliminare gli elemtni selezionati?",
                  cancellazione);
            } else {
              MessageBox.alert("Errore", "Selezionare uno o più elementi", cancellazione);
            }
          }
          // conferma per l'eliminazione
          final Listener<MessageBoxEvent> cancellazione =
              new Listener<MessageBoxEvent>() {

                @Override
                public void handleEvent(MessageBoxEvent ce) {
                  Button btn = ce.getButtonClicked();
                  if (btn.getText().equals("Yes")) {
                    List<BeanModel> modelsDaRimuovere = sm.getSelectedItems();
                    ArrayList<Azienda> aziendeDaRimuovere = new ArrayList();
                    if (modelsDaRimuovere != null) {
                      Iterator it = modelsDaRimuovere.iterator();
                      while (it.hasNext()) {
                        Object model = it.next();
                        store.remove((BeanModel) model);
                        Azienda azienda = ((BeanModel) model).getBean();
                        aziendeDaRimuovere.add(azienda);
                        aziende.remove(azienda);
                      }
                      cancellaDati(aziendeDaRimuovere);
                    }
                  }
                }
              };
        });
    toolBar.add(remove);
    cp.setTopComponent(toolBar);

    ToolBar statusBar = new ToolBar();
    status.setWidth(350);
    statusBar.add(status);
    cp.setBottomComponent(statusBar);
    cp.setButtonAlign(HorizontalAlignment.CENTER);

    Button resetButton =
        new Button(
            "Reset",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.rejectChanges();
              }
            });
    resetButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/undo.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(resetButton);

    Button saveButton =
        new Button(
            "Save",
            new SelectionListener<ButtonEvent>() {

              @Override
              public void componentSelected(ButtonEvent ce) {
                store.commitChanges();
                salvaDati(aziende);
              }
            });
    saveButton.setIcon(
        IconHelper.create(
            "/resources/grafica/x16/save.png", Consts.ICON_WIDTH_SMALL, Consts.ICON_HEIGHT_SMALL));
    cp.addButton(saveButton);

    add(cp);
  }
Exemplo n.º 20
0
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("network-dhcp-nat");
    FormData formData = new FormData();
    formData.setWidth(250);

    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setLayout(new FlowLayout());
    m_formPanel.setStyleAttribute("min-width", "775px");
    m_formPanel.setStyleAttribute("padding-left", "30px");

    FieldSet fieldSet = new FieldSet();
    FormLayout layoutAccount = new FormLayout();
    layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    fieldSet.setLayout(layoutAccount);
    fieldSet.setBorders(false);

    //
    // Tool Tip Box
    //
    toolTipField.setText(defaultToolTip);
    fieldSet.add(toolTipField);

    //
    // Router Mode
    //
    m_modeCombo = new SimpleComboBox<String>();
    m_modeCombo.setName("comboMode");
    m_modeCombo.setFieldLabel(MSGS.netRouterMode());
    m_modeCombo.setEditable(false);
    m_modeCombo.setTypeAhead(true);
    m_modeCombo.setTriggerAction(TriggerAction.ALL);
    for (GwtNetRouterMode mode : GwtNetRouterMode.values()) {
      m_modeCombo.add(MessageUtils.get(mode.name()));
    }
    m_modeCombo.setSimpleValue(MessageUtils.get(GwtNetRouterMode.netRouterDchpNat.name()));
    m_modeCombo.setValidator(
        new Validator() {
          public String validate(Field<?> field, String value) {
            if (m_tcpIpConfigTab.isDhcp()
                && !value.equals(MessageUtils.get(GwtNetRouterMode.netRouterOff.toString()))) {
              return MSGS.netRouterConfiguredForDhcpError();
            }

            return null;
          }
        });
    m_modeCombo.addSelectionChangedListener(
        new SelectionChangedListener<SimpleComboValue<String>>() {
          @Override
          public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
            refreshForm();
          }
        });
    m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipMode()));
    m_modeCombo.addStyleName("kura-combobox");
    m_modeCombo.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_modeCombo, formData);

    //
    // DHCP Beginning Address
    //
    m_dhcpBeginAddressField = new TextField<String>();
    m_dhcpBeginAddressField.setAllowBlank(true);
    m_dhcpBeginAddressField.setName("dhcpBeginAddress");
    m_dhcpBeginAddressField.setFieldLabel(MSGS.netRouterDhcpBeginningAddress());
    m_dhcpBeginAddressField.setRegex(IPV4_REGEX);
    m_dhcpBeginAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpBeginAddressField.addPlugin(m_dirtyPlugin);
    m_dhcpBeginAddressField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    m_dhcpBeginAddressField.addStyleName("kura-textfield");
    m_dhcpBeginAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpBeginAddr()));
    fieldSet.add(m_dhcpBeginAddressField, formData);

    //
    // DHCP Ending Address
    //
    m_dhcpEndAddressField = new TextField<String>();
    m_dhcpEndAddressField.setAllowBlank(true);
    m_dhcpEndAddressField.setName("dhcpEndAddress");
    m_dhcpEndAddressField.setFieldLabel(MSGS.netRouterDhcpEndingAddress());
    m_dhcpEndAddressField.setRegex(IPV4_REGEX);
    m_dhcpEndAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpEndAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpEndAddr()));
    m_dhcpEndAddressField.addStyleName("kura-textfield");
    ;
    m_dhcpEndAddressField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpEndAddressField, formData);

    //
    // DHCP Subnet Mask
    //
    m_dhcpSubnetMaskField = new TextField<String>();
    m_dhcpSubnetMaskField.setAllowBlank(true);
    m_dhcpSubnetMaskField.setName("dhcpSubnetMask");
    m_dhcpSubnetMaskField.setFieldLabel(MSGS.netRouterDhcpSubnetMask());
    m_dhcpSubnetMaskField.setRegex(IPV4_REGEX);
    m_dhcpSubnetMaskField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpSubnet()));
    m_dhcpSubnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpSubnetMaskField.addStyleName("kura-textfield");
    m_dhcpSubnetMaskField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpSubnetMaskField, formData);

    //
    // DHCP Default Lease
    //
    m_dhcpLeaseDefaultField = new NumberField();
    m_dhcpLeaseDefaultField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseDefaultField.setAllowDecimals(false);
    m_dhcpLeaseDefaultField.setAllowNegative(false);
    m_dhcpLeaseDefaultField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseDefaultField.setAllowBlank(true);
    m_dhcpLeaseDefaultField.setName("dhcpDefaultLease");
    m_dhcpLeaseDefaultField.setFieldLabel(MSGS.netRouterDhcpDefaultLease());
    m_dhcpLeaseDefaultField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpDefaultLeaseTime()));
    m_dhcpLeaseDefaultField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseDefaultField, formData);

    //
    // DHCP Max Lease
    //
    m_dhcpLeaseMaxField = new NumberField();
    m_dhcpLeaseMaxField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseMaxField.setAllowDecimals(false);
    m_dhcpLeaseMaxField.setAllowNegative(false);
    m_dhcpLeaseMaxField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseMaxField.setAllowBlank(true);
    m_dhcpLeaseMaxField.setName("dhcpMaxLease");
    m_dhcpLeaseMaxField.setFieldLabel(MSGS.netRouterDhcpMaxLease());
    m_dhcpLeaseMaxField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpMaxLeaseTime()));
    m_dhcpLeaseMaxField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseMaxField, formData);

    //
    // Pass DNS
    //
    m_passDnsRadioTrue = new Radio();
    m_passDnsRadioTrue.setBoxLabel(MSGS.trueLabel());
    m_passDnsRadioTrue.setItemId("true");

    m_passDnsRadioFalse = new Radio();
    m_passDnsRadioFalse.setBoxLabel(MSGS.falseLabel());
    m_passDnsRadioFalse.setItemId("false");

    m_passDnsRadioGroup = new RadioGroup();
    m_passDnsRadioGroup.setName("dhcpPassDns");
    m_passDnsRadioGroup.setFieldLabel(MSGS.netRouterPassDns());
    m_passDnsRadioGroup.add(m_passDnsRadioTrue);
    m_passDnsRadioGroup.add(m_passDnsRadioFalse);
    m_passDnsRadioGroup.addPlugin(m_dirtyPlugin);
    m_passDnsRadioGroup.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipPassDns()));
    fieldSet.add(m_passDnsRadioGroup, formData);

    m_formPanel.add(fieldSet);
    add(m_formPanel);
    setScrollMode(Scroll.AUTO);
    m_initialized = true;
  }