List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField()
From source file:nz.co.senanque.vaadinsupport.TouchkitHintsImpl.java
License:Apache License
public AbstractField getTextField(MaduraPropertyWrapper property) { AbstractTextField ret = null;// w w w . j a v a 2 s . co m if (property.isSecret()) { ret = new PasswordField(); } else if (property.isNumeric()) { ret = new NumberField(); } else if (property.isEmail()) { ret = new EmailField(); } else { ret = new TextField(); } return ret; }
From source file:nz.co.senanque.workflowui.WorkflowUIHints.java
License:Apache License
public AbstractField<?> getTextField(MaduraPropertyWrapper property) { AbstractTextField ret = null;//w w w. j av a2 s .c o m if (property.isSecret()) { ret = new PasswordField(); } else { if ("comment".equals(property.getName())) { TextArea textArea = new TextArea(); textArea.setRows(5); textArea.setWordwrap(true); textArea.setWidth("400px"); ret = textArea; } else { ret = new TextField(); } } ret.setMaxLength(property.getMaxLength()); if (property.getValue() == null) { property.setValue(""); } return ret; }
From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java
License:Apache License
protected void loadUserDetails() { // Grid of details GridLayout detailGrid = new GridLayout(); detailGrid.setColumns(2);//w ww .j a va2 s . co m detailGrid.setSpacing(true); detailGrid.setMargin(true, true, false, true); userDetailsLayout.addComponent(detailGrid); // Details addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_ID), new Label(user.getId())); // details are non-editable if (!editingDetails) { addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), new Label(user.getFirstName())); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), new Label(user.getLastName())); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), new Label(user.getEmail())); } else { firstNameField = new TextField(null, user.getFirstName() != null ? user.getFirstName() : ""); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), firstNameField); firstNameField.focus(); lastNameField = new TextField(null, user.getLastName() != null ? user.getLastName() : ""); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), lastNameField); emailField = new TextField(null, user.getEmail() != null ? user.getEmail() : ""); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), emailField); passwordField = new PasswordField(); Label cautionLabel = new Label(i18nManager.getMessage(Messages.USER_RESET_PASSWORD)); cautionLabel.addStyleName(Reindeer.LABEL_SMALL); HorizontalLayout passwordLayout = new HorizontalLayout(); passwordLayout.setSpacing(true); passwordLayout.addComponent(passwordField); passwordLayout.addComponent(cautionLabel); passwordLayout.setComponentAlignment(cautionLabel, Alignment.MIDDLE_LEFT); addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_PASSWORD), passwordLayout); } }
From source file:org.apache.ace.useradmin.ui.vaadin.EditUserInfoWindow.java
License:Apache License
/** * Creates a new {@link EditUserInfoWindow} instance. *//*from ww w . ja v a 2 s. com*/ public EditUserInfoWindow() { setCaption("My info"); setWidth("20%"); m_usernameTextField = new TextField(); m_usernameTextField.setEnabled(false); m_usernameTextField.setCaption("Username"); m_passwordTextField = new PasswordField(); m_passwordTextField.setCaption("Password"); m_passwordTextField.setImmediate(true); m_passwordTextField.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean changed = passwordChanged(); m_applyButton.setEnabled(changed); } }); m_groupField = new TextField(); m_groupField.setEnabled(false); m_groupField.setCaption("Role"); m_applyButton = new Button(); m_applyButton.setCaption("Apply changes"); m_applyButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { storeUserInfo(); } }); FormLayout formLayout = new FormLayout(); formLayout.setMargin(false, false, false, true); formLayout.addComponent(m_usernameTextField); formLayout.addComponent(m_passwordTextField); formLayout.addComponent(m_groupField); formLayout.addComponent(m_applyButton); addComponent(formLayout); }
From source file:org.apache.ace.useradmin.ui.vaadin.UserAdminWindow.java
License:Apache License
/** * Creates a new {@link UserAdminWindow} instance. *//* w ww .ja v a 2 s. c o m*/ public UserAdminWindow() { setCaption("Manage users"); setWidth("30%"); m_userTable = new Table(); m_userTable.setSizeFull(); m_userTable.setImmediate(true); m_userTable.setSelectable(true); m_userTable.setSortDisabled(false); m_userTable.addContainerProperty("User", UserDTO.class, null); m_userTable.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); VerticalLayout usersList = new VerticalLayout(); usersList.setSizeFull(); usersList.addComponent(m_userTable); Button addUserButton = new Button("+"); addUserButton.setStyleName(Reindeer.BUTTON_SMALL); addUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { prepareForNewUser(); } }); m_removeUserButton = new Button(); m_removeUserButton.setStyleName(Reindeer.BUTTON_SMALL); m_removeUserButton.setCaption("-"); m_removeUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { removeSelectedUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addRemoveUserButtons = new HorizontalLayout(); addRemoveUserButtons.setMargin(true, false, false, false); addRemoveUserButtons.setSpacing(true); addRemoveUserButtons.addComponent(addUserButton); addRemoveUserButtons.addComponent(m_removeUserButton); usersList.addComponent(addRemoveUserButtons); usersList.setExpandRatio(m_userTable, 1.0f); usersList.setExpandRatio(addRemoveUserButtons, 0.0f); ValueChangeListener changeListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { m_applyButton.setEnabled(isCurrentFormValid()); m_cancelButton.setEnabled(true); } }; m_usernameTextField = new TextField(); m_usernameTextField.setCaption("Username"); m_usernameTextField.setImmediate(true); m_usernameTextField.setRequired(true); m_usernameTextField.addListener(changeListener); m_passwordTextField = new PasswordField(); m_passwordTextField.setCaption("Password"); m_passwordTextField.setImmediate(true); m_passwordTextField.setRequired(true); m_passwordTextField.addListener(changeListener); m_groupSelect = new Select(); m_groupSelect.setCaption("Role"); m_groupSelect.setImmediate(true); m_groupSelect.setNullSelectionAllowed(false); m_groupSelect.setRequired(true); m_groupSelect.addListener(changeListener); FormLayout formLayout = new FormLayout(); formLayout.addComponent(m_usernameTextField); formLayout.addComponent(m_passwordTextField); formLayout.addComponent(m_groupSelect); m_applyButton = new Button(); m_applyButton.setCaption("Apply changes"); m_applyButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { storeUserInfo(); } }); m_cancelButton = new Button(); m_cancelButton.setEnabled(false); m_cancelButton.setCaption("Cancel"); m_cancelButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addUserButtons = new HorizontalLayout(); addUserButtons.setMargin(true, false, false, false); addUserButtons.setSpacing(true); addUserButtons.addComponent(m_applyButton); addUserButtons.addComponent(m_cancelButton); formLayout.addComponent(addUserButtons); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); horizontalLayout.setSpacing(true); horizontalLayout.addComponent(usersList); horizontalLayout.addComponent(formLayout); horizontalLayout.setExpandRatio(usersList, 0.35f); horizontalLayout.setExpandRatio(formLayout, 0.65f); addComponent(horizontalLayout); updateState(null, false /* editAllowed */); }
From source file:org.apache.openaz.xacml.admin.view.components.SQLPIPConfigurationComponent.java
License:Apache License
@AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false);/* ww w .ja v a2s . c o m*/ mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(false); mainLayout.setSpacing(true); // top-level component properties setWidth("-1px"); setHeight("-1px"); // comboBoxConnectionType comboBoxConnectionType = new ComboBox(); comboBoxConnectionType.setCaption("Type of SQL Connection"); comboBoxConnectionType.setImmediate(false); comboBoxConnectionType.setWidth("-1px"); comboBoxConnectionType.setHeight("-1px"); mainLayout.addComponent(comboBoxConnectionType); // textFieldDataSource textFieldDataSource = new TextField(); textFieldDataSource.setCaption("Data Source"); textFieldDataSource.setImmediate(false); textFieldDataSource.setWidth("-1px"); textFieldDataSource.setHeight("-1px"); mainLayout.addComponent(textFieldDataSource); mainLayout.setExpandRatio(textFieldDataSource, 1.0f); // comboBoxSQLDriver comboBoxSQLDriver = new ComboBox(); comboBoxSQLDriver.setCaption("JDBC Driver"); comboBoxSQLDriver.setImmediate(false); comboBoxSQLDriver.setWidth("-1px"); comboBoxSQLDriver.setHeight("-1px"); mainLayout.addComponent(comboBoxSQLDriver); mainLayout.setExpandRatio(comboBoxSQLDriver, 1.0f); // textFieldConnectionURL textFieldConnectionURL = new TextField(); textFieldConnectionURL.setCaption("Connection URL"); textFieldConnectionURL.setImmediate(false); textFieldConnectionURL.setWidth("-1px"); textFieldConnectionURL.setHeight("-1px"); mainLayout.addComponent(textFieldConnectionURL); mainLayout.setExpandRatio(textFieldConnectionURL, 1.0f); // textFieldUser textFieldUser = new TextField(); textFieldUser.setCaption("User"); textFieldUser.setImmediate(false); textFieldUser.setWidth("-1px"); textFieldUser.setHeight("-1px"); mainLayout.addComponent(textFieldUser); mainLayout.setExpandRatio(textFieldUser, 1.0f); // textFieldPassword textFieldPassword = new PasswordField(); textFieldPassword.setCaption("Password"); textFieldPassword.setImmediate(false); textFieldPassword.setWidth("-1px"); textFieldPassword.setHeight("-1px"); mainLayout.addComponent(textFieldPassword); mainLayout.setExpandRatio(textFieldPassword, 1.0f); // buttonTest buttonTest = new Button(); buttonTest.setCaption("Test Connection"); buttonTest.setImmediate(true); buttonTest.setWidth("-1px"); buttonTest.setHeight("-1px"); mainLayout.addComponent(buttonTest); mainLayout.setComponentAlignment(buttonTest, new Alignment(48)); return mainLayout; }
From source file:org.hip.vif.forum.member.ui.EditPwrdView.java
License:Open Source License
private PasswordField createPasswordField(final int inWidth) { final PasswordField out = new PasswordField(); out.setWidth(inWidth, Unit.PIXELS);/* w w w. j av a 2s . c o m*/ out.setStyleName("vif-input"); //$NON-NLS-1$ return out; }
From source file:org.hip.vif.web.util.ConfigViewHelper.java
License:Open Source License
/** Creates a password field for the specified bean field. * * @param inKey String the id of the bean field this password field should be bound to * @param inRequiredFieldLbl String the label of the password field, if it's required * @return {@link PasswordField} the created password field instance */ public PasswordField createPassword(final String inKey, final String inRequiredFieldLbl) { return (PasswordField) configForm.prepareField(new PasswordField(), inKey, inRequiredFieldLbl); }
From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoryManagementPanel.java
License:BSD License
protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*from ww w. ja v a 2 s. c o m*/ Panel securityAdministrationPanel = new Panel(); securityAdministrationPanel.setStyleName("dashboard"); securityAdministrationPanel.setWidth("100%"); securityAdministrationPanel.setHeight("100%"); GridLayout gridLayout = new GridLayout(2, 25); gridLayout.setSpacing(true); gridLayout.setWidth("100%"); gridLayout.setHeight("100%"); gridLayout.setMargin(true); gridLayout.setColumnExpandRatio(0, 0.3f); gridLayout.setColumnExpandRatio(1, 0.7f); authenticationMethodCombo.addItem(LOCAL_AUTHENTICATION); authenticationMethodCombo.setItemCaption(LOCAL_AUTHENTICATION, LOCAL_AUTHENTICATION.getCaption()); authenticationMethodCombo.addItem(LDAP_LOCAL_AUTHENTICATION); authenticationMethodCombo.setItemCaption(LDAP_LOCAL_AUTHENTICATION, LDAP_LOCAL_AUTHENTICATION.getCaption()); authenticationMethodCombo.addItem(LDAP_AUTHENTICATION); authenticationMethodCombo.setItemCaption(LDAP_AUTHENTICATION, LDAP_AUTHENTICATION.getCaption()); authenticationMethodDropdownValuesMap.put(LOCAL_AUTHENTICATION.getValue(), LOCAL_AUTHENTICATION); authenticationMethodDropdownValuesMap.put(LDAP_LOCAL_AUTHENTICATION.getValue(), LDAP_LOCAL_AUTHENTICATION); authenticationMethodDropdownValuesMap.put(LDAP_AUTHENTICATION.getValue(), LDAP_AUTHENTICATION); final Label serverSettings = new Label("Server Settings"); serverSettings.setStyleName("large-bold"); gridLayout.addComponent(serverSettings, 0, 0); final Label directoryNameLabel = new Label("Directory Name:"); directoryNameLabel.setSizeUndefined(); this.directoryName = new TextField(); this.directoryName.setWidth("400px"); this.directoryName.setRequired(true); gridLayout.addComponent(directoryNameLabel, 0, 1); gridLayout.addComponent(this.directoryName, 1, 1); gridLayout.setComponentAlignment(directoryNameLabel, Alignment.MIDDLE_RIGHT); final Label ldapServerUrlLabel = new Label("LDAP Server URL:"); ldapServerUrlLabel.setSizeUndefined(); this.ldapServerUrl = new TextField(); this.ldapServerUrl.setWidth("400px"); gridLayout.addComponent(ldapServerUrlLabel, 0, 2); gridLayout.addComponent(this.ldapServerUrl, 1, 2); this.ldapServerUrl.setRequired(true); gridLayout.setComponentAlignment(ldapServerUrlLabel, Alignment.MIDDLE_RIGHT); Label hostnameExample = new Label("Hostname of server running LDAP. Example: ldap://ldap.example.com:389"); gridLayout.addComponent(hostnameExample, 1, 3); final Label ldapBindUserDnLabel = new Label("Username:"); ldapBindUserDnLabel.setSizeUndefined(); this.ldapBindUserDn = new TextField(); this.ldapBindUserDn.setWidth("400px"); this.ldapBindUserDn.setRequired(true); gridLayout.addComponent(ldapBindUserDnLabel, 0, 4); gridLayout.addComponent(this.ldapBindUserDn, 1, 4); gridLayout.setComponentAlignment(ldapBindUserDnLabel, Alignment.MIDDLE_RIGHT); Label usernameExample = new Label("User to log into LDAP. Example: cn=user,DC=domain,DC=name"); gridLayout.addComponent(usernameExample, 1, 5); final Label ldapBindUserPasswordLabel = new Label("Password:"); ldapBindUserPasswordLabel.setSizeUndefined(); this.ldapBindUserPassword = new PasswordField(); this.ldapBindUserPassword.setWidth("100px"); this.ldapBindUserPassword.setRequired(true); gridLayout.addComponent(ldapBindUserPasswordLabel, 0, 6); gridLayout.addComponent(this.ldapBindUserPassword, 1, 6); gridLayout.setComponentAlignment(ldapBindUserPasswordLabel, Alignment.MIDDLE_RIGHT); final Label ldapSchema = new Label("LDAP Schema"); ldapSchema.setStyleName("large-bold"); gridLayout.addComponent(ldapSchema, 0, 7); final Label ldapUserSearchDnLabel = new Label("User DN:"); ldapUserSearchDnLabel.setSizeUndefined(); this.ldapUserSearchDn = new TextField(); this.ldapUserSearchDn.setRequired(true); this.ldapUserSearchDn.setWidth("400px"); gridLayout.addComponent(ldapUserSearchDnLabel, 0, 8); gridLayout.setComponentAlignment(ldapUserSearchDnLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.ldapUserSearchDn, 1, 8); Label userDnExample = new Label("The base DN to use when searching for users."); gridLayout.addComponent(userDnExample, 1, 9); final Label applicationSecurityBaseDnLabel = new Label("Group DN:"); applicationSecurityBaseDnLabel.setSizeUndefined(); this.applicationSecurityBaseDn = new TextField(); this.applicationSecurityBaseDn.setRequired(true); this.applicationSecurityBaseDn.setWidth("400px"); gridLayout.addComponent(applicationSecurityBaseDnLabel, 0, 10); gridLayout.setComponentAlignment(applicationSecurityBaseDnLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.applicationSecurityBaseDn, 1, 10); Label groupDnExample = new Label("The base DN to use when searching for groups."); gridLayout.addComponent(groupDnExample, 1, 11); final Label ldapAttributes = new Label("LDAP Attributes"); ldapAttributes.setStyleName("large-bold"); CheckBox checkbox = new CheckBox("Populate default attributes"); checkbox.setValue(false); checkbox.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); if (value == true) { ldapUserSearchFilter.setValue(LDAP_USER_SEARCH_FILTER); emailAttributeName.setValue(EMAIL_ATTRIBUTE_NAME); userAccountNameAttributeName.setValue(USER_ACCOUNT_NAME_ATTRIBUTE_NAME); accountTypeAttributeName.setValue(ACCOUNT_TYPE_ATTRIBUTE_NAME); firstNameAttributeName.setValue(FIRST_NAME_ATTRIBUTE_NAME); surnameAttributeName.setValue(SURNAME_ATTRIBUTE_NAME); departmentAttributeName.setValue(DEPARTMENT_ATTRIBUTE_NAME); ldapUserDescriptionAttributeName.setValue(LDAP_USER_DESCRIPTION_ATTRIBUTE_NAME); memberofAttributeName.setValue(MEMBER_OF_ATTRIBUTE_NAME); applicationSecurityGroupAttributeName.setValue(APPLICATION_SECURITY_GROUP_ATTRIBUTE_NAME); applicationSecurityDescriptionAttributeName .setValue(APPLICATION_SECURITY_DESCRIPTION_ATTRIBUTE_NAME); } else { ldapUserSearchFilter.setValue(""); emailAttributeName.setValue(""); userAccountNameAttributeName.setValue(""); accountTypeAttributeName.setValue(""); firstNameAttributeName.setValue(""); surnameAttributeName.setValue(""); departmentAttributeName.setValue(""); ldapUserDescriptionAttributeName.setValue(""); memberofAttributeName.setValue(""); applicationSecurityGroupAttributeName.setValue(""); applicationSecurityDescriptionAttributeName.setValue(""); } } }); checkbox.setImmediate(true); gridLayout.addComponent(ldapAttributes, 0, 12); gridLayout.addComponent(checkbox, 1, 12); final Label userSearchFieldLabel = new Label("User Search Filter:"); userSearchFieldLabel.setSizeUndefined(); this.ldapUserSearchFilter = new TextField(); this.ldapUserSearchFilter.setWidth("300px"); this.ldapUserSearchFilter.setRequired(true); gridLayout.addComponent(userSearchFieldLabel, 0, 13); gridLayout.setComponentAlignment(userSearchFieldLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.ldapUserSearchFilter, 1, 13); final Label emailAttributeNameLabel = new Label("Email:"); emailAttributeNameLabel.setSizeUndefined(); this.emailAttributeName = new TextField(); this.emailAttributeName.setWidth("300px"); this.emailAttributeName.setRequired(true); gridLayout.addComponent(emailAttributeNameLabel, 0, 14); gridLayout.setComponentAlignment(emailAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.emailAttributeName, 1, 14); final Label userAccountNameAttributeNameLabel = new Label("Account Name:"); userAccountNameAttributeNameLabel.setSizeUndefined(); this.userAccountNameAttributeName = new TextField(); this.userAccountNameAttributeName.setWidth("300px"); this.userAccountNameAttributeName.setRequired(true); gridLayout.addComponent(userAccountNameAttributeNameLabel, 0, 15); gridLayout.setComponentAlignment(userAccountNameAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.userAccountNameAttributeName, 1, 15); final Label accountTypeAttributeNameLabel = new Label("Account Type:"); accountTypeAttributeNameLabel.setSizeUndefined(); this.accountTypeAttributeName = new TextField(); this.accountTypeAttributeName.setWidth("300px"); this.accountTypeAttributeName.setRequired(true); gridLayout.addComponent(accountTypeAttributeNameLabel, 0, 16); gridLayout.setComponentAlignment(accountTypeAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.accountTypeAttributeName, 1, 16); final Label firstNameAttributeNameLabel = new Label("First Name:"); firstNameAttributeNameLabel.setSizeUndefined(); this.firstNameAttributeName = new TextField(); this.firstNameAttributeName.setWidth("300px"); this.firstNameAttributeName.setRequired(true); gridLayout.addComponent(firstNameAttributeNameLabel, 0, 17); gridLayout.setComponentAlignment(firstNameAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.firstNameAttributeName, 1, 17); final Label surnameAttributeNameLabel = new Label("Surname:"); surnameAttributeNameLabel.setSizeUndefined(); this.surnameAttributeName = new TextField(); this.surnameAttributeName.setWidth("300px"); this.surnameAttributeName.setRequired(true); gridLayout.addComponent(surnameAttributeNameLabel, 0, 18); gridLayout.setComponentAlignment(surnameAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.surnameAttributeName, 1, 18); final Label departmentAttributeNameLabel = new Label("User Department:"); departmentAttributeNameLabel.setSizeUndefined(); this.departmentAttributeName = new TextField(); this.departmentAttributeName.setWidth("300px"); this.departmentAttributeName.setRequired(true); gridLayout.addComponent(departmentAttributeNameLabel, 0, 19); gridLayout.setComponentAlignment(departmentAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.departmentAttributeName, 1, 19); final Label ldapUserDescriptionAttributeNameLabel = new Label("User Description:"); ldapUserDescriptionAttributeNameLabel.setSizeUndefined(); this.ldapUserDescriptionAttributeName = new TextField(); this.ldapUserDescriptionAttributeName.setWidth("300px"); this.ldapUserDescriptionAttributeName.setRequired(true); gridLayout.addComponent(ldapUserDescriptionAttributeNameLabel, 0, 20); gridLayout.setComponentAlignment(ldapUserDescriptionAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.ldapUserDescriptionAttributeName, 1, 20); final Label memberOfAttributeNameLabel = new Label("Member Of:"); memberOfAttributeNameLabel.setSizeUndefined(); this.memberofAttributeName = new TextField(); this.memberofAttributeName.setWidth("300px"); this.memberofAttributeName.setRequired(true); gridLayout.addComponent(memberOfAttributeNameLabel, 0, 21); gridLayout.setComponentAlignment(memberOfAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.memberofAttributeName, 1, 21); final Label applicationSecurityGroupAttributeNameLabel = new Label("Group Name:"); applicationSecurityGroupAttributeNameLabel.setSizeUndefined(); this.applicationSecurityGroupAttributeName = new TextField(); this.applicationSecurityGroupAttributeName.setWidth("300px"); this.applicationSecurityGroupAttributeName.setRequired(true); gridLayout.addComponent(applicationSecurityGroupAttributeNameLabel, 0, 22); gridLayout.setComponentAlignment(applicationSecurityGroupAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.applicationSecurityGroupAttributeName, 1, 22); final Label applicationSecurityAttributeNameLabel = new Label("Group Description:"); applicationSecurityAttributeNameLabel.setSizeUndefined(); this.applicationSecurityDescriptionAttributeName = new TextField(); this.applicationSecurityDescriptionAttributeName.setWidth("300px"); this.applicationSecurityDescriptionAttributeName.setRequired(true); gridLayout.addComponent(applicationSecurityAttributeNameLabel, 0, 23); gridLayout.setComponentAlignment(applicationSecurityAttributeNameLabel, Alignment.MIDDLE_RIGHT); gridLayout.addComponent(this.applicationSecurityDescriptionAttributeName, 1, 23); final BeanItem<AuthenticationMethod> authenticationMethodItem = new BeanItem<AuthenticationMethod>( authenticationMethod); this.directoryName.setPropertyDataSource(authenticationMethodItem.getItemProperty("name")); this.ldapServerUrl.setPropertyDataSource(authenticationMethodItem.getItemProperty("ldapServerUrl")); this.ldapBindUserDn.setPropertyDataSource(authenticationMethodItem.getItemProperty("ldapBindUserDn")); this.ldapBindUserPassword .setPropertyDataSource(authenticationMethodItem.getItemProperty("ldapBindUserPassword")); this.ldapUserSearchDn .setPropertyDataSource(authenticationMethodItem.getItemProperty("ldapUserSearchBaseDn")); this.ldapUserSearchFilter .setPropertyDataSource(authenticationMethodItem.getItemProperty("ldapUserSearchFilter")); this.emailAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("emailAttributeName")); this.userAccountNameAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("userAccountNameAttributeName")); this.accountTypeAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("accountTypeAttributeName")); this.applicationSecurityBaseDn .setPropertyDataSource(authenticationMethodItem.getItemProperty("applicationSecurityBaseDn")); this.applicationSecurityGroupAttributeName.setPropertyDataSource( authenticationMethodItem.getItemProperty("applicationSecurityGroupAttributeName")); this.departmentAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("departmentAttributeName")); this.firstNameAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("firstNameAttributeName")); this.surnameAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("surnameAttributeName")); this.ldapUserDescriptionAttributeName.setPropertyDataSource( authenticationMethodItem.getItemProperty("ldapUserDescriptionAttributeName")); this.applicationSecurityDescriptionAttributeName.setPropertyDataSource( authenticationMethodItem.getItemProperty("applicationSecurityDescriptionAttributeName")); this.memberofAttributeName .setPropertyDataSource(authenticationMethodItem.getItemProperty("memberofAttributeName")); Button saveButton = new Button("Save"); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { logger.info("saving auth method: " + authenticationMethod); authenticationMethod.setMethod(SecurityConstants.AUTH_METHOD_LDAP); if (authenticationMethod.getOrder() == null) { authenticationMethod.setOrder(securityService.getNumberOfAuthenticationMethods() + 1); } securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to save the authentication method!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Saved!"); } }); GridLayout buttonLayout = new GridLayout(1, 1); buttonLayout.setWidth("200px"); buttonLayout.setHeight("20px"); buttonLayout.addComponent(saveButton); gridLayout.addComponent(buttonLayout, 0, 24, 1, 24); VerticalLayout wrapperLayout = new VerticalLayout(); wrapperLayout.addComponent(gridLayout); wrapperLayout.setComponentAlignment(gridLayout, Alignment.TOP_CENTER); securityAdministrationPanel.setContent(wrapperLayout); layout.addComponent(securityAdministrationPanel); this.setContent(layout); }
From source file:org.ikasan.dashboard.ui.framework.window.AdminPasswordDialog.java
License:BSD License
/** * Helper method to initialise this object. * /*from w ww.ja va 2 s .com*/ * @param userService * @param authProvider * @param visibilityGroup * @param userDetailsHelper * @param commitHandler */ protected void init() { super.setModal(true); super.setResizable(false); super.center(); this.setWidth(300, Unit.PIXELS); this.setHeight(220, Unit.PIXELS); super.setClosable(false); GridLayout form = new GridLayout(2, 4); form.setColumnExpandRatio(0, .15f); form.setColumnExpandRatio(1, .85f); form.setWidth(100, Unit.PERCENTAGE); form.setMargin(true); form.setSpacing(true); Label newTypeLabel = new Label("Initial Administration Password"); newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE); form.addComponent(newTypeLabel, 0, 0, 1, 0); Label passwordLabel = new Label("Password:"); passwordLabel.setSizeUndefined(); form.addComponent(passwordLabel, 0, 1); form.setComponentAlignment(passwordLabel, Alignment.MIDDLE_RIGHT); final PasswordField passwordField = new PasswordField(); passwordField.addValidator(new StringLengthValidator("The username must not be empty", 1, null, true)); passwordField.setValidationVisible(false); passwordField.setStyleName("ikasan"); form.addComponent(passwordField, 1, 1); Label passwordConfirmLabel = new Label("Confirm Password:"); passwordConfirmLabel.setSizeUndefined(); form.addComponent(passwordConfirmLabel, 0, 2); form.setComponentAlignment(passwordConfirmLabel, Alignment.MIDDLE_RIGHT); final PasswordField passwordConfirmField = new PasswordField(); passwordConfirmField.setStyleName("ikasan"); passwordConfirmField .addValidator(new StringLengthValidator("The password must not be empty", 1, null, true)); passwordConfirmField.setValidationVisible(false); form.addComponent(passwordConfirmField, 1, 2); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.setClickShortcut(KeyCode.ENTER); saveButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { passwordField.validate(); passwordConfirmField.validate(); if (!passwordField.getValue().equals(passwordConfirmField.getValue())) { Notification.show("Password and confirmation must be the same!", Type.ERROR_MESSAGE); return; } } catch (InvalidValueException e) { passwordField.setValidationVisible(true); passwordConfirmField.setValidationVisible(true); return; } password = passwordField.getValue(); passwordField.setValue(""); passwordConfirmField.setValue(""); close(); } }); buttons.addComponent(saveButton); form.addComponent(buttons, 0, 3, 1, 3); form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); this.setContent(form); }