List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField(ValueChangeListener<String> valueChangeListener)
From source file:org.mpavel.app.views.LoginView.java
License:Apache License
public LoginView(final String fragmentAndParameters) { setCaption("Login"); VerticalLayout layout = new VerticalLayout(); final TextField username = new TextField("Username"); layout.addComponent(username);/* w w w .ja v a 2 s .c o m*/ final PasswordField password = new PasswordField("Password"); layout.addComponent(password); final CheckBox rememberMe = new CheckBox("Remember Me"); layout.addComponent(rememberMe); username.focus(); // TODO: Remove these two lines before production release username.setValue("admin"); password.setValue("admin"); if (ApplicationSecurity.isRemembered()) { username.setValue(ApplicationSecurity.whoIsRemembered()); rememberMe.setValue(ApplicationSecurity.isRemembered()); password.focus(); } @SuppressWarnings("serial") final Button login = new Button("Login", new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Navigator navigator = UI.getCurrent().getNavigator(); if (ApplicationSecurity.login(username.getValue(), password.getValue(), rememberMe.getValue())) { final String location = (fragmentAndParameters == null) ? ApplicationView.NAME : fragmentAndParameters; navigator.navigateTo(location); } else { navigator.navigateTo(LoginView.NAME); } } }); layout.addComponent(login); setContent(layout); }
From source file:org.ow2.sirocco.cloudmanager.util.InputDialog.java
License:Open Source License
private InputDialog(final String title, final String name, final String initialValue, final boolean isPassword, final DialogCallback callback) { super(title); this.callback = callback; this.center(); this.setClosable(false); this.setModal(true); this.setResizable(false); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true);//w w w . j a v a2 s . co m verticalLayout.setMargin(true); FormLayout content = new FormLayout(); content.setMargin(true); content.setWidth("400px"); content.setHeight("100px"); this.textField = isPassword ? new PasswordField(name) : new TextField(name); this.textField.setRequired(true); this.textField.setWidth("100%"); this.textField.setRequired(true); this.textField.setRequiredError("Please provide a " + name); this.textField.setImmediate(true); if (initialValue != null) { this.textField.setValue(initialValue); } content.addComponent(this.textField); verticalLayout.addComponent(content); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); Label spacer = new Label(""); buttonLayout.addComponent(spacer); spacer.setWidth("100%"); buttonLayout.setExpandRatio(spacer, 1f); this.okButton = new Button("Ok", this); this.okButton.setClickShortcut(KeyCode.ENTER, null); this.cancelButton = new Button("Cancel", this); this.cancelButton.setClickShortcut(KeyCode.ESCAPE, null); this.cancelButton.focus(); buttonLayout.addComponent(this.okButton); buttonLayout.addComponent(this.cancelButton); content.addComponent(buttonLayout); // content.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT); verticalLayout.addComponent(buttonLayout); this.setContent(verticalLayout); }
From source file:org.processbase.ui.bpm.admin.UserWindow.java
License:Open Source License
public void initUI() { try {//from w w w. j a v a2s .c o m if (user == null) { setCaption(ProcessbaseApplication.getString("newUser")); } else { setCaption(ProcessbaseApplication.getString("user")); } setModal(true); VerticalLayout layout = (VerticalLayout) this.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName(Reindeer.LAYOUT_WHITE); layout.setSizeFull(); addBtn = new Button(ProcessbaseApplication.getString("btnAdd"), this); closeBtn = new Button(ProcessbaseApplication.getString("btnClose"), this); saveBtn = new Button(ProcessbaseApplication.getString("btnSave"), this); userFirstName = new TextField(ProcessbaseApplication.getString("userFirstName")); userLastName = new TextField(ProcessbaseApplication.getString("userLastName")); userName = new TextField(ProcessbaseApplication.getString("userName")); userEmail = new TextField(ProcessbaseApplication.getString("userEmail")); userJobTitle = new TextField(ProcessbaseApplication.getString("userJobTitle")); password = new PasswordField(ProcessbaseApplication.getString("password")); // prepare user information userInfofmation.setMargin(true); userInfofmation.setSpacing(true); userName.setWidth("270px"); userInfofmation.addComponent(userName); password.setWidth("270px"); userInfofmation.addComponent(password); userFirstName.setWidth("270px"); userInfofmation.addComponent(userFirstName); userLastName.setWidth("270px"); userInfofmation.addComponent(userLastName); userEmail.setWidth("270px"); userInfofmation.addComponent(userEmail); userJobTitle.setWidth("270px"); userInfofmation.addComponent(userJobTitle); // prepare user membership userMembership.setMargin(true); userMembership.setSpacing(true); userMembership.setSizeFull(); prepareTableMembership(); userMembership.addComponent(tableMembership); // prepare user metadata userMetadata.setMargin(true); userMetadata.setSpacing(true); userMetadata.setSizeFull(); prepareTableMetadata(); userMetadata.addComponent(tableMetadata); // prepare tabSheet tabSheet.addTab(userInfofmation, ProcessbaseApplication.getString("userInfofmation"), null); tabSheet.addTab(userMembership, ProcessbaseApplication.getString("userMembership"), null); tabSheet.addTab(userMetadata, ProcessbaseApplication.getString("userMetadata"), null); tabSheet.addListener((TabSheet.SelectedTabChangeListener) this); tabSheet.setImmediate(true); tabSheet.setSizeFull(); layout.addComponent(tabSheet); layout.setExpandRatio(tabSheet, 1); addBtn.setVisible(false); buttons.addButton(addBtn); buttons.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT); buttons.addButton(saveBtn); buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT); buttons.setExpandRatio(saveBtn, 1); buttons.addButton(closeBtn); buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT); buttons.setMargin(false); buttons.setHeight("30px"); buttons.setWidth("100%"); addComponent(buttons); if (user != null) { userFirstName.setValue(user.getFirstName()); userLastName.setValue(user.getLastName()); userName.setValue(user.getUsername()); userEmail.setValue( user.getProfessionalContactInfo() != null ? user.getProfessionalContactInfo().getEmail() : ""); userJobTitle.setValue(user.getJobTitle()); password.setValue(user.getPassword()); refreshTableMembership(); refreshTableMetadata(); userName.setReadOnly(true); } setWidth("800px"); setHeight("500px"); setResizable(false); setModal(true); } catch (Exception ex) { ex.printStackTrace(); showError(ex.getMessage()); throw new RuntimeException(ex); } }
From source file:org.processbase.ui.bpm.identity.UserWindow.java
License:Open Source License
public void initUI() { try {/*from ww w . j ava 2 s . co m*/ if (user == null) { setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("newUser")); } else { setCaption(ProcessbaseApplication.getCurrent().getPbMessages().getString("user")); } setModal(true); VerticalLayout layout = (VerticalLayout) this.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName(Reindeer.LAYOUT_WHITE); layout.setSizeFull(); addBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnAdd"), this); closeBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnClose"), this); saveBtn = new Button(ProcessbaseApplication.getCurrent().getPbMessages().getString("btnSave"), this); userFirstName = new TextField( ProcessbaseApplication.getCurrent().getPbMessages().getString("userFirstName")); userLastName = new TextField( ProcessbaseApplication.getCurrent().getPbMessages().getString("userLastName")); userName = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("userName")); userEmail = new TextField(ProcessbaseApplication.getCurrent().getPbMessages().getString("userEmail")); userJobTitle = new TextField( ProcessbaseApplication.getCurrent().getPbMessages().getString("userJobTitle")); password = new PasswordField(ProcessbaseApplication.getCurrent().getPbMessages().getString("password")); // prepare user information userInfofmation.setMargin(true); userInfofmation.setSpacing(true); userName.setWidth("270px"); userInfofmation.addComponent(userName); password.setWidth("270px"); userInfofmation.addComponent(password); userFirstName.setWidth("270px"); userInfofmation.addComponent(userFirstName); userLastName.setWidth("270px"); userInfofmation.addComponent(userLastName); userEmail.setWidth("270px"); userInfofmation.addComponent(userEmail); userJobTitle.setWidth("270px"); userInfofmation.addComponent(userJobTitle); // prepare user membership userMembership.setMargin(true); userMembership.setSpacing(true); userMembership.setSizeFull(); prepareTableMembership(); userMembership.addComponent(tableMembership); // prepare user metadata userMetadata.setMargin(true); userMetadata.setSpacing(true); userMetadata.setSizeFull(); prepareTableMetadata(); userMetadata.addComponent(tableMetadata); // prepare tabSheet tabSheet.addTab(userInfofmation, ProcessbaseApplication.getCurrent().getPbMessages().getString("userInfofmation"), null); tabSheet.addTab(userMembership, ProcessbaseApplication.getCurrent().getPbMessages().getString("userMembership"), null); tabSheet.addTab(userMetadata, ProcessbaseApplication.getCurrent().getPbMessages().getString("userMetadata"), null); tabSheet.addListener((TabSheet.SelectedTabChangeListener) this); tabSheet.setImmediate(true); tabSheet.setSizeFull(); layout.addComponent(tabSheet); layout.setExpandRatio(tabSheet, 1); addBtn.setVisible(false); buttons.addButton(addBtn); buttons.setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT); buttons.addButton(saveBtn); buttons.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT); buttons.setExpandRatio(saveBtn, 1); buttons.addButton(closeBtn); buttons.setComponentAlignment(closeBtn, Alignment.MIDDLE_RIGHT); buttons.setMargin(false); buttons.setHeight("30px"); buttons.setWidth("100%"); addComponent(buttons); if (user != null) { userFirstName.setValue(user.getFirstName()); userLastName.setValue(user.getLastName()); userName.setValue(user.getUsername()); userEmail.setValue( user.getProfessionalContactInfo() != null ? user.getProfessionalContactInfo().getEmail() : ""); userJobTitle.setValue(user.getJobTitle()); password.setValue(user.getPassword()); refreshTableMembership(); refreshTableMetadata(); userName.setReadOnly(true); } setWidth("800px"); setHeight("500px"); setResizable(false); setModal(true); } catch (Exception ex) { ex.printStackTrace(); showError(ex.getMessage()); } }
From source file:org.ripla.web.internal.views.RiplaLogin.java
License:Open Source License
private void createForm(final VerticalLayout inLayout, final IAppConfiguration inConfiguration) { final IMessages lMessages = Activator.getMessages(); final FormLayout lLayout = new FormLayout(); lLayout.setStyleName("ripla-login-form"); //$NON-NLS-1$ lLayout.setWidth(400, Unit.PIXELS);/*from w w w . j ava 2 s. c o m*/ inLayout.addComponent(lLayout); inLayout.setComponentAlignment(lLayout, Alignment.TOP_CENTER); lLayout.addComponent(LabelHelper.createLabel(inConfiguration.getWelcome(), "ripla-welcome")); userid = new TextField(String.format("%s:", lMessages.getMessage("login.field.user"))); //$NON-NLS-1$ //$NON-NLS-2$ lLayout.addComponent(userid); userid.focus(); password = new PasswordField(String.format("%s:", lMessages.getMessage("login.field.pass"))); //$NON-NLS-1$ //$NON-NLS-2$ lLayout.addComponent(password); loginButton = new Button(lMessages.getMessage("login.button")); //$NON-NLS-1$ lLayout.addComponent(loginButton); loginItem = createLoginItem(); final FieldGroup lBinding = new FieldGroup(loginItem); lBinding.bindMemberFields(this); lBinding.setBuffered(false); }
From source file:org.vaadin.spring.samples.security.shared.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Shared Security Demo Login"); FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined();/*from www . jav a2s . c om*/ userName = new TextField("Username"); passwordField = new PasswordField("Password"); rememberMe = new CheckBox("Remember me"); login = new Button("Login"); loginForm.addComponent(userName); loginForm.addComponent(passwordField); loginForm.addComponent(rememberMe); loginForm.addComponent(login); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); }
From source file:org.vaadin.spring.samples.security.ui.login.views.LoginView.java
License:Apache License
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true);//from www.j a v a 2s . co m fields.addStyleName("fields"); username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); signin.focus(); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { try { security.login(username.getValue(), password.getValue()); } catch (AuthenticationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } // TODO Register Remember me Token /* * Redirect is handled by the VaadinRedirectStrategy * User is redirected to either always the default * or the URL the user request before authentication * * Strategy is configured within SecurityConfiguration * Defaults to User request URL. */ } }); return fields; }
From source file:roart.client.MyVaadinUI.java
private Window getLoginWindow() { final Window window = new Window("Login"); window.setWidth("30%"); window.setHeight("30%"); window.center();// www . ja va 2s.co m final TextField login = new TextField("Username"); final PasswordField password = new PasswordField("Password"); Button button = new Button("Login"); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { tryLogin(login.getValue(), password.getValue()); window.close(); } }); VerticalLayout vert = new VerticalLayout(); vert.addComponent(login); vert.addComponent(password); vert.addComponent(button); window.setContent(vert); return window; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createEmailDatesPanel() { VerticalLayout emailDates = new VerticalLayout(); emailDates.setSpacing(true);/* w w w. ja v a 2s . com*/ emailDates.setMargin(true); emailDates.setSizeFull(); Panel panel2 = new Panel(" ? ??", emailDates); panel2.setSizeFull(); final TextField emailToField = new TextField("e-mail ?:"); emailToField.setValue(get(API.EMAIL_TO)); emailToField.setRequired(true); emailToField.setReadOnly(true); emailToField.addValidator(new EmailValidator(" e-mail ?")); final TextField receiverNameField = new TextField("? ?:"); receiverNameField.setValue(get(API.RECEIVER_NAME)); receiverNameField.setRequired(true); receiverNameField.setReadOnly(true); final TextField emailFromField = new TextField("e-mail ?:"); emailFromField.setValue(get(API.EMAIL_FROM)); emailFromField.setRequired(true); emailFromField.setReadOnly(true); emailFromField.addValidator(new EmailValidator(" e-mail ?")); final TextField senderLoginField = new TextField(" ?:"); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderLoginField.setRequired(true); senderLoginField.setReadOnly(true); final TextField senderNameField = new TextField("? ?:"); senderNameField.setValue(get(API.SENDER_NAME)); senderNameField.setRequired(true); senderNameField.setReadOnly(true); final PasswordField passwordField = new PasswordField(":"); passwordField.setValue(API.PASSWORD); passwordField.setRequired(true); passwordField.setReadOnly(true); final TextField hostField = new TextField("SMTP ?:"); String host = get(API.HOST); hostField.setValue(host == null ? "" : host); hostField.setRequired(true); hostField.setReadOnly(true); final TextField portField = new TextField(":"); String port = get(API.PORT); portField.setValue(port == null ? "" : port); portField.setRequired(true); portField.setReadOnly(true); portField.addValidator(new IntegerValidator(" ")); final CheckBox tls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.TLS)); tls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); final Button check = new Button(""); check.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String emailTo = get(API.EMAIL_TO); String receiverName = get(API.RECEIVER_NAME); String hostName = get(API.HOST); String port = get(API.PORT); String senderLogin = get(API.SENDER_LOGIN); String password = get(API.PASSWORD); String emailFrom = get(API.EMAIL_FROM); String senderName = get(API.SENDER_NAME); if (emailTo.isEmpty() || receiverName.isEmpty() || hostName.isEmpty() || port.isEmpty() || senderLogin.isEmpty() || password.isEmpty() || emailFrom.isEmpty() || senderName.isEmpty()) { check.getWindow().showNotification("? ? "); return; } Email email = new SimpleEmail(); try { email.setSubject("? ?"); email.setMsg("? ?"); email.addTo(emailTo, receiverName); email.setHostName(hostName); email.setSmtpPort(Integer.parseInt(port)); email.setTLS(AdminServiceProvider.getBoolProperty(API.TLS)); email.setAuthentication(senderLogin, password); email.setFrom(emailFrom, senderName); email.setCharset("utf-8"); email.send(); } catch (EmailException e) { check.getWindow().showNotification(e.getMessage()); e.printStackTrace(); return; } check.getWindow().showNotification("? ? "); } }); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setReadOnly(false); receiverNameField.setReadOnly(false); emailFromField.setReadOnly(false); senderLoginField.setReadOnly(false); senderNameField.setReadOnly(false); passwordField.setReadOnly(false); hostField.setReadOnly(false); portField.setReadOnly(false); tls.setReadOnly(false); change.setVisible(false); check.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) emailToField.getValue()) || StringUtils.isEmpty((String) receiverNameField.getValue()) || StringUtils.isEmpty((String) emailFromField.getValue()) || StringUtils.isEmpty((String) senderNameField.getValue()) || StringUtils.isEmpty((String) senderLoginField.getValue()) || StringUtils.isEmpty((String) passwordField.getValue()) || StringUtils.isEmpty((String) hostField.getValue()) || portField.getValue() == null) { emailToField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { emailToField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { emailFromField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { portField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.EMAIL_TO, emailToField.getValue()); set(API.RECEIVER_NAME, receiverNameField.getValue()); set(API.EMAIL_FROM, emailFromField.getValue()); set(API.SENDER_LOGIN, senderLoginField.getValue()); set(API.SENDER_NAME, senderNameField.getValue()); set(API.PASSWORD, passwordField.getValue()); set(API.HOST, hostField.getValue()); set(API.PORT, portField.getValue()); set(API.TLS, tls.getValue()); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); emailToField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setValue(get(API.EMAIL_TO)); receiverNameField.setValue(get(API.RECEIVER_NAME)); emailFromField.setValue(get(API.EMAIL_FROM)); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderNameField.setValue(get(API.SENDER_NAME)); passwordField.setValue(get(API.PASSWORD)); hostField.setValue(get(API.HOST)); portField.setValue(get(API.PORT)); tls.setValue(AdminServiceProvider.getBoolProperty(API.TLS)); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); } }); FormLayout fields1 = new FormLayout(); fields1.setSizeFull(); fields1.addComponent(senderLoginField); fields1.addComponent(passwordField); fields1.addComponent(hostField); fields1.addComponent(portField); fields1.addComponent(tls); FormLayout fields2 = new FormLayout(); fields2.setSizeFull(); fields2.addComponent(emailToField); fields2.addComponent(receiverNameField); fields2.addComponent(emailFromField); fields2.addComponent(senderNameField); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setSizeFull(); fields.addComponent(fields1); fields.addComponent(fields2); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); buttons.addComponent(check); Label label = new Label("?? "); label.addStyleName(Reindeer.LABEL_H2); emailDates.addComponent(label); emailDates.addComponent(fields); emailDates.addComponent(buttons); emailDates.setExpandRatio(fields, 1f); return panel2; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createMilTaskConfigPanel() { VerticalLayout mailConfig = new VerticalLayout(); mailConfig.setSpacing(true);/*from w w w.j av a 2s .c om*/ mailConfig.setMargin(true); mailConfig.setSizeFull(); Panel emailTaskPanel = new Panel("?? SMTP ? Email Task", mailConfig); emailTaskPanel.setSizeFull(); final TextField mtDefaultFrom = new TextField("email :"); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtDefaultFrom.setRequired(true); mtDefaultFrom.setReadOnly(true); mtDefaultFrom.addValidator(new EmailValidator(" e-mail ?")); final TextField mtSenderLoginField = new TextField(" ?:"); mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtSenderLoginField.setRequired(true); mtSenderLoginField.setReadOnly(true); final PasswordField mtPasswordField = new PasswordField(":"); mtPasswordField.setValue(API.MT_PASSWORD); mtPasswordField.setRequired(true); mtPasswordField.setReadOnly(true); final TextField mtHostField = new TextField("SMTP ?:"); String host = get(API.MT_HOST); mtHostField.setValue(host == null ? "" : host); mtHostField.setRequired(true); mtHostField.setReadOnly(true); final TextField mtPortField = new TextField(":"); String port = get(API.MT_PORT); mtPortField.setValue(port == null ? "" : port); mtPortField.setRequired(true); mtPortField.setReadOnly(true); mtPortField.addValidator(new IntegerValidator(" ")); final CheckBox mtTls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtTls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setReadOnly(false); mtDefaultFrom.setReadOnly(false); mtPasswordField.setReadOnly(false); mtHostField.setReadOnly(false); mtPortField.setReadOnly(false); mtTls.setReadOnly(false); change.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) mtSenderLoginField.getValue()) || StringUtils.isEmpty((String) mtDefaultFrom.getValue()) || StringUtils.isEmpty((String) mtPasswordField.getValue()) || StringUtils.isEmpty((String) mtHostField.getValue()) || mtPortField.getValue() == null) { mtSenderLoginField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { mtDefaultFrom.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { mtPortField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.MT_SENDER_LOGIN, mtSenderLoginField.getValue()); set(API.MT_DEFAULT_FROM, mtDefaultFrom.getValue()); set(API.MT_PASSWORD, mtPasswordField.getValue()); set(API.MT_HOST, mtHostField.getValue()); set(API.MT_PORT, mtPortField.getValue()); set(API.MT_TLS, mtTls.getValue()); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); mtSenderLoginField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtPasswordField.setValue(get(API.MT_PASSWORD)); mtHostField.setValue(get(API.MT_HOST)); mtPortField.setValue(get(API.MT_PORT)); mtTls.setValue(AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); } }); FormLayout leftFields = new FormLayout(); leftFields.setSizeFull(); leftFields.addComponent(mtSenderLoginField); leftFields.addComponent(mtDefaultFrom); leftFields.addComponent(mtPasswordField); leftFields.addComponent(mtHostField); leftFields.addComponent(mtPortField); FormLayout rightFields = new FormLayout(); rightFields.setSizeFull(); rightFields.addComponent(mtTls); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSpacing(true); fieldsLayout.setSizeFull(); fieldsLayout.addComponent(leftFields); fieldsLayout.addComponent(rightFields); fieldsLayout.setExpandRatio(leftFields, 0.6f); fieldsLayout.setExpandRatio(rightFields, 0.4f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); Label label = new Label("?? Email Task"); label.addStyleName(Reindeer.LABEL_H2); mailConfig.addComponent(label); mailConfig.addComponent(fieldsLayout); mailConfig.addComponent(buttons); mailConfig.setExpandRatio(fieldsLayout, 1f); return emailTaskPanel; }