List of usage examples for com.vaadin.ui FormLayout setSizeUndefined
@Override public void setSizeUndefined()
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout getPC() { VerticalLayout cAgentInfo = new VerticalLayout(); final HorizontalLayout cPlaceholder = new HorizontalLayout(); cAgentInfo.setMargin(new MarginInfo(true, true, true, true)); cAgentInfo.setStyleName("c_details_test"); final VerticalLayout cLBody = new VerticalLayout(); cLBody.setStyleName("c_body_visible"); tb = new Table("Linked child accounts"); // addLinksTable(); final VerticalLayout cAllProf = new VerticalLayout(); HorizontalLayout cProfActions = new HorizontalLayout(); final FormLayout cProfName = new FormLayout(); cProfName.setStyleName("frm_profile_name"); cProfName.setSizeUndefined(); final Label lbProf = new Label(); final TextField tFProf = new TextField(); lbProf.setCaption("Profile Name: "); lbProf.setValue("Certified Authorized User."); tFProf.setCaption(lbProf.getCaption()); cProfName.addComponent(lbProf);//from w w w .j a v a 2 s. co m final Button btnEdit = new Button(); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName("btn_link"); btnEdit.setDescription("Edit profile name"); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel Profile name editting."); Button btnAdd = new Button("+"); // btnAdd.setIcon(FontAwesome.EDIT); btnAdd.setStyleName("btn_link"); btnAdd.setDescription("Set new profile"); Button btnRemove = new Button("-"); // btnRemove.setIcon(FontAwesome.EDIT); btnRemove.setStyleName("btn_link"); btnRemove.setDescription("Remove current profile"); // cProf.addComponent(cProfName); cProfActions.addComponent(btnEdit); cProfActions.addComponent(btnCancel); cProfActions.addComponent(btnAdd); cProfActions.addComponent(btnRemove); btnCancel.setVisible(false); cAllProf.addComponent(cProfName); cAllProf.addComponent(cProfActions); cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER); cLBody.addComponent(cAllProf); // cLBody.addComponent(tb); tb.setSelectable(true); cAgentInfo.addComponent(cLBody); btnLink = new Button("Add New Link"); btnLink.setIcon(FontAwesome.LINK); btnLink.setDescription("Link new account."); // cLBody.addComponent(btnLink); // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT); btnLink.addClickListener(new LinkClickHandler()); cPlaceholder.setVisible(false); addLinkUserContainer(); cPlaceholder.setWidth("100%"); cLBody.addComponent(cPlaceholder); cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER); HorizontalLayout c = new HorizontalLayout(); c.addComponent(cAgentInfo); btnEdit.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8427226211153164650L; @Override public void buttonClick(ClickEvent event) { if (btnEdit.getIcon().equals(FontAwesome.EDIT)) { tFProf.setValue(lbProf.getValue()); tFProf.selectAll(); cProfName.replaceComponent(lbProf, tFProf); btnEdit.setIcon(FontAwesome.SAVE); btnCancel.setVisible(true); return; } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) { lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); return; } lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnCancel.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -2870045546205986347L; @Override public void buttonClick(ClickEvent event) { cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder)); btnRemove.addClickListener(new RemoveProfileHandler(pop)); return c; }
From source file:de.fatalix.app.view.login.LoginView.java
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined(); loginForm.setMargin(false);//from w w w .j a v a2 s . co m 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("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); 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.setClickShortcut(ShortcutAction.KeyCode.ENTER); 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: Try anything", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
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(); loginForm.setMargin(false);//from ww w . j a v a 2 s. c o m 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(); loginForm.setMargin(false);/*w w w .j av a 2s. c o m*/ 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.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);//from w ww . j a v a2s. c o m window.setResizable(false); window.setDraggable(false); window.setCaption(Language.get(Word.ACTIVATION_CODE)); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); Button save = new Button(Language.get(Word.ACTIVATE)); TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE)); activationCode.setMaxLength(6); activationCode.focus(); activationCode.addValueChangeListener(e -> { if (activationCode.getValue().length() > 5) { save.setEnabled(true); activationCode.setComponentError(null); } else { save.setEnabled(false); activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS), AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS)); } }); forms.addComponent(activationCode); Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE)); resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); resendMail.addClickListener(ce -> { try { UserUtils.resendActivationMail(UserUtils.getCurrent()); VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL)); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED)); } }); forms.addComponent(resendMail); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { window.close(); }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { String code = activationCode.getValue(); User user = UserUtils.getCurrent(); if (UserUtils.activateUser(user, code)) { VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL)); window.close(); } else { activationCode.setValue(""); VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED)); } } catch (NumberFormatException e) { } }); save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); footer.setSizeUndefined(); footer.setWidth("100%"); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); window.setContent(windowLayout); return window; }
From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java
public RegisterWindow() { setModal(true);/* w ww . j ava 2 s.c o m*/ setResizable(false); setDraggable(false); setCaption(Language.get(Word.REGISTER)); addCloseShortcut(KeyCode.ENTER, null); Button save = new Button(Language.get(Word.REGISTER)); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); TextField firstName = new TextField(Language.get(Word.FIRST_NAME)); firstName.focus(); firstName.setMaxLength(20); firstName.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); save.setEnabled(setError(firstName, true)); } else { firstName.setComponentError(null); boolean enabled = setError(firstName, false); save.setEnabled(enabled); } }); forms.addComponent(firstName); TextField lastName = new TextField(Language.get(Word.LAST_NAME)); lastName.setMaxLength(20); lastName.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); save.setEnabled(setError(lastName, true)); } else { lastName.setComponentError(null); save.setEnabled(setError(lastName, false)); } }); forms.addComponent(lastName); TextField userName = new TextField(Language.get(Word.USERNAME)); userName.setMaxLength(20); userName.addValueChangeListener(event -> { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); save.setEnabled(setError(userName, true)); } else { userName.setComponentError(null); save.setEnabled(setError(userName, false)); } }); forms.addComponent(userName); TextField email1 = new TextField(Language.get(Word.EMAIL)); email1.setMaxLength(256); email1.addValueChangeListener(event -> { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); save.setEnabled(setError(email1, true)); } else { email1.setComponentError(null); save.setEnabled(setError(email1, false)); } }); forms.addComponent(email1); TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN)); email2.setMaxLength(256); email2.addValueChangeListener(event -> { String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase()) + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase()); if (!email2Error.isEmpty()) { email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email2Error); save.setEnabled(setError(email2, true)); } else { email2.setComponentError(null); save.setEnabled(setError(email2, false)); } }); forms.addComponent(email2); ProgressBar strength = new ProgressBar(); PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD)); password1.setMaxLength(51); password1.addValueChangeListener(event -> { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); save.setEnabled(setError(password1, true)); } else { password1.setComponentError(null); save.setEnabled(setError(password1, false)); } }); forms.addComponent(password1); strength.setWidth("184px"); strength.setHeight("1px"); forms.addComponent(strength); PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2.setMaxLength(51); password2.addValueChangeListener(event -> { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); save.setEnabled(setError(password2, true)); } else { password2.setComponentError(null); save.setEnabled(setError(password2, false)); } }); forms.addComponent(password2); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { close(); }); cancel.setClickShortcut(KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(), email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(), lastName.getValue()); UserUtils.setCurrentUser(user); close(); UI.getCurrent().addWindow(ActivateWindow.get()); } catch (UserCreationException ex) { Log.error("Registration failed", ex); VaadinUtils.errorNotification(Language.get(Word.REG_FAILED)); } }); save.setClickShortcut(KeyCode.ENTER, null); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); setContent(windowLayout); }
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);/*from www. ja v a 2s .c o 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.ja va2 s . com 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.univlorraine.mondossierweb.views.windows.PreferencesApplicationWindow.java
License:Apache License
/** * Cre une fentre d'dition des preferences applicative * @param prfrence diter/* w w w.j ava2s.c o m*/ */ public PreferencesApplicationWindow(PreferencesApplication prefApp) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); /* Formulaire */ fieldGroup = new BeanFieldGroup<>(PreferencesApplication.class); fieldGroup.setItemDataSource(prefApp); fieldGroup.setFieldFactory(new FieldGroupFieldFactory() { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("rawtypes") public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) { if (fieldType == NativeSelect.class) { final NativeSelect field = new NativeSelect(); field.addItem("true"); field.addItem("false"); field.setNullSelectionAllowed(false); field.setImmediate(true); //field.setValue(centre.getTemSrv()); field.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { field.setValue(event.getProperty().getValue()); } }); return fieldType.cast(field); } else { final TextField field = new TextField(); field.setImmediate(true); field.addTextChangeListener(new FieldEvents.TextChangeListener() { private static final long serialVersionUID = 1L; @Override public void textChange(TextChangeEvent event) { if (!field.isReadOnly()) { field.setValue(event.getText()); } } }); return fieldType.cast(field); } } }); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale()); //Si on est sur un parametre booleen if (fieldName.equals("valeur") && estUneValeurBooleenne(prefApp.getValeur())) { //On forme le nativeSelect Field<?> field = fieldGroup.buildAndBind(caption, fieldName, NativeSelect.class); formLayout.addComponent(field); } else { Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } formLayout.addComponent(field); } } fieldGroup.getField("prefId").setReadOnly(prefApp.getPrefId() != null); fieldGroup.getField("prefDesc").setReadOnly(prefApp.getPrefDesc() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); /* Enregistre la conf saisie */ configController.saveAppParameter(prefApp); /* Ferme la fentre */ close(); } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }
From source file:fr.univlorraine.mondossierweb.views.windows.SwapUtilisateurWindow.java
License:Apache License
/** * Cre une fentre d'dition du swap utilisateur * @param swap utilisateur diter/*from w w w .ja v a 2s . c o m*/ */ public SwapUtilisateurWindow(UtilisateurSwap swap, boolean ajout) { /* Style */ setModal(true); setResizable(false); setClosable(false); setWidth("50%"); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("100%"); setContent(layout); /* Titre */ if (ajout) { setCaption(applicationContext.getMessage(NAME + ".title.ajout", null, getLocale())); } else { setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale())); } /* Formulaire */ fieldGroup = new BeanFieldGroup<>(UtilisateurSwap.class); fieldGroup.setItemDataSource(swap); FormLayout formLayout = new FormLayout(); formLayout.setSpacing(true); formLayout.setSizeUndefined(); formLayout.setWidth("100%"); for (String fieldName : CONF_APP_FIELDS_ORDER) { String caption = applicationContext.getMessage(NAME + ".swapUserTable." + fieldName, null, getLocale()); Field<?> field = fieldGroup.buildAndBind(caption, fieldName); if (field instanceof AbstractTextField) { ((AbstractTextField) field).setNullRepresentation(""); field.setWidth("100%"); } if (field instanceof DateField) { ((DateField) field).setResolution(DateField.RESOLUTION_MIN); } formLayout.addComponent(field); } //fieldGroup.getField("loginCible").setReadOnly(swap.getLoginCible() != null); fieldGroup.getField("loginSource").setReadOnly(swap.getLoginSource() != null); layout.addComponent(formLayout); /* Ajoute les boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(true); layout.addComponent(buttonsLayout); btnAnnuler = new Button(applicationContext.getMessage(NAME + ".btnAnnuler", null, getLocale()), FontAwesome.TIMES); btnAnnuler.addClickListener(e -> close()); buttonsLayout.addComponent(btnAnnuler); buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT); btnEnregistrer = new Button(applicationContext.getMessage(NAME + ".btnSave", null, getLocale()), FontAwesome.SAVE); btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY); btnEnregistrer.addClickListener(e -> { try { /* Valide la saisie */ fieldGroup.commit(); boolean commitok = true; if (ajout) { //On regarde si le login source n'est pas dj dans la table String loginSource = (String) fieldGroup.getField("loginSource").getValue(); if (configController.getSwapUtilisateur(loginSource) != null) { commitok = false; //afficher message d'erreur Notification.show(applicationContext.getMessage(NAME + ".error.loginexistant", null, UI.getCurrent().getLocale()), Notification.Type.ERROR_MESSAGE); } } if (commitok) { /* Enregistre le swap saisie */ configController.saveSwap(swap); /* Ferme la fentre */ close(); } } catch (CommitException ce) { } }); buttonsLayout.addComponent(btnEnregistrer); buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }