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() 

Source Link

Document

Constructs an empty PasswordField.

Usage

From source file:com.esofthead.mycollab.shell.view.SetupNewInstanceView.java

License:Open Source License

public SetupNewInstanceView() {
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    MVerticalLayout content = new MVerticalLayout().withWidth("600px");
    this.with(content);
    content.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined());
    content.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined());
    content.with(/*from   w  ww .java  2 s.c  om*/
            new ELabel(AppContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), ContentMode.HTML)
                    .withStyleName(UIConstants.META_COLOR));
    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px");
    formLayoutHelper.getLayout().setWidth("600px");
    final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0);
    final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0,
            1);
    final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(),
            "Retype Admin password", 0, 2);
    final DateFormatField dateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3);

    final DateFormatField shortDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);

    final DateFormatField longDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);

    final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent(
            new TimeZoneSelectionField(false), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0,
            6);
    timeZoneSelectionField.setValue(TimeZone.getDefault().getID());
    final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
    languageBox.setValue(Locale.US.toLanguageTag());
    content.with(formLayoutHelper.getLayout());

    Button installBtn = new Button("Setup", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String adminName = adminField.getValue();
            String password = passwordField.getValue();
            String retypePassword = retypePasswordField.getValue();
            if (!StringUtils.isValidEmail(adminName)) {
                NotificationUtil.showErrorNotification("Invalid email value");
                return;
            }

            if (!password.equals(retypePassword)) {
                NotificationUtil.showErrorNotification("Password is not match");
                return;
            }

            String dateFormat = dateFormatField.getValue();
            String shortDateFormat = shortDateFormatField.getValue();
            String longDateFormat = longDateFormatField.getValue();
            if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat)
                    || !isValidDayPattern(longDateFormat)) {
                NotificationUtil.showErrorNotification("Invalid date format");
                return;
            }
            String language = languageBox.getValue();
            String timezoneDbId = timeZoneSelectionField.getValue();
            BillingAccountMapper billingAccountMapper = AppContextUtil
                    .getSpringBean(BillingAccountMapper.class);
            BillingAccountExample ex = new BillingAccountExample();
            ex.createCriteria().andIdEqualTo(AppContext.getAccountId());
            List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex);
            BillingAccount billingAccount = billingAccounts.get(0);
            billingAccount.setDefaultlanguagetag(language);
            billingAccount.setDefaultyymmddformat(dateFormat);
            billingAccount.setDefaultmmddformat(shortDateFormat);
            billingAccount.setDefaulthumandateformat(longDateFormat);
            billingAccount.setDefaulttimezone(timezoneDbId);
            billingAccountMapper.updateByPrimaryKey(billingAccount);

            BillingAccountService billingAccountService = AppContextUtil
                    .getSpringBean(BillingAccountService.class);

            billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true,
                    true, AppContext.getAccountId());
            ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false);

        }
    });
    installBtn.addStyleName(UIConstants.BUTTON_ACTION);
    content.with(installBtn).withAlign(installBtn, Alignment.TOP_RIGHT);
}

From source file:com.esspl.datagen.common.SettingFieldFactory.java

License:Open Source License

private PasswordField createPasswordField(Object propertyId) {
    log.debug("Creating Password Field.");
    PasswordField pf = new PasswordField();
    pf.setCaption(DefaultFieldFactory.createCaptionByPropertyId(propertyId));
    return pf;//from   w ww. j a va 2  s.c  om
}

From source file:com.expressui.core.view.security.user.UserForm.java

License:Open Source License

@Override
public void init(FormFieldSet formFields) {
    formFields.setCoordinates("loginName", 1, 1);
    formFields.setCoordinates("loginPassword", 1, 2);
    formFields.setField("loginPassword", new PasswordField());
    formFields.setCoordinates("repeatLoginPassword", 2, 2);
    formFields.setField("repeatLoginPassword", new PasswordField());

    formFields.setCoordinates("accountExpired", 3, 1);
    formFields.setCoordinates("accountLocked", 3, 2);

    formFields.setCoordinates("credentialsExpired", 4, 1);
    formFields.setCoordinates("enabled", 4, 2);
}

From source file:com.expressui.sample.view.myprofile.MyProfileForm.java

License:Open Source License

@Override
public void init(FormFieldSet formFields) {

    formFields.setCoordinates("firstName", 1, 1);
    formFields.setCoordinates("lastName", 1, 2);

    formFields.setCoordinates("title", 2, 1);
    formFields.setCoordinates("companyWebsite", 2, 2);

    formFields.setCoordinates("email", 3, 1);
    formFields.setCoordinates("phone", 3, 2);
    formFields.setCoordinates("phoneType", 3, 2);

    formFields.setCoordinates("user.loginName", 4, 1);
    formFields.setCoordinates("user.loginPassword", 4, 2);
    formFields.setCoordinates("user.repeatLoginPassword", 5, 2);

    formFields.setPropertyFormatter("companyWebsite", new UrlPropertyFormatter());

    formFields.setOriginalReadOnly("user.loginName", true);

    formFields.setWidth("phoneType", 7, Sizeable.UNITS_EM);
    getFormFieldSet().setToolTipArgs("phone",
            Phone.getExampleNumber(getMainApplication().getLocale().getCountry()));

    formFields.addConversionValidator("phone", new PhoneConversionValidator());
    formFields.setPropertyFormatter("phone", new PhonePropertyFormatter());

    formFields.setField("user.loginPassword", new PasswordField());
    formFields.setField("user.repeatLoginPassword", new PasswordField());
}

From source file:com.expressui.sample.view.user.UserForm.java

License:Open Source License

@Override
public void configureFields(FormFields formFields) {
    formFields.setPosition("loginName", 1, 1);
    formFields.setPosition("loginPassword", 1, 2);
    formFields.setField("loginPassword", new PasswordField());

    formFields.setPosition("accountExpired", 2, 1);
    formFields.setPosition("accountLocked", 2, 2);
    formFields.setPosition("credentialsExpired", 3, 1);
    formFields.setPosition("enabled", 3, 2);

    addPersistListener(this, "onPersist");
}

From source file:com.jain.addon.web.bean.factory.AbstractFieldFactory.java

License:Apache License

protected PasswordField createPasswordField(JNIProperty property) {
    PasswordField pf = new PasswordField();
    pf.setCaption(getCaption(property));
    pf.setInputPrompt(getCaption(property));
    pf.setDescription(getDescription(property));
    pf.setNullRepresentation("");
    return pf;// www.  j  a  va 2 s .  c  om
}

From source file:com.jain.addon.web.bean.factory.generator.text.SecrateFieldGenerator.java

License:Apache License

public Field<?> createField(Class<?> type, JNIProperty property) {
    PasswordField field = new PasswordField();
    field.setCaption(getCaption(property));
    field.setInputPrompt(getCaption(property));
    field.setDescription(getDescription(property));
    field.setNullRepresentation("");
    return field;
}

From source file:com.jiangyifen.ec2.ui.LoginLayout.java

/**
 * ?//from  w  w w.  j  av  a  2s .  c  o  m
 * 
 * @param panelContent ????
 * @param roleType      ?
 */
private void createLoginMainComponents(VerticalLayout panelContent, RoleType roleType) {
    GridLayout gridLayout = new GridLayout(2, 5);
    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);
    panelContent.addComponent(gridLayout);
    panelContent.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER);

    // ??
    Label username_lb = new Label("&nbsp;&nbsp;&nbsp;&nbsp;??", Label.CONTENT_XHTML);
    gridLayout.addComponent(username_lb, 0, 0);
    usernameTextField = new TextField();
    usernameTextField.setWidth("170px");
    usernameTextField.setValue(username);
    gridLayout.addComponent(usernameTextField, 1, 0);

    // ?
    Label password = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?", Label.CONTENT_XHTML);
    gridLayout.addComponent(password, 0, 1);
    passwordTextField = new PasswordField();
    passwordTextField.setWidth("170px");
    gridLayout.addComponent(passwordTextField, 1, 1);

    //  ?Csr ?
    if (roleType.equals(RoleType.csr)) {
        Label extenNoLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",
                Label.CONTENT_XHTML);
        gridLayout.addComponent(extenNoLabel, 0, 2);
        extenNoField = new TextField();
        extenNoField.setWidth("170px");
        extenNoField.setValue(exten);
        gridLayout.addComponent(extenNoField, 1, 2);
    }

    // ?????
    String warningMsg = "<font color='red'>?????</font>";
    warningLabel = new Label(warningMsg, Label.CONTENT_XHTML);
    warningLabel.setVisible(false);

    gridLayout.addComponent(warningLabel, 1, 3);
    gridLayout.setComponentAlignment(warningLabel, Alignment.MIDDLE_CENTER);

    // ?
    login = new Button("  ", this);
    forget = new NativeButton("?", this);

    //???
    Map<String, String> licenseMap = LicenseManager.licenseValidate();
    String validateResult = licenseMap.get(LicenseManager.LICENSE_VALIDATE_RESULT);
    if (LicenseManager.LICENSE_VALID.equals(validateResult)) {
        SpringContextHolder.getHttpSession().removeAttribute("businessModels");
        String licensedDate = licenseMap.get(LicenseManager.LICENSE_DATE);
        try {
            Date stopDate = LicenseManager.simpleDateFormat.parse(licensedDate);
            Long times = stopDate.getTime() - new Date().getTime();
            int outdateWarnDay = (int) (times / (24 * 3600 * 1000));

            if (outdateWarnDay < 7) {
                isValid = true;
                warningLabel.setValue("<font color='red'>" + outdateWarnDay
                        + ",???</font>");
                if (outdateWarnDay < 0) {
                    warningLabel.setValue("<font color='red'>?,???</font>");
                    isValid = false;
                } else if (outdateWarnDay == 0) {
                    warningLabel.setValue(
                            "<font color='red'>?,???</font>");
                }
                warningLabel.setVisible(true);
            }
            //            //??
            //            if(roleType==RoleType.manager){
            //               login.setEnabled(true);
            //            }
            //            
        } catch (Exception e) {
            e.printStackTrace();
            login.setEnabled(false);
            forget.setEnabled(false);
        }

    } else {
        warningLabel.setVisible(true);
        warningLabel.setValue("<font color='red'>??,???</font>");
        login.setEnabled(false);
        forget.setEnabled(false);
        isValid = false;

        //chb ???
        if (roleType == RoleType.manager) {
            if (isValid == false) {
                login.setEnabled(true);
            } else {
                //normal login
            }
        }

    }

    HorizontalLayout operatorHLayout = new HorizontalLayout();
    operatorHLayout.setSpacing(true);
    operatorHLayout.addComponent(login);
    operatorHLayout.addComponent(forget);
    gridLayout.addComponent(operatorHLayout, 1, 4);
}

From source file:com.klwork.explorer.ui.user.ChangePasswordPopupWindow.java

License:Apache License

protected void initPasswordFields() {
    inputGrid = new GridLayout(2, 2);
    inputGrid.setSpacing(true);/* w  w  w.  j av  a 2 s  .c  om*/
    layout.addComponent(inputGrid);
    layout.setComponentAlignment(inputGrid, Alignment.MIDDLE_CENTER);

    Label newPasswordLabel = new Label(i18nManager.getMessage(Messages.PROFILE_NEW_PASSWORD));
    inputGrid.addComponent(newPasswordLabel);
    passwordField1 = new PasswordField();
    passwordField1.setWidth(150, UNITS_PIXELS);
    inputGrid.addComponent(passwordField1);
    passwordField1.focus();

    Label confirmPasswordLabel = new Label(i18nManager.getMessage(Messages.PROFILE_CONFIRM_PASSWORD));
    inputGrid.addComponent(confirmPasswordLabel);
    passwordField2 = new PasswordField();
    passwordField2.setWidth(150, UNITS_PIXELS);
    inputGrid.addComponent(passwordField2);
}

From source file:com.mycollab.mobile.module.user.view.LoginViewImpl.java

License:Open Source License

private void initUI() {
    MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth();
    contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image mainLogo = new Image(null,
            AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150));
    contentLayout.addComponent(mainLogo);

    CssLayout welcomeTextWrapper = new CssLayout();
    ELabel welcomeText = new ELabel(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN))
                    .withStyleName("h1");
    welcomeTextWrapper.addComponent(welcomeText);
    contentLayout.addComponent(welcomeText);

    final EmailField emailField = new EmailField();
    new Dom(emailField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL));
    emailField.setWidth("100%");
    contentLayout.addComponent(emailField);

    final PasswordField pwdField = new PasswordField();
    pwdField.setWidth("100%");
    new Dom(pwdField).setAttribute("placeholder",
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.FORM_PASSWORD));
    contentLayout.addComponent(pwdField);

    final CheckBox rememberPassword = new CheckBox(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD),
            true);/*from   w  w w.  j a  va2s. c o  m*/
    rememberPassword.setWidth("100%");
    contentLayout.addComponent(rememberPassword);

    MButton signInBtn = new MButton(
            LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN),
            clickEvent -> {
                try {
                    LoginViewImpl.this.fireEvent(new ViewEvent<>(LoginViewImpl.this, new UserEvent.PlainLogin(
                            emailField.getValue(), pwdField.getValue(), rememberPassword.getValue())));
                } catch (Exception e) {
                    throw new MyCollabException(e);
                }
            }).withStyleName(MobileUIConstants.BUTTON_ACTION);
    contentLayout.addComponent(signInBtn);

    this.addComponent(contentLayout);
}