List of usage examples for com.vaadin.ui FormLayout addStyleName
@Override public void addStyleName(String style)
From source file:de.fatalix.bookery.view.login.LoginView.java
License:Open Source License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*from w w w . j a v a2 s . com*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription(""); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); login = new Button("login"); buttons.addComponent(login); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Ask me", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); Panel loginPanel = new Panel(loginForm); loginPanel.setWidthUndefined(); loginPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); loginPanel.addAction(new ShortcutListener("commit", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } } }); return loginPanel; }
From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java
License:Apache License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*from w w w .j a va2 s. c om*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField(translate("login.name.caption"))); username.setDescription(translate("login.name.description")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField(translate("login.password.caption"))); password.setWidth(15, Unit.EM); password.setDescription(translate("login.password.description")); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); login = new Button(translate("login.login-button.caption")); buttons.addComponent(login); login.setDescription(translate("login.login-button.description")); login.setDisableOnClick(true); login.addClickListener(event -> { try { login(); } finally { login.setEnabled(true); } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button forgotPassword; buttons.addComponent(forgotPassword = new Button(translate("login.password-forgotten.caption"))); forgotPassword.setDescription(translate("login.password-forgotten.description")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { NotificationPayload notification = new NotificationPayload("login.password-forgotten.text"); bus.post(new NotificationEvent(this, notification)); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildUserTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.PROFILE)); root.setIcon(VaadinIcons.USER);//w ww .j a v a 2s. com root.setWidth("100%"); root.setSpacing(true); root.setMargin(true); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); firstNameField = new TextField(Language.get(Word.FIRST_NAME)); firstNameField.setValue(user.getFirstName()); firstNameField.setMaxLength(20); firstNameField.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstNameField.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); saveButton.setEnabled(setError(firstNameField, true)); } else { firstNameField.setComponentError(null); boolean enabled = setError(firstNameField, false); saveButton.setEnabled(enabled); } }); setError(firstNameField, false); lastNameField = new TextField(Language.get(Word.LAST_NAME)); lastNameField.setValue(user.getLastName()); lastNameField.setMaxLength(20); lastNameField.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); saveButton.setEnabled(setError(lastNameField, true)); } else { lastNameField.setComponentError(null); saveButton.setEnabled(setError(lastNameField, false)); } }); setError(lastNameField, false); usernameField = new TextField(Language.get(Word.USERNAME)); usernameField.setValue(user.getUsername()); usernameField.setMaxLength(20); usernameField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getUsername())) { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { usernameField.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); saveButton.setEnabled(setError(usernameField, true)); } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } }); setError(usernameField, false); emailField = new TextField(Language.get(Word.EMAIL)); emailField.setValue(user.getEmail()); emailField.setMaxLength(256); emailField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getEmail())) { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); saveButton.setEnabled(setError(emailField, true)); } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } }); setError(emailField, false); oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD)); oldPasswordField.setValue(""); oldPasswordField.setMaxLength(51); oldPasswordField.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); if (!password1Error.isEmpty()) { oldPasswordField.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(oldPasswordField, true)); } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } }); setError(oldPasswordField, false); ProgressBar strength = new ProgressBar(); password1Field = new PasswordField(Language.get(Word.PASSWORD)); password1Field.setValue(""); password1Field.setMaxLength(51); password1Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1Field.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(password1Field, true)); } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } }); setError(password1Field, false); strength.setWidth("184px"); strength.setHeight("1px"); password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2Field.setValue(""); password2Field.setMaxLength(51); password2Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2Field.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); saveButton.setEnabled(setError(password2Field, true)); } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } }); setError(password2Field, false); details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField, password1Field, strength, password2Field); return root; }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildClippingsTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.CLIPPINGS)); root.setIcon(VaadinIcons.NEWSPAPER); root.setWidth("100%"); root.setSpacing(true);//from w ww. ja v a 2 s .co m root.setMargin(true); FormLayout formLayoutClippingDetails = new FormLayout(); formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(formLayoutClippingDetails); CheckBox checkBoxReceiveEmails = new CheckBox(); checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user)); checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue())); HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails); layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION)); layoutCheckBoxReceiveEmails.setMargin(false); layoutCheckBoxReceiveEmails.setSpacing(false); HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout(); layoutAddNewClippingTime.setMargin(false); layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME)); layoutAddNewClippingTime.setWidth("100%"); InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField(); LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin")); dateFieldNewClippingTime.setValue(value); dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale()); dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE); dateFieldNewClippingTime.addStyleName("time-only"); Button buttonAddClippingTime = new Button(); buttonAddClippingTime.setIcon(VaadinIcons.PLUS); buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonAddClippingTime.addClickListener(e -> { LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime(); layoutClippingTimes.addComponent(getTimeRow(user, generalTime)); UserUtils.addClippingSendTime(user, generalTime); }); layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime); layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT); layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER); layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5); layoutClippingTimes = new VerticalLayout(); layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true)); layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES)); layoutClippingTimes.setWidth("100%"); layoutClippingTimes.addStyleName("times"); Set<LocalTime> userTimes = user.getClippingTime(); userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t))); formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime, layoutClippingTimes); return root; }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.PasswordResetPopup.java
License:Open Source License
@SuppressWarnings("serial") public PasswordResetPopup(Button.ClickListener listener, String uname) { setCaption("Password Reset"); VerticalLayout vLay = new VerticalLayout(); vLay.setSpacing(true);//w w w .j av a 2 s . co m vLay.setMargin(true); setContent(vLay); vLay.addComponent(new HtmlLabel( "<center>Please fill in your player name and/or email address<br/>to initiate a password reset.</center>")); // Use an actual form widget here for data binding and error display. FormLayout formLay = new FormLayout(); formLay.setSizeUndefined(); formLay.setSpacing(true); formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) vLay.addComponent(formLay); vLay.setComponentAlignment(formLay, Alignment.TOP_CENTER); formLay.addComponent(userIDTf = new TextField("Player name:")); userIDTf.addStyleName("m-dialog-textfield"); userIDTf.setWidth("85%"); userIDTf.setTabIndex(100); // Help out a little here userIDTf.setValue(uname == null ? "" : uname); formLay.addComponent(emailTf = new TextField("Email:")); emailTf.addStyleName("m-dialog-textfield"); emailTf.setWidth("85%"); emailTf.setTabIndex(101); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(false); hl.setWidth("100%"); vLay.addComponent(hl); Label lab; hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); Button cancelButt = new Button("Cancel"); hl.addComponent(cancelButt); cancelButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getUI().setScrollTop(0); getUI().removeWindow(PasswordResetPopup.this); } }); cancelButt.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); Button continueButt = new Button("Continue"); hl.addComponent(continueButt); continueButt.addClickListener(PasswordResetPopup.this); continueButt.setClickShortcut(ShortcutAction.KeyCode.ENTER); emailTf.focus(); }
From source file:edu.nps.moves.security.PasswordResetUI.java
License:Open Source License
private void handleChangeTL(User user) { this.user = user; Game g = Game.getTL();//w w w .jav a2s . c o m String brand = g.getCurrentMove().getTitle(); Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli"); HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(true); hLay.setWidth("100%"); setContent(hLay); GameLinks gl = GameLinks.getTL(); String blog = gl.getBlogLink(); Label lab; hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); VerticalLayout vl = new VerticalLayout(); hLay.addComponent(vl); vl.setWidth(bannerWidthPx); hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); vl.addStyleName("m-greyborder"); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(lab = new HtmlLabel("")); lab.addStyleName("m-font-21-bold"); lab.setSizeUndefined(); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); StringBuilder sb = new StringBuilder(); sb.append(thanksHdr1); sb.append(blog); sb.append(thanksHdr2); sb.append(brand); sb.append(thanksHdr3); lab.setValue(sb.toString()); vl.addComponent(lab = new HtmlLabel("")); lab.setHeight("15px"); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); FormLayout fLay = new FormLayout(); fLay.setSizeUndefined(); fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) vl.addComponent(fLay); vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER); newPw = new PasswordField("New Password"); newPw.setWidth("99%"); fLay.addComponent(newPw); newPw2 = new PasswordField("Again, please"); newPw2.setWidth("99%"); fLay.addComponent(newPw2); HorizontalLayout buttLay = new HorizontalLayout(); buttLay.setSpacing(true); vl.addComponent(buttLay); vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER); NativeButton cancelButt = new NativeButton(); cancelButt.setStyleName("m-cancelButton"); buttLay.addComponent(cancelButt); buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT); saveButt = new NativeButton(); saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER); saveButt.setStyleName("m-continueButton"); //m-saveChangesButton"); buttLay.addComponent(saveButt); buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT); cancelButt.addClickListener(this); saveButt.addClickListener(this); }
From source file:fr.amapj.view.engine.tools.InLineFormHelper.java
License:Open Source License
/** * Permet de positionner une form en mode Lecture, avec un bouton Editer * //from w ww . j a va 2 s . co m * @param footer * @param canceListener * @param saveListener * @param form */ private void formInLectureMode(FormLayout form) { // form.addStyleName("light"); // Iterator<Component> i = form.iterator(); while (i.hasNext()) { Component c = i.next(); if (c instanceof com.vaadin.ui.AbstractField) { AbstractField field = (AbstractField) c; field.setReadOnly(true); } } // footer.removeAllComponents(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); Label l = new Label(); footer.addComponent(l); footer.setExpandRatio(l, 1.0f); Button edit = new Button(libModifier, new ClickListener() { @Override public void buttonClick(ClickEvent event) { formInCancelSaveMode(form); } }); footer.addComponent(edit); }
From source file:fr.amapj.view.views.parametres.ParametresView.java
License:Open Source License
/** * //from ww w.jav a 2 s . c o m */ @Override public void enterIn(ViewChangeEvent event) { // Bloc identifiants FormLayout form1 = new FormLayout(); form1.setMargin(false); form1.addStyleName("light"); addComponent(form1); Label section = new Label("Paramtres de l'AMAP"); section.addStyleName("h2"); section.addStyleName("colored"); form1.addComponent(section); nomAmap = addTextField("Nom de l'AMAP ", form1); villeAmap = addTextField("Ville de l'AMAP ", form1); addButton("Changer les paramtres gnraux", e -> handleChangerParam()); final PopupListener listener = this; addButton("Ecran \"Mes contrats\" , Gnralits", e -> CorePopup.open(new PEMesContratsEditorPart(), listener)); addButton("Ecran \"Mes contrats\" , Saisie des paiements par l'amapien", e -> CorePopup.open(new PESaisiePaiementEditorPart(), listener)); addButton("Ecran \"Mes livraisons\"", e -> CorePopup.open(new PEMesLivraisonsEditorPart(), listener)); addButton("Ecran \"Liste des adhrents\"", e -> CorePopup.open(new PEListeAdherentEditorPart(), listener)); addButton("Ecran \"Livraison d'un producteur\"", e -> CorePopup.open(new PELivraisonProducteurEditorPart(), listener)); addButton("Ecran \"Livraison d'un amapien\"", e -> CorePopup.open(new PELivraisonAmapienEditorPart(), listener)); addButton("Ecran \"Rception des chques\"", e -> CorePopup.open(new PEReceptionChequeEditorPart(), listener)); addButton("Ecran \"Synthse multi contrats\"", e -> CorePopup.open(new PESyntheseMultiContratEditorPart(), listener)); refresh(); }
From source file:info.magnolia.ui.form.field.component.AbstractBaseItemContentPreviewComponent.java
License:Open Source License
@Override public Component refreshContentDetail(Item item) { FormLayout fileInfo = new FormLayout(); fileInfo.setSizeUndefined();//from www . j ava2 s .c o m fileInfo.addStyleName("file-details"); try { List<Component> res = createFieldDetail(item); fileInfo.addComponents(res.toArray(new Component[res.size()])); } catch (RepositoryException e) { log.warn("Could not get the related File node", e); } return fileInfo; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Initialize a Component displaying some File Informations. * Override getFileDetail...() in order to display custom info's you may want to display. * * @return A file Info Component. Generally a {@link FormLayout}. *///from w w w . ja va 2 s . c o m private Component createFileInfoComponent() { FormLayout fileInfo = new FormLayout(); fileInfo.setSizeUndefined(); fileInfo.addStyleName("file-details"); fileInfo.addComponent(getFileDetailHeader()); fileInfo.addComponent(getFileDetailFileName()); fileInfo.addComponent(getFileDetailSize()); fileInfo.addComponent(getFileDetailFileFormat()); return fileInfo; }