public UserSelect() { loginInfo = new Label(""); loginInfo.addStyleName("error-font"); loginInfo.addStyleName("margin15"); loginInfo.addStyleName("margin-top40"); loginInfo.setVisible(false); selected = null; loginField = new PasswordField(""); loginField.setWidth("200px"); loginField.addStyleName("margin15"); loginField.addStyleName("margin-bot40"); loginBut = new Button("login"); loginBut.addStyleName("margin15"); loginBut.addClickListener( e -> { if (loginField.getValue().equals(selected.getPassword())) { hidePass(); Globals.user = selected; Globals.root.changeScreen(Globals.user); } else { loginInfo.setVisible(true); loginInfo.setValue("Wrong password"); loginField.setValue(""); } }); loginBox = new HorizontalLayout(); loginBox.addStyleName("popup-box"); loginBox.addComponents(loginField, loginBut, loginInfo); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT); loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT); loginBox.setVisible(false); userIcon = new ThemeResource("icons/user.png"); users = Globals.control.usersData(); vbox = new VerticalLayout(); // vbox.setSizeUndefined(); vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Panel p = new Panel(); p.setSizeFull(); p.setContent(vbox); // vbox.addStyleName("border-l-r"); this.addComponent(p, "left: 25%; right: 25%; top: 15px"); this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%"); this.addLayoutClickListener( e -> { if (!loginBox.isVisible()) return; System.out.println(e.getClickedComponent()); if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass(); }); }
private com.vaadin.ui.Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField 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(ShortcutAction.KeyCode.ENTER); signin.focus(); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { DashboardEventBus.post( new UserLoginRequestedEvent(username.getValue(), password.getValue())); } }); return fields; }
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); username = new TextField("Usuario"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); username.focus(); clave = new PasswordField("Contraseña"); clave.setIcon(FontAwesome.LOCK); clave.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Entrar"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); fields.addComponents(username, clave, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener( new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { doLogin(); } }); return fields; }