Ejemplo 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);
 }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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;
  }