List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY
String BUTTON_PRIMARY
To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY.
Click Source Link
From source file:xyz.iipster.ui.DefaultIbmiLoginComponent.java
License:Apache License
@Override public void attach() { super.attach(); final FormLayout fl = new FormLayout(); fl.setSizeUndefined();/*from w w w .j a va 2 s. com*/ userNameTF.setCaption(i18N.get("iipster.login.username.label")); // userNameTF.setRequired(true); userNameTF.addStyleName("upper-case"); userNameTF.setMaxLength(10); passwordPF.setCaption(i18N.get("iipster.login.password.label")); // passwordPF.setRequired(true); fl.addComponent(userNameTF); fl.addComponent(passwordPF); final VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.addComponent(fl); vl.setExpandRatio(fl, 1F); vl.setComponentAlignment(fl, Alignment.MIDDLE_CENTER); final HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); loginButton.setCaption(i18N.get("iipster.login.loginButton.label")); loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY); loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); loginButton.addClickListener(event -> { if (userNameTF.isEmpty()) { Notification.show(i18N.get("iipster.login.username.missing"), Notification.Type.WARNING_MESSAGE); userNameTF.focus(); return; } if (passwordPF.isEmpty()) { Notification.show(i18N.get("iipster.login.password.missing"), Notification.Type.WARNING_MESSAGE); passwordPF.focus(); return; } try { Authentication auth = securityUtils.login(userNameTF.getValue(), passwordPF.getValue()); eventBus.post(new LoginEvent(auth.getPrincipal().toString())); } catch (BadCredentialsException e) { Notification.show(i18N.get("iipster.login.bad.credential"), Notification.Type.WARNING_MESSAGE); } catch (DisabledException e) { Notification.show(i18N.get("iipster.login.disabled"), Notification.Type.WARNING_MESSAGE); } catch (CredentialsExpiredException e) { changePasswordComponent.setUserName(userNameTF.getValue()); changePasswordComponent.setCurrentPassword(passwordPF.getValue()); UI.getCurrent().addWindow(changePasswordComponent); } catch (Exception e) { Notification.show(i18N.get("iipster.login.error"), Notification.Type.WARNING_MESSAGE); } }); hl.addComponent(loginButton); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); vl.setSizeUndefined(); vl.setMargin(true); final Panel panel = new Panel(i18N.get("iipster.login.panel.title"), vl); panel.setSizeUndefined(); rootLayout.addComponent(panel); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }