Exemplo n.º 1
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.º 2
0
  private TextField<String> getEmailTextField() {
    if (emailTextField == null) {
      emailTextField = new TextField<String>();
      emailTextField.setEnabled(false);
      emailTextField.setWidth("");
      emailTextField.setFieldLabel("Email");
      emailTextField.setValidator(
          new Validator() {
            public String validate(Field<?> field, String value) {
              if (field == emailTextField) {
                if (!emailTextField
                    .getValue()
                    .toLowerCase()
                    .matches(
                        "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])")) {
                  return "Bad E-mail Address";
                }
              }

              return null;
            }
          });
    }
    return emailTextField;
  }
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;
  }
Exemplo n.º 4
0
  private TextField<String> buildFilterField() {
    filter =
        new TextField<String>() {
          @Override
          public void onKeyUp(FieldEvent fe) {
            String val = getValue();
            if (val == null || val.isEmpty()) {
              search("");
              return;
            }

            if (fe.getKeyCode() == 13) {
              if (val.length() >= 3) {
                search(val);
              }
            }
          }
        };

    filter.setEmptyText(I18N.DISPLAY.searchToolTip());
    filter.setToolTip(I18N.DISPLAY.searchToolTip());
    filter.setId(ID_SEARCH_FLD);
    filter.setWidth(350);
    return filter;
  }
  private TextField<String> addDefinition(String definable, String definition) {
    TableData deleteColumn = new TableData();
    deleteColumn.setWidth("20px");
    deleteColumn.setVerticalAlign(VerticalAlignment.TOP);

    TableData defColumn = new TableData();
    defColumn.setWidth(defColumnWidth);
    defColumn.setVerticalAlign(VerticalAlignment.TOP);

    TableData definitionsColumn = new TableData();
    definitionsColumn.setWidth(definitionsColumnWidth);
    definitionsColumn.setVerticalAlign(VerticalAlignment.TOP);

    final TextField<String> defText = new TextField<String>();
    defText.setValue(definable);
    defText.setWidth(defColumnWidth);

    final TextArea definitionText = new TextArea();
    definitionText.setValue(definition);
    definitionText.setWidth(definitionsColumnWidth);

    fields.put(defText, definitionText);
    final Image image = new Image("images/icon-delete.png");
    image.addClickListener(
        new ClickListener() {

          public void onClick(Widget sender) {
            WindowUtils.confirmAlert(
                "Delete?",
                "Are you sure you want to delete this definition?",
                new Listener<MessageBoxEvent>() {
                  public void handleEvent(MessageBoxEvent be) {
                    if (be.getButtonClicked().getText().equalsIgnoreCase("yes")) {
                      remove(defText);
                      remove(definitionText);
                      remove(image);
                      fields.remove(defText);
                    }
                  };
                });
          }
        });

    add(image, deleteColumn);
    add(defText, defColumn);
    add(definitionText, definitionsColumn);

    return defText;
  }
Exemplo n.º 6
0
  private HorizontalPanel getSearchPanel() {
    HorizontalPanel searchBox = new HorizontalPanel();
    TextField<String> msisdnField = new TextField<String>();
    msisdnField.setFieldLabel("MSISDN");
    msisdnField.setWidth(200);
    msisdnField.setEmptyText("Enter MSISDN");
    Button searchButton = new Button("Search");
    searchBox.setShadow(true);
    searchBox.setSpacing(5);
    searchBox.add(msisdnField);
    searchBox.add(searchButton);
    searchBox.setHorizontalAlign(HorizontalAlignment.CENTER);
    searchButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {}
        });
    return searchBox;
  }
Exemplo n.º 7
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);
  }
 private TextField createConditionAttributeField() {
   conditionAttributeField.setWidth(60);
   return conditionAttributeField;
 }
Exemplo n.º 9
0
 /**
  * Sets the field width (defaults to 125).
  *
  * @param width the field width
  */
 public void setWidth(int width) {
   this.width = width;
   field.setWidth(width);
 }