List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField(ValueChangeListener<String> valueChangeListener)
From source file:management.limbr.ui.login.LogInViewImpl.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();/*from w w w .j a v a 2 s. c o m*/ usernameField = new TextField(messages.get("usernameFieldLabel")); usernameField.setWidth(20.0f, Unit.EM); usernameField.setRequired(true); usernameField.setInputPrompt(messages.get("usernameFieldPrompt")); usernameField .addValidator(new StringLengthValidator(messages.get("usernameFieldValidation"), 3, 256, false)); usernameField.setImmediate(true); usernameField.setInvalidAllowed(false); passwordField = new PasswordField(messages.get("passwordFieldLabel")); passwordField.setWidth(20.0f, Unit.EM); passwordField.setInputPrompt(messages.get("passwordFieldPrompt")); passwordField .addValidator(new StringLengthValidator(messages.get("passwordFieldValidation"), 8, 256, false)); passwordField.setImmediate(true); passwordField.setRequired(true); passwordField.setNullRepresentation(""); Button logInButton = new Button(messages.get("logInButtonLabel")); logInButton.addClickListener(event -> { usernameField.setValidationVisible(false); passwordField.setValidationVisible(false); try { usernameField.commit(); passwordField.commit(); } catch (Validator.InvalidValueException e) { Notification.show(e.getMessage()); usernameField.setValidationVisible(true); passwordField.setValidationVisible(true); LOG.debug("Validation of log in fields failed.", e); } listeners.forEach(LogInViewListener::logInClicked); }); VerticalLayout fields = new VerticalLayout(usernameField, passwordField, logInButton); fields.setCaption(messages.get("logInCaption", LimbrApplication.getApplicationName())); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); VerticalLayout mainLayout = new VerticalLayout(fields); mainLayout.setSizeFull(); mainLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); mainLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT); setCompositionRoot(mainLayout); listeners.forEach(listener -> listener.viewInitialized(this)); }
From source file:my.vaadin.profile.Forms.java
public Forms() { setSpacing(true);/*from w w w . j a v a2 s . c om*/ setMargin(true); Label title = new Label("Signup Form"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("900px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); //StringGenerator sg = new StringGenerator(); TextField zID = new TextField("zID"); zID.setValue("z123456"); zID.setRequired(true); form.addComponent(zID); TextField name = new TextField("Name"); name.setValue("loreum"); //name.setWidth("50%"); form.addComponent(name); PasswordField pw = new PasswordField("Set Password"); pw.setRequired(true); form.addComponent(pw); DateField birthday = new DateField("Birthday"); birthday.setDateFormat("dd-MM-yyyy"); birthday.setValue(new java.util.Date()); form.addComponent(birthday); OptionGroup gender = new OptionGroup("Gender"); gender.addItem("Male"); gender.addItem("Female"); //sex.select("Male"); gender.addStyleName("horizontal"); form.addComponent(gender); section = new Label("Class Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); TextField classID = new TextField("Class ID"); classID.setValue("INFS2605"); classID.setRequired(true); //classID.setWidth("50%"); form.addComponent(classID); TextField groupID = new TextField("Group ID"); groupID.setValue("1"); //groupID.setWidth("50%"); groupID.setRequired(true); form.addComponent(groupID); Button confirm = new Button("Confirm"); confirm.addStyleName("primary"); form.addComponent(confirm); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(confirm); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.UserComponent.java
License:Apache License
private void init() { FormLayout layout = new FormLayout(); setContent(layout);/*from ww w .j a v a 2 s . co m*/ addStyleName(ValoTheme.FORMLAYOUT_LIGHT); BeanFieldGroup binder = new BeanFieldGroup(user.getClass()); binder.setItemDataSource(user); Field<?> fn = binder.buildAndBind(TRANSLATOR.translate("general.first.name"), "firstName", TextField.class); layout.addComponent(fn); Field<?> ln = binder.buildAndBind(TRANSLATOR.translate("general.last.name"), "lastName", TextField.class); layout.addComponent(ln); Field<?> username = binder.buildAndBind(TRANSLATOR.translate("general.username"), "username", TextField.class); layout.addComponent(username); PasswordField pw = (PasswordField) binder.buildAndBind(TRANSLATOR.translate("general.password"), "password", PasswordField.class); PasswordChangeListener listener = new PasswordChangeListener(); pw.addTextChangeListener(listener); pw.setConverter(new UserPasswordConverter()); layout.addComponent(pw); Field<?> email = binder.buildAndBind(TRANSLATOR.translate("general.email"), "email", TextField.class); layout.addComponent(email); ComboBox locale = new ComboBox(TRANSLATOR.translate("general.locale")); locale.setTextInputAllowed(false); ValidationManagerUI.getAvailableLocales().forEach(l -> { locale.addItem(l.toString()); }); if (user.getLocale() != null) { locale.setValue(user.getLocale()); } binder.bind(locale, "locale"); layout.addComponent(locale); //Status ComboBox status = new ComboBox(TRANSLATOR.translate("general.status")); new UserStatusJpaController(DataBaseManager.getEntityManagerFactory()).findUserStatusEntities() .forEach(us -> { status.addItem(us); status.setItemCaption(us, TRANSLATOR.translate(us.getStatus())); }); binder.bind(status, "userStatusId"); status.setTextInputAllowed(false); layout.addComponent(status); List<UserHasRole> userRoles = new ArrayList<>(); //Project specific roles if (!user.getUserHasRoleList().isEmpty()) { Tree roles = new Tree(TRANSLATOR.translate("project.specific.role")); user.getUserHasRoleList().forEach(uhr -> { if (uhr.getProjectId() != null) { Project p = uhr.getProjectId(); if (!roles.containsId(p)) { roles.addItem(p); roles.setItemCaption(p, p.getName()); roles.setItemIcon(p, VMUI.PROJECT_ICON); } roles.addItem(uhr); roles.setItemCaption(uhr, TRANSLATOR.translate(uhr.getRole().getRoleName())); roles.setChildrenAllowed(uhr, false); roles.setItemIcon(uhr, VaadinIcons.USER_CARD); roles.setParent(uhr, p); } }); if (!roles.getItemIds().isEmpty()) { layout.addComponent(roles); } } //Roles if (edit && ((VMUI) UI.getCurrent()).checkRight("system.configuration")) { Button projectRole = new Button(TRANSLATOR.translate("manage.project.role")); projectRole.addClickListener(l -> { VMWindow w = new VMWindow(TRANSLATOR.translate("manage.project.role")); w.setContent(getProjectRoleManager()); ((VMUI) UI.getCurrent()).addWindow(w); }); layout.addComponent(projectRole); List<Role> list = new RoleJpaController(DataBaseManager.getEntityManagerFactory()).findRoleEntities(); Collections.sort(list, (Role r1, Role r2) -> TRANSLATOR.translate(r1.getRoleName()) .compareTo(TRANSLATOR.translate(r2.getRoleName()))); BeanItemContainer<Role> roleContainer = new BeanItemContainer<>(Role.class, list); TwinColSelect roles = new TwinColSelect(TRANSLATOR.translate("general.role")); roles.setContainerDataSource(roleContainer); roles.setRows(5); roles.setLeftColumnCaption(TRANSLATOR.translate("available.roles")); roles.setRightColumnCaption(TRANSLATOR.translate("current.roles")); roles.setImmediate(true); list.forEach(r -> { roles.setItemCaption(r, TRANSLATOR.translate(r.getDescription())); }); if (user.getUserHasRoleList() != null) { Set<Role> rs = new HashSet<>(); user.getUserHasRoleList().forEach(uhr -> { if (uhr.getProjectId() == null) { rs.add(uhr.getRole()); } }); roles.setValue(rs); } roles.addValueChangeListener(event -> { Set<Role> selected = (Set<Role>) event.getProperty().getValue(); selected.forEach(r -> { UserHasRole temp = new UserHasRole(); temp.setRole(r); temp.setVmUser(user); userRoles.add(temp); }); }); layout.addComponent(roles); } else { if (!user.getUserHasRoleList().isEmpty()) { Table roles = new Table(TRANSLATOR.translate("general.role")); user.getUserHasRoleList().forEach(role -> { roles.addItem(role.getRole()); roles.setItemCaption(role.getRole(), TRANSLATOR.translate(role.getRole().getRoleName())); roles.setItemIcon(role.getRole(), VaadinIcons.USER_STAR); }); layout.addComponent(roles); } } Button update = new Button(user.getId() == null ? TRANSLATOR.translate("general.create") : TRANSLATOR.translate("general.update")); update.addClickListener((Button.ClickEvent event) -> { try { VMUserServer us; String password = (String) pw.getValue(); if (user.getId() == null) { us = new VMUserServer((String) username.getValue(), password, (String) fn.getValue(), (String) ln.getValue(), (String) email.getValue()); } else { us = new VMUserServer(user); us.setFirstName((String) fn.getValue()); us.setLastName((String) ln.getValue()); us.setEmail((String) email.getValue()); us.setUsername((String) username.getValue()); } us.setLocale((String) locale.getValue()); if (user.getUserHasRoleList() == null) { user.setUserHasRoleList(new ArrayList<>()); } user.getUserHasRoleList().clear(); userRoles.forEach(uhr -> { UserHasRoleJpaController c = new UserHasRoleJpaController( DataBaseManager.getEntityManagerFactory()); try { c.create(uhr); user.getUserHasRoleList().add(uhr); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } }); if (listener.isChanged() && !password.equals(user.getPassword())) { //Different password. Prompt for confirmation MessageBox mb = MessageBox.create(); VerticalLayout vl = new VerticalLayout(); Label l = new Label(TRANSLATOR.translate("password.confirm.pw.message")); vl.addComponent(l); PasswordField np = new PasswordField(Lookup.getDefault() .lookup(InternationalizationProvider.class).translate("general.password")); vl.addComponent(np); mb.asModal(true) .withCaption(Lookup.getDefault().lookup(InternationalizationProvider.class) .translate("password.confirm.pw")) .withMessage(vl).withButtonAlignment(Alignment.MIDDLE_CENTER).withOkButton(() -> { try { if (password.equals(MD5.encrypt(np.getValue()))) { us.setHashPassword(true); us.setPassword(np.getValue()); us.write2DB(); Notification.show( TRANSLATOR.translate("audit.user.account.password.change"), Notification.Type.ASSISTIVE_NOTIFICATION); ((VMUI) UI.getCurrent()).updateScreen(); } else { Notification.show(TRANSLATOR.translate("password.does.not.match"), Notification.Type.WARNING_MESSAGE); } mb.close(); } catch (VMException ex) { Exceptions.printStackTrace(ex); } }, ButtonOption.focus(), ButtonOption.closeOnClick(false), ButtonOption.icon(VaadinIcons.CHECK)) .withCancelButton(ButtonOption.icon(VaadinIcons.CLOSE)).getWindow() .setIcon(ValidationManagerUI.SMALL_APP_ICON); mb.open(); } else { us.write2DB(); } ((VMUI) UI.getCurrent()).getUser().update(); ((VMUI) UI.getCurrent()).setLocale(new Locale(us.getLocale())); ((VMUI) UI.getCurrent()).updateScreen(); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } }); Button cancel = new Button( Lookup.getDefault().lookup(InternationalizationProvider.class).translate("general.cancel")); cancel.addClickListener((Button.ClickEvent event) -> { binder.discard(); ((VMUI) UI.getCurrent()).updateScreen(); }); binder.setReadOnly(!edit); binder.setBuffered(true); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(update); hl.addComponent(cancel); layout.addComponent(hl); }
From source file:nl.amc.biolab.nsg.display.component.LoginUI.java
License:Open Source License
public LoginUI(final MainControl mainControl) { setWidth("100%"); setHeight("300px"); layout.setWidth("100%"); layout.setHeight("300px"); layout.addComponent(form);//from w w w .java 2s .co m setCompositionRoot(layout); final TextField name = new TextField("Please enter your XNAT username"); final PasswordField xnatPassword = new PasswordField("Please enter your XNAT password"); xnatPassword.setRequired(true); form.addField("xnatUsername", name); form.addField("xnatPassword", xnatPassword); final Button okButton = new Button("ok"); okButton.setClickShortcut(KeyCode.ENTER); okButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -6535226372165482804L; public void buttonClick(ClickEvent event) { User user = null; user = login((String) name.getValue(), (String) xnatPassword.getValue()); xnatPassword.setValue(""); if (user == null) { return; } okButton.setData(user); mainControl.init(user); app.getMainWindow().executeJavaScript("window.location.reload();"); } }); form.getFooter().addComponent(okButton); }
From source file:nz.co.senanque.vaadinsupport.viewmanager.TouchLoginForm.java
License:Apache License
public void afterPropertiesSet() throws Exception { MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); usernameCaption = messageSourceAccessor.getMessage("username"); passwordCaption = messageSourceAccessor.getMessage("password"); submitCaption = messageSourceAccessor.getMessage("login.button"); welcomeCaption = messageSourceAccessor.getMessage("welcome"); final TextField userName = new TextField(usernameCaption); userName.setImmediate(true);// w w w . ja va2 s .c om addField("userName", userName); final PasswordField password = new PasswordField(passwordCaption); password.setImmediate(true); addField("password", password); Button submit = new Button(submitCaption); addField("submit", submit); submit.addListener(new ClickListener() { private static final long serialVersionUID = 5201900702970450254L; public void buttonClick(ClickEvent event) { Map<String, String> map = new HashMap<String, String>(); map.put("user", String.valueOf(userName.getValue())); map.put("password", String.valueOf(password.getValue())); if (getLoginListener() != null) { try { getLoginListener().onLogin(map); } catch (Exception e) { Throwable cause = e.getCause(); if (cause == null || !(cause instanceof LoginException)) { logger.error(e.getMessage(), e); } MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(m_messageSource); String message = messageSourceAccessor.getMessage("Bad.Login", "Bad Login"); TouchKitApplication.get().getMainWindow().showNotification(message, Notification.TYPE_ERROR_MESSAGE); return; } } TouchKitApplication.get().setUser(userName.getValue()); } }); }
From source file:org.abstractform.vaadin.VaadinFormToolkit.java
License:Apache License
protected AbstractComponent internalBuildField(Field field, Map<String, Object> extraObjects) { AbstractComponent ret = null;/*from www . j a v a2 s .c om*/ if (field.getType().equals(Field.TYPE_BOOL)) { CheckBox cb = new CheckBox(field.getName()); cb.setImmediate(true); ret = cb; } else if (field.getType().equals(Field.TYPE_DATETIME)) { DateField dt = new DateField(field.getName()); dt.setResolution(DateField.RESOLUTION_DAY); dt.setDescription(field.getDescription()); dt.setRequired(field.isRequired()); dt.setImmediate(true); dt.setReadOnly(field.isReadOnly()); ret = dt; } else if (field.getType().equals(Field.TYPE_TEXT) || field.getType().equals(Field.TYPE_NUMERIC) || field.getType().equals(Field.TYPE_PASSWORD)) { AbstractTextField textField; if (field.getType().equals(Field.TYPE_PASSWORD)) { textField = new PasswordField(field.getName()); } else { textField = new TextField(field.getName()); } //textField.setColumns(field.getDisplayWidth()); if (field.getMaxLength() != 0) { textField.setMaxLength(field.getMaxLength()); } textField.setDescription(field.getDescription()); textField.setReadOnly(field.isReadOnly()); textField.setNullRepresentation("".intern()); textField.setNullSettingAllowed(true); textField.setRequired(field.isRequired()); textField.setImmediate(true); textField.setWidth("100%"); ret = textField; } else if (field.getType().equals(SelectorConstants.TYPE_SELECTOR)) { ComboBox comboBox = new ComboBox(field.getName()); comboBox.setTextInputAllowed(false); comboBox.setNullSelectionAllowed(!field.isRequired()); comboBox.setDescription(field.getDescription()); comboBox.setReadOnly(field.isReadOnly()); comboBox.setRequired(field.isRequired()); comboBox.setImmediate(true); comboBox.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY); comboBox.setItemCaptionPropertyId(VaadinSelectorContainer.PROPERTY_CAPTION); comboBox.setWidth("100%"); ret = comboBox; } else if (field.getType().equals(TableConstants.TYPE_TABLE)) { ret = buildTableField(field, extraObjects); } return ret; }
From source file:org.accelerators.activiti.admin.ui.LoginView.java
License:Open Source License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set layout to full size setSizeFull();/* w w w . jav a2s . c o m*/ // Set style this.setStyleName("login-background"); // Add header bar final HorizontalLayout header = new HorizontalLayout(); header.setHeight("50px"); header.setWidth("100%"); addComponent(header); setComponentAlignment(header, Alignment.MIDDLE_CENTER); // Setup grid GridLayout loginGrid = new GridLayout(1, 2); loginGrid.setWidth("250px"); addComponent(loginGrid); setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); loginGrid.addComponent(logoGrid, 0, 0); loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER); Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("login-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSizeFull(); buttonLayout.setSpacing(true); buttonLayout.setMargin(false); buttonLayout.setStyleName("login-form"); loginGrid.addComponent(buttonLayout, 0, 1); loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); footer.setWidth("100%"); addComponent(footer); }
From source file:org.activiti.administrator.ui.LoginView.java
License:Apache License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set style/*from w w w . j a v a 2s . c om*/ setStyleName(Reindeer.LAYOUT_WHITE); // Set layout to full size setSizeFull(); // Create main layout VerticalLayout mainLayout = new VerticalLayout(); // Add layout styles mainLayout.setStyleName(Reindeer.LAYOUT_WHITE); mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); mainLayout.setMargin(false); mainLayout.setSpacing(false); // Add layout addComponent(mainLayout); setComponentAlignment(mainLayout, Alignment.TOP_LEFT); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSpacing(true); buttonLayout.setMargin(true); buttonLayout.setWidth("200px"); buttonLayout.setStyleName("login-form"); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_LEFT); // Add button layout mainLayout.addComponent(buttonLayout); // Add footer text Label footerText = new Label(app.getMessage(Messages.Footer)); footerText.setSizeUndefined(); footerText.setStyleName(Reindeer.LABEL_SMALL); footerText.addStyleName("footer"); mainLayout.addComponent(footerText); mainLayout.setComponentAlignment(footerText, Alignment.BOTTOM_CENTER); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.switchView(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); }
From source file:org.activiti.explorer.ui.management.identity.NewUserPopupWindow.java
License:Apache License
protected void initInputFields() { // Input fields form.addField("id", new TextField(i18nManager.getMessage(Messages.USER_ID))); // Set id field to required form.getField("id").setRequired(true); form.getField("id").setRequiredError(i18nManager.getMessage(Messages.USER_ID_REQUIRED)); form.getField("id").focus(); // Set id field to be unique form.getField("id").addValidator(new Validator() { public void validate(Object value) throws InvalidValueException { if (!isValid(value)) { throw new InvalidValueException(i18nManager.getMessage(Messages.USER_ID_UNIQUE)); }// w ww .jav a 2s . c om } public boolean isValid(Object value) { if (value != null) { return identityService.createUserQuery().userId(value.toString()).singleResult() == null; } return false; } }); // Password is required form.addField("password", new PasswordField(i18nManager.getMessage(Messages.USER_PASSWORD))); form.getField("password").setRequired(true); form.getField("password").setRequiredError(i18nManager.getMessage(Messages.USER_PASSWORD_REQUIRED)); // Password must be at least 5 characters StringLengthValidator passwordLengthValidator = new StringLengthValidator( i18nManager.getMessage(Messages.USER_PASSWORD_MIN_LENGTH, 5), 5, -1, false); form.getField("password").addValidator(passwordLengthValidator); form.addField("firstName", new TextField(i18nManager.getMessage(Messages.USER_FIRSTNAME))); form.addField("lastName", new TextField(i18nManager.getMessage(Messages.USER_LASTNAME))); form.addField("email", new TextField(i18nManager.getMessage(Messages.USER_EMAIL))); }
From source file:org.activiti.explorer.ui.profile.AccountSelectionPopup.java
License:Apache License
protected void initImapComponent() { imapForm = new Form(); imapForm.setDescription(i18nManager.getMessage(Messages.IMAP_DESCRIPTION)); final TextField imapServer = new TextField(i18nManager.getMessage(Messages.IMAP_SERVER)); imapForm.getLayout().addComponent(imapServer); final TextField imapPort = new TextField(i18nManager.getMessage(Messages.IMAP_PORT)); imapPort.setWidth(30, UNITS_PIXELS); imapPort.setValue(143); // Default imap port (non-ssl) imapForm.getLayout().addComponent(imapPort); final CheckBox useSSL = new CheckBox(i18nManager.getMessage(Messages.IMAP_SSL)); useSSL.setValue(false);/* w w w. j av a 2 s .c o m*/ useSSL.setImmediate(true); imapForm.getLayout().addComponent(useSSL); useSSL.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { imapPort.setValue(((Boolean) useSSL.getValue()) ? 993 : 143); } }); final TextField imapUserName = new TextField(i18nManager.getMessage(Messages.IMAP_USERNAME)); imapForm.getLayout().addComponent(imapUserName); final PasswordField imapPassword = new PasswordField(i18nManager.getMessage(Messages.IMAP_PASSWORD)); imapForm.getLayout().addComponent(imapPassword); // Matching listener imapClickListener = new ClickListener() { public void buttonClick(ClickEvent event) { Map<String, Object> accountDetails = createAccountDetails("imap", imapUserName.getValue().toString(), imapPassword.getValue().toString(), "server", imapServer.getValue().toString(), "port", imapPort.getValue().toString(), "ssl", imapPort.getValue().toString()); fireEvent(new SubmitEvent(AccountSelectionPopup.this, SubmitEvent.SUBMITTED, accountDetails)); } }; }