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(String caption, ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new PasswordField with the given caption and a value change listener.

Usage

From source file:de.fatalix.bookery.view.admin.AppUserCard.java

License:Open Source License

private FormLayout createContent() {
    usernameField = new TextField("Username", "some.user");
    passwordField = new PasswordField("Password", "password");
    fullnameField = new TextField("Fullname", "Some User");
    eMailField = new TextField("EMail", "user@some.de");
    roles = new TextField("Roles", "user");

    FormLayout userCardContent = new FormLayout(usernameField, passwordField, fullnameField, eMailField, roles);
    userCardContent.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    userCardContent.setMargin(true);/* w w w  . j  a va  2  s  . com*/

    return userCardContent;
}

From source file:org.adho.dhconvalidator.ui.LoginPanel.java

/** Setup UI. */
private void initComponents() {

    userNameInput = new TextField(Messages.getString("LoginPanel.userName"), "");
    userNameInput.focus();/* w  w  w. j  av a2s.  com*/
    passwordInput = new PasswordField(Messages.getString("LoginPanel.password"), "");

    btLogin = new Button(Messages.getString("LoginPanel.login"));
    btLogin.setClickShortcut(KeyCode.ENTER);

    Label caption = new Label(Messages.getString("LoginPanel.title"), ContentMode.HTML);
    caption.addStyleName("login-caption");
    addCenteredComponent(caption);
    addCenteredComponent(userNameInput);
    addCenteredComponent(passwordInput);
    addCenteredComponent(btLogin);
}

From source file:org.apache.ace.webui.vaadin.LoginWindow.java

License:Apache License

/**
 * Creates a new {@link LoginWindow} instance.
 * //from  www.  j a  va 2  s .co  m
 * @param log
 *            the log service to use;
 * @param loginFunction
 *            the login callback to use.
 */
public LoginWindow(LogService log, LoginFunction loginFunction) {
    super("Apache ACE Login");

    m_log = log;
    m_loginFunction = loginFunction;

    setResizable(false);
    setClosable(false);
    setModal(true);
    setWidth("20em");

    m_additionalInfo = new Label("");
    m_additionalInfo.setImmediate(true);
    m_additionalInfo.setStyleName("alert");
    m_additionalInfo.setHeight("1.2em");
    // Ensures the information message disappears when starting typing...
    FieldEvents.TextChangeListener changeListener = new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            m_additionalInfo.setValue("");
        }
    };

    final TextField nameField = new TextField("Name", "");
    nameField.addListener(changeListener);
    nameField.setImmediate(true);
    nameField.setWidth("100%");

    final PasswordField passwordField = new PasswordField("Password", "");
    passwordField.addListener(changeListener);
    passwordField.setImmediate(true);
    passwordField.setWidth("100%");

    Button loginButton = new Button("Login");
    loginButton.setImmediate(true);
    // Allow enter to be used to login directly...
    loginButton.setClickShortcut(KeyCode.ENTER);
    // Highlight this button as the default one...
    loginButton.addStyleName(Reindeer.BUTTON_DEFAULT);

    loginButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Button button = event.getButton();
            button.setEnabled(false);

            try {
                String username = (String) nameField.getValue();
                String password = (String) passwordField.getValue();

                if (m_loginFunction.login(username, password)) {
                    m_log.log(LogService.LOG_INFO, "Apache Ace WebUI succesfull login by user: " + username);

                    closeWindow();
                } else {
                    m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username or password entered.");

                    m_additionalInfo.setValue("Invalid username or password!");

                    nameField.focus();
                    nameField.selectAll();
                }
            } finally {
                button.setEnabled(true);
            }
        }
    });

    final VerticalLayout content = (VerticalLayout) getContent();
    content.setSpacing(true);
    content.setMargin(true);
    content.setSizeFull();

    content.addComponent(nameField);
    content.addComponent(passwordField);
    content.addComponent(m_additionalInfo);
    content.addComponent(loginButton);

    content.setComponentAlignment(loginButton, Alignment.BOTTOM_CENTER);

    nameField.focus();
}

From source file:org.jumpmind.metl.ui.views.admin.UserEditPanel.java

License:Open Source License

