Example usage for com.vaadin.ui PasswordField PasswordField

List of usage examples for com.vaadin.ui PasswordField PasswordField

Introduction

In this page you can find the example usage for com.vaadin.ui PasswordField PasswordField.

Prototype

public PasswordField(ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new PasswordField with a value change listener.

Usage

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupFirstA.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public RegistrationPagePopupFirstA(ClickListener listener) {
    super(listener);
    super.initGui();

    setTitleString("We don't need much to get you started.", true); //smaller

    contentVLayout.setSpacing(true);//  w  ww .j ava 2 s .co m

    Label lab;
    contentVLayout.addComponent(lab = new Label());
    lab.setHeight("10px");

    contentVLayout.addComponent(
            lab = new Label("Game play for this session of mmowgli is restricted to invited users"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(
            lab = new Label("with a previously-registered email address or approved email domain."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout.addComponent(lab = new HtmlLabel("&nbsp;"));
    ;
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    contentVLayout
            .addComponent(lab = new Label("Please choose a player name (ID) that protects your privacy."));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    // Use an actual form widget here for data binding and error display.
    formLay = new FormLayout();
    formLay.setSizeUndefined();
    formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    contentVLayout.addComponent(formLay);
    contentVLayout.setComponentAlignment(formLay, Alignment.TOP_CENTER);

    formLay.addComponent(userIDTf = new TextField("Pick a player name (ID)"));
    userIDTf.setColumns(24);
    // userIDTf.setRequired(true);
    // userIDTf.setRequiredError("We really need an occupation.");

    formLay.addComponent(passwordTf = new PasswordField("Password *"));
    passwordTf.setColumns(24);
    // passwordTf.setRequired(true);
    // passwordTf.setRequiredError("We really need some expertise.");

    formLay.addComponent(confirmTf = new PasswordField("Confirm password *"));
    confirmTf.setColumns(24);
    // confirmTf.setRequired(true);
    // confirmTf.setRequiredError("We really need some expertise.");

    formLay.addComponent(emailTf = new TextField("Email address *"));
    emailTf.setColumns(27); // sets width
    // emailTf.setRequired(true);
    // emailTf.setRequiredError("We really need a location.");

    contentVLayout.addComponent(lab = new Label("* private information (encrypted in database)"));
    lab.addStyleName("m-dialog-text");
    lab.setWidth(null); // makes it undefined so it's not 100%
    contentVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    contentVLayout.addComponent(hl);

    hl.addComponent(lab = new Label());
    hl.setExpandRatio(lab, 1.0f);

    continueButt = new NativeButton(null);
    continueButt.setStyleName("m-continueButton");
    //NativeButton continueButt = new NativeButton();
    hl.addComponent(continueButt);
    //app.globs().mediaLocator().decorateDialogContinueButton(continueButt);
    continueButt.addClickListener(new MyContinueListener());
    continueButt.setClickShortcut(KeyCode.ENTER);

    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    // if this is a cac-based registration, initialize the tf's with the cac card.
    // then, if the cac values are require to be used, mark the tf's as read-only
    CACData cData = Mmowgli2UI.getGlobals().getCACInfo();
    if (CACManager.isCacPresent(cData)) {
        Game g = Game.getTL();
        boolean force = g.isEnforceCACdataRegistration();

        String s;
        /*if((s = CACManager.getFirstName(cData))!=null) {
          firstNameTf.setValue(s);
          firstNameTf.setReadOnly(force);
        }
        if((s = CACManager.getLastName(cData))!=null) {
          lastNameTf.setValue(s);
          lastNameTf.setReadOnly(force);
        }
        */
        if ((s = CACManager.getEmail(cData)) != null) {
            emailTf.setValue(s);
            emailTf.setReadOnly(force);
        }
    }

    userIDTf.focus(); // should do it
    FocusHack.focus(userIDTf); // this does
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.ChangePasswordDialog.java

License:Open Source License

@SuppressWarnings("serial")
public ChangePasswordDialog(PasswordPacket pkt) {
    this.packet = pkt;

    setCaption("Change Password");
    setModal(true);//from  w  ww.  j av  a2s . co  m
    setWidth("350px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldPw = new PasswordField("Current");
    //oldPw.setColumns(20);
    oldPw.setWidth("99%");
    fLay.addComponent(oldPw);
    newPw = new PasswordField("New");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);
    newPw2 = new PasswordField("New again");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);

    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldPw.getValue().toString();
            StrongPasswordEncryptor spe = new StrongPasswordEncryptor();
            if (!spe.checkPassword(oldTry, packet.original)) {
                Notification.show("Error", "Existing password incorrect", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String newStr = newPw.getValue().toString();
            if (newStr == null || newStr.length() < 6) {
                Notification.show("Error", "Enter a password of at least six characters",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String check = newPw2.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Passwords do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangePasswordDialog.this);
        }
    });
}

From source file:edu.nps.moves.mmowgliMobile.ui.SigninPopover.java

License:Open Source License

public SigninPopover() {
    setWidth("300px");
    setHeight("350px");
    setClosable(false); // else it can be closed by clicking anywhere outside it

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);/*from   www. j a va2  s .c  o m*/
    layout.setMargin(true);
    layout.addComponent(nameTF = new TextField("Player name"));
    nameTF.setWidth("100%");
    layout.addComponent(pwTF = new PasswordField("Password"));
    pwTF.setWidth("100%");

    Label lab;
    layout.addComponent(lab = new Label());
    lab.setHeight("25px");

    layout.addComponent(submitButt = new Button("Sign in", new SubmitListener()));
    submitButt.setSizeUndefined();

    layout.addComponent(errorLab = new HtmlLabel(""));
    layout.setComponentAlignment(errorLab, Alignment.TOP_CENTER);
    // Decorate with navigation view
    NavigationView content = new NavigationView(layout);
    content.setCaption("Sign in");
    setContent(content);
    // Have a close button
    /*
    Button close = new Button(null, this);
    close.setIcon(new ThemeResource("../runo/icons/64/cancel.png"));
    content.setRightComponent(close); 
    */
}

From source file:edu.nps.moves.security.PasswordResetUI.java

License:Open Source License

private void handleChangeTL(User user) {
    this.user = user;
    Game g = Game.getTL();/*from   w  ww  .  j a v  a  2s . c om*/

    String brand = g.getCurrentMove().getTitle();
    Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli");

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(true);
    hLay.setWidth("100%");
    setContent(hLay);

    GameLinks gl = GameLinks.getTL();
    String blog = gl.getBlogLink();
    Label lab;
    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    VerticalLayout vl = new VerticalLayout();
    hLay.addComponent(vl);
    vl.setWidth(bannerWidthPx);

    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    vl.addStyleName("m-greyborder");
    vl.setMargin(true);
    vl.setSpacing(true);

    vl.addComponent(lab = new HtmlLabel(""));
    lab.addStyleName("m-font-21-bold");
    lab.setSizeUndefined();
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
    StringBuilder sb = new StringBuilder();
    sb.append(thanksHdr1);
    sb.append(blog);
    sb.append(thanksHdr2);
    sb.append(brand);
    sb.append(thanksHdr3);
    lab.setValue(sb.toString());

    vl.addComponent(lab = new HtmlLabel(""));
    lab.setHeight("15px");
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    FormLayout fLay = new FormLayout();
    fLay.setSizeUndefined();
    fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    vl.addComponent(fLay);
    vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER);

    newPw = new PasswordField("New Password");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);

    newPw2 = new PasswordField("Again, please");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vl.addComponent(buttLay);
    vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER);

    NativeButton cancelButt = new NativeButton();
    cancelButt.setStyleName("m-cancelButton");
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    saveButt = new NativeButton();
    saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    saveButt.setStyleName("m-continueButton"); //m-saveChangesButton");
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    cancelButt.addClickListener(this);
    saveButt.addClickListener(this);
}

From source file:eu.hurion.hello.vaadin.shiro.application.LoginScreen.java

License:Apache License

public LoginScreen(final HerokuShiroApplication app) {
    setSizeFull();//from   www  .j  a v  a 2s . c  o  m

    final Panel loginPanel = new Panel("Login");
    loginPanel.setWidth("300px");
    final FormLayout content = new FormLayout();
    content.setSizeFull();
    user = new TextField("User");
    content.addComponent(user);
    password = new PasswordField("Password");
    content.addComponent(password);
    final Button loginButton = new Button("Log in");
    content.setHeight("150px");
    loginButton.addClickListener(new ShiroLoginListener(app));
    content.addComponent(loginButton);
    loginPanel.setContent(content);

    addComponent(loginPanel);
    setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);

    final HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    addComponent(footer);
}

From source file:fr.amapj.view.engine.popup.formpopup.AbstractFormPopup.java

License:Open Source License

protected PasswordField addPasswordTextField(String title, Object propertyId) {
    PasswordField f = new PasswordField(title);
    binder.bind(f, propertyId);/* ww w  .  j a va  2  s.  co m*/
    // 
    f.setNullRepresentation("");
    f.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    f.setWidth("80%");
    form.addComponent(f);

    return f;
}

From source file:fr.amapj.view.engine.ui.PopupSaisieNewPassword.java

License:Open Source License

protected void addFields() {
    u = new PasswordManager().findUserWithResetPassword(resetPasswordSalt);

    if (u == null) {
        addLabel("Demande invalide", ContentMode.TEXT);
        return;/*  w w  w. j a v  a2 s .c  o m*/
    }

    Date datLimit = DateUtils.addDays(fr.amapj.common.DateUtils.getDate(), -1);
    if (u.getResetPasswordDate().before(datLimit)) {
        addLabel("Votre demande est trop ancienne", ContentMode.TEXT);
        return;
    }

    // Contruction de l'item
    item.addItemProperty("pwd", new ObjectProperty<String>(""));

    // Construction des champs
    PasswordField f = new PasswordField("Nouveau mot de passe");
    binder.bind(f, "pwd");
    // f.addValidator(new BeanValidator(getClazz(), propertyId));
    f.setNullRepresentation("");
    f.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    f.setWidth("80%");
    form.addComponent(f);

    valid = true;
}

