List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField(ValueChangeListener<String> valueChangeListener)
From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.UserEditor.java
License:Open Source License
/** * Creates a new UserEditor instance./* w w w.ja v a 2 s . c o m*/ * * @param userServiceAdmin The user admin service for editing the user. */ public UserEditor(APSSimpleUserServiceAdmin userServiceAdmin) { this.userServiceAdmin = userServiceAdmin; this.setStyleName(CSS.APS_EDITING_TEXT); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL); // User id & Auth { HorizontalLayout firstRowLayout = new HorizontalLayout(); firstRowLayout.setSpacing(true); this.userId = new TextField("User id"); this.userId.setColumns(30); this.userId.setImmediate(true); this.userId.setEnabled(true); firstRowLayout.addComponent(this.userId); this.authCurrent = new PasswordField("Current auth"); this.authCurrent.setColumns(30); this.authCurrent.setImmediate(true); this.authCurrent.setEnabled(true); firstRowLayout.addComponent(this.authCurrent); verticalLayout.addComponent(firstRowLayout); HorizontalLayout secondRowLayout = new HorizontalLayout(); secondRowLayout.setSpacing(true); this.authNewOne = new PasswordField("New auth"); this.authNewOne.setColumns(30); this.authNewOne.setImmediate(true); this.authNewOne.setEnabled(true); secondRowLayout.addComponent(this.authNewOne); this.authNewTwo = new PasswordField("New auth confirm"); this.authNewTwo.setColumns(30); this.authNewTwo.setImmediate(true); this.authNewTwo.setEnabled(true); secondRowLayout.addComponent(this.authNewTwo); verticalLayout.addComponent(secondRowLayout); } // User Properties { this.propertiesEditor = new Table(); this.propertiesEditor.setSelectable(true); this.propertiesEditor.setCaption("User properties"); this.propertiesEditor.setPageLength(8); this.propertiesEditor.setEditable(true); this.propertiesEditor.setSizeFull(); this.propertiesEditor.setColumnExpandRatio(USER_PROPS_KEY, 0.3f); this.propertiesEditor.setColumnExpandRatio(USER_PROPS_VALUE, 0.7f); this.propertiesEditor.setTableFieldFactory(new EditFieldFactory()); this.propertiesEditor.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { selectDeselectProperty(event.getItemId()); } }); verticalLayout.addComponent(this.propertiesEditor); // Buttons + info row { HorizontalLayout plusMinusRow = new HorizontalLayout(); plusMinusRow.setSpacing(true); this.plusButton = new Button("+"); this.plusButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addProperty(); } }); plusMinusRow.addComponent(this.plusButton); this.minusButton = new Button("-"); this.minusButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { deleteProperty(); } }); this.minusButton.setEnabled(false); plusMinusRow.addComponent(this.minusButton); this.propsHelpText = new HelpText( "Press + to add new property, select property and press - to delete."); plusMinusRow.addComponent(this.propsHelpText); verticalLayout.addComponent(plusMinusRow); } } // Roles { HorizontalLayout rolesLayout = new HorizontalLayout(); rolesLayout.setSizeFull(); // Available this.availableRoles = new Table("Available roles"); this.availableRoles.setImmediate(true); this.availableRoles.setPageLength(10); this.availableRoles.setSortAscending(true); this.availableRoles.setSizeFull(); this.availableRoles.setDragMode(Table.TableDragMode.ROW); this.availableRoles.setDropHandler(new DropHandler() { @Override public void drop(DragAndDropEvent event) { DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); Object itemId = t.getItemId(); removeRole(itemId); } @Override public AcceptCriterion getAcceptCriterion() { return new RoleAcceptCriterion(UserEditor.this.availableRoles); } }); VerticalLayout availableRolesFrame = new VerticalLayout(); availableRolesFrame.setMargin(false, true, false, false); availableRolesFrame.addComponent(this.availableRoles); rolesLayout.addComponent(availableRolesFrame); // Selected this.selectedRoles = new Table("Selected roles"); this.selectedRoles.setImmediate(true); this.selectedRoles.setPageLength(10); this.selectedRoles.setSortAscending(true); this.selectedRoles.setSizeFull(); this.selectedRoles.setDragMode(Table.TableDragMode.ROW); this.selectedRoles.setDropHandler(new DropHandler() { @Override public void drop(DragAndDropEvent event) { DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); Object itemId = t.getItemId(); addRole(itemId); } @Override public AcceptCriterion getAcceptCriterion() { return new RoleAcceptCriterion(UserEditor.this.selectedRoles); } }); VerticalLayout selectedRolesFrame = new VerticalLayout(); selectedRolesFrame.setMargin(false, false, false, true); selectedRolesFrame.addComponent(this.selectedRoles); rolesLayout.addComponent(selectedRolesFrame); rolesLayout.setExpandRatio(availableRolesFrame, 0.5f); rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f); verticalLayout.addComponent(rolesLayout); this.roleHelptext = new HelpText("Drag and drop roles back and forth to set or remove a role."); verticalLayout.addComponent(this.roleHelptext); } // Save & Cancel { HorizontalLayout saveCancelLayout = new HorizontalLayout(); saveCancelLayout.setSpacing(true); this.saveButton = new Button("Save"); this.saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { save(); } }); saveCancelLayout.addComponent(saveButton); Button cancelButton = new Button("Cancel"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { cancel(); } }); saveCancelLayout.addComponent(cancelButton); verticalLayout.addComponent(saveCancelLayout); } setContent(verticalLayout); }
From source file:se.natusoft.osgi.aps.tools.web.vaadin.VaadinLoginDialogHandler.java
License:Open Source License
/** * Creates a new VaadinLoginDialogHandler. * * @param appWindow The Vaadin application window to add the popup login dialog to. * @param loginHandler A handler for doing the login from the login dialog input. *//*ww w .j a v a 2 s . co m*/ public VaadinLoginDialogHandler(Window appWindow, LoginHandler loginHandler) { this.appWindow = appWindow; this.loginHandler = loginHandler; // Create Login window dialog this.loginWindow = new Window("Login"); this.loginWindow.setModal(true); this.loginWindow.setWidth("300px"); VerticalLayout dialogLayout = new VerticalLayout(); dialogLayout.setSpacing(true); dialogLayout.setMargin(true); this.userName = new TextField("User:"); this.userName.setColumns(20); dialogLayout.addComponent(this.userName); this.password = new PasswordField("Password"); this.password.setColumns(20); this.password.setImmediate(true); this.password.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { login(); } }); dialogLayout.addComponent(password); Button loginButton = new Button("Login"); loginButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); dialogLayout.addComponent(loginButton); this.loginWindow.setContent(dialogLayout); }
From source file:tad.grupo7.ccamistadeslargas.LoginView.java
/** * Crea los campos del formulario./*from w w w .j ava2 s . c om*/ * * @return Component Devuelve el layout que contiene todos los campos del * formulario. */ private Component buildFields() { //LAYOUT CON LOS CAMPOS DEL FORMULARIO HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField email = new TextField("Email"); email.setRequired(true); email.setIcon(FontAwesome.USER); email.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); email.focus(); final PasswordField password = new PasswordField("Password"); password.setRequired(true); 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); final Button registrar = new Button("Sign Up"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); fields.addComponents(email, password, signin, registrar); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); fields.setComponentAlignment(registrar, Alignment.BOTTOM_LEFT); //LOGARSE signin.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { email.validate(); password.validate(); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); if (u != null) { if (u.getEmail().equals("admin") && u.getPassword().equals("admin")) { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("AdminIndex"); } else { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } } else { Notification n = new Notification("Usuario incorrecto", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Rellena todos los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } }); //IR AL FORMULARIO DE REGISTRARSE registrar.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().getNavigator().navigateTo("registrar"); } }); return fields; }
From source file:tad.grupo7.ccamistadeslargas.RegistrarView.java
public RegistrarView() { setMargin(true);// w w w . ja v a 2s .c o m setSpacing(true); //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Registro"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); PasswordField password = new PasswordField("Contrasea"); password.setRequired(true); TextField email = new TextField("Email"); email.setRequired(true); final Button registrar = new Button("Sign Up"); registrar.setClickShortcut(ShortcutAction.KeyCode.ENTER); registrar.addStyleName(ValoTheme.BUTTON_PRIMARY); FormLayout form = new FormLayout(nombre, password, email, registrar); //BOTN PARA REGISTRARSE registrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { nombre.validate(); password.validate(); email.validate(); UsuarioDAO.create(nombre.getValue(), password.getValue(), email.getValue()); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } catch (Validator.InvalidValueException ex) { } } }); //AADIR COMPONENTES addComponents(l, form); setComponentAlignment(form, Alignment.MIDDLE_CENTER); }
From source file:trader.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { setLocale(Locale.ENGLISH);/*from w w w.java2 s. c o m*/ FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); loginForm.addComponent(passwordField = new PasswordField("Password")); loginForm.addComponent(rememberMe = new CheckBox("Remember me")); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 7813011112417170727L; @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(); }