public UserEditPanel(ApplicationContext context, User user) {
    this.context = context;
    this.user = user;

    FormLayout form = new FormLayout();
    form.setSpacing(true);//from  w ww. j a va2  s.  co m

    TextField loginField = new TextField("Login ID", StringUtils.trimToEmpty(user.getLoginId()));
    form.addComponent(loginField);
    loginField.addValueChangeListener(new LoginChangeListener());
    loginField.focus();

    TextField nameField = new TextField("Full Name", StringUtils.trimToEmpty(user.getName()));
    nameField.addValueChangeListener(new NameChangeListener());
    form.addComponent(nameField);

    PasswordField passwordField = new PasswordField("Password", NOCHANGE);
    passwordField.addValueChangeListener(new PasswordChangeListener());
    form.addComponent(passwordField);

    List<Group> groups = context.getConfigurationService().findGroups();
    groupsById = new HashMap<String, Group>();
    TwinColSelect groupSelect = new TwinColSelect();
    for (Group group : groups) {
        groupSelect.addItem(group.getId());
        groupSelect.setItemCaption(group.getId(), group.getName());
        groupsById.put(group.getId(), group);
    }
    lastGroups = new HashSet<String>();
    for (Group group : user.getGroups()) {
        lastGroups.add(group.getId());
    }
    groupSelect.setValue(lastGroups);
    groupSelect.setRows(20);
    groupSelect.setNullSelectionAllowed(true);
    groupSelect.setMultiSelect(true);
    groupSelect.setImmediate(true);
    groupSelect.setLeftColumnCaption("Available groups");
    groupSelect.setRightColumnCaption("Selected groups");
    groupSelect.addValueChangeListener(new GroupChangeListener());
    form.addComponent(groupSelect);

    addComponent(form);
    setMargin(true);
}

From source file:pl.exsio.frameset.vaadin.account.window.view.AccountWindowView.java

License:Open Source License

private Field createPasswordRepeatedField() {
    final Field passwordFieldRepeated = new PasswordField(
            t("pl.exsio.frameset.security.entity.UserImpl.plainPasswordRepeated"), "");
    passwordFieldRepeated.setPropertyDataSource(this.item.getItemProperty("plainPasswordRepeated"));
    return passwordFieldRepeated;
}

From source file:pl.exsio.frameset.vaadin.account.window.view.AccountWindowView.java

License:Open Source License

private Field createPasswordField() {
    final Field passwordField = new PasswordField(t("pl.exsio.frameset.security.entity.UserImpl.plainPassword"),
            "");//  w  w w .j  a v  a 2 s .c  o  m
    passwordField.setPropertyDataSource(this.item.getItemProperty("plainPassword"));
    return passwordField;
}

From source file:pl.exsio.frameset.vaadin.module.management.users.UsersDataTable.java

License:Open Source License

@Override
protected Layout decorateForm(TabbedForm form, EntityItem<? extends User> item, int mode) {

    form.init(this.getTabsConfig());
    form.getLayout().setWidth("400px");
    VerticalLayout formLayout = new VerticalLayout();

    FramesetFieldFactory<? extends User> ff = new FramesetFieldFactory<>(this.securityEntities.getUserClass(),
            this.getClass());
    ff.setMultiSelectType(this.securityEntities.getRoleClass(), OptionGroup.class);
    ff.setMultiSelectType(this.securityEntities.getGroupClass(), OptionGroup.class);
    form.setFormFieldFactory(ff);//from  ww  w.java 2  s . co m
    form.setItemDataSource(item, Arrays.asList(
            new String[] { "username", "firstName", "lastName", "phoneNo", "isEnabled", "groups", "roles" }));
    Field passwordField = new PasswordField(t("plainPassword"), "");
    Field passwordFieldRepeated = new PasswordField(t("plainPasswordRepeated"), "");
    passwordField.setPropertyDataSource(item.getItemProperty("plainPassword"));
    passwordFieldRepeated.setPropertyDataSource(item.getItemProperty("plainPasswordRepeated"));
    form.addField("plainPassword", passwordField);
    form.addField("plainPasswordRepeated", passwordFieldRepeated);
    form.setBuffered(true);
    form.getField("username").addValidator(new EmailValidator(t("invalid_username")));
    form.setEnabled(true);

    formLayout.addComponent(form);
    return formLayout;
}