From source file:fr.amapj.view.views.compte.PopupSaisiePassword.java

License:Open Source License

protected void addFields() {
    // Contruction de l'item
    item.addItemProperty("pwd", new ObjectProperty<String>(""));

    // Construction des champs
    PasswordField f = new PasswordField("Nouveau mot de passe");
    binder.bind(f, "pwd");
    // f.addValidator(new BeanValidator(getClazz(), propertyId));
    f.setNullRepresentation("");
    f.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    f.setWidth("80%");
    form.addComponent(f);//from   w  w  w  . j  a  v  a 2 s  .c om

}

From source file:gms.demo.service.presentation.ui.MainUI.java

License:Open Source License

private void initLoginContent() {
    loginForm.setCaption("Login:");
    loginForm.setDescription("<br/>This application does not use your SSO or LDAP "
            + "passwords. So don't go giving me all your " + "login info.");

    loginForm.addField("user", new TextField("User:"));
    loginForm.addField("pass", new PasswordField("Password:"));
    loginForm.getFooter().addComponent(loginButton);
    loginButton.addListener(this);

    // a panel will make this look a little nicer
    Panel loginPanel = new Panel();
    loginPanel.addComponent(loginForm);//  w  ww.j  a  va2s. c  om
    loginPanel.setWidth(24f, Sizeable.UNITS_EM);
    loginPanel.setHeight(20f, Sizeable.UNITS_EM);

    // add the components to a root layout and center it
    loginLayout = new VerticalLayout();
    loginLayout.addComponent(loginPanel);

    // this will keep the form near the top of the page
    loginLayout.setMargin(true);
    loginLayout.setComponentAlignment(loginPanel, Alignment.TOP_CENTER);

    // this would center it on the page
    //        loginLayout.setSizeFull();
    //        loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
}

From source file:gov.va.ds4p.ds4pmobileportal.ui.LoginView.java

License:Open Source License

private Panel getLoginPanel() {
    Panel p = new Panel();
    VerticalLayout v = (VerticalLayout) p.getContent();
    v.setSpacing(true);/*from  ww w .  j a v  a2 s  .com*/
    v.setHeight("300px");
    Label sandi = new Label("");
    sandi.setIcon(new ThemeResource("onc_s_and_i_logo.png"));
    v.addComponent(sandi);

    final TextField username = new TextField("User Name:");
    final PasswordField userpass = new PasswordField("Password:");
    username.setWidth("500px");
    userpass.setWidth("500px");
    v.addComponent(username);
    v.addComponent(userpass);

    HorizontalLayout h = new HorizontalLayout();
    h.setSpacing(true);
    h.setWidth("500px");
    Button okBTN = new Button("Ok");
    Label l = new Label("");
    l.setIcon(new ThemeResource("header-logo.png"));
    h.addComponent(okBTN);
    h.addComponent(l);
    v.addComponent(h);
    okBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            userN = (String) username.getValue();
            userP = (String) userpass.getValue();
            authenticate();
            if (userProfile == null) {
                getWindow().showNotification("Login Error", "Incorrect username or password combination.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
            } else {
                AdminContext.getSessionAttributes().setUserProfile(userProfile);
                ((MyVaadinApplication) getApplication()).loginComplete();
            }
        }
    });

    okBTN.setImmediate(true);

    return p;
}