List of usage examples for com.vaadin.ui FormLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:de.fatalix.bookery.view.admin.AppUserCard.java
License:Open Source License
private FormLayout createContent() { usernameField = new TextField("Username", "some.user"); passwordField = new PasswordField("Password", "password"); fullnameField = new TextField("Fullname", "Some User"); eMailField = new TextField("EMail", "user@some.de"); roles = new TextField("Roles", "user"); FormLayout userCardContent = new FormLayout(usernameField, passwordField, fullnameField, eMailField, roles); userCardContent.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); userCardContent.setMargin(true); return userCardContent; }
From source file:de.fatalix.bookery.view.admin.BatchJobCard.java
private FormLayout createContent() { batchJobTypeCombo = new ComboBox("Batch Type"); for (BatchJobType type : BatchJobType.values()) { batchJobTypeCombo.addItem(type); }/*from w w w. j a v a 2 s. c o m*/ batchJobTypeCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (!noUpdate) { BatchJobType newType = ((BatchJobType) batchJobTypeCombo.getValue()); batchJobConfiguration.setValue(newType.getDefaultConfig()); updateBean(); setFields(); } } }); description = new Label("description"); nextRuntime = new Label("---"); batchJobActive = new CheckBox("active", false); cronjobExpression = new TextField("Cronjob", "*******"); status = new TextField("Status", "-"); batchJobConfiguration = new TextArea("Configuration"); Button updateButton = new Button("update", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { updateBean(); jobConfig = presenter.updateBatchJob(jobConfig); setFields(); logger.debug("Updated Batch Job..."); } }); updateButton.addStyleName(ValoTheme.BUTTON_FRIENDLY); FormLayout batchJobCardContent = new FormLayout(batchJobTypeCombo, description, cronjobExpression, batchJobActive, batchJobConfiguration, nextRuntime, status, updateButton); batchJobCardContent.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); batchJobCardContent.setMargin(true); return batchJobCardContent; }
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();/*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.gedoplan.webclients.vaadin.LoginUi.java
@Override protected void init(VaadinRequest request) { TextField name = new TextField(Messages.login_name.value()); name.focus();//from w w w .j av a 2s . c om PasswordField password = new PasswordField(Messages.login_password.value()); Button login = new Button(Messages.login_submit.value(), e -> { try { JaasAccessControl.login(name.getValue(), password.getValue()); Page.getCurrent().setLocation(Konstanten.VAADIN_UI_PATH); } catch (ServletException ex) { Notification.show(Messages.login_invalid.value(), Notification.Type.ERROR_MESSAGE); } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); FormLayout fieldLayout = new FormLayout(name, password, login); fieldLayout.setMargin(true); fieldLayout.setSpacing(true); Panel loginPanel = new Panel(Messages.login_title.value(), fieldLayout); loginPanel.setSizeUndefined(); VerticalLayout page = new VerticalLayout(); page.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); page.addComponent(loginPanel); page.setSizeFull(); setContent(page); }
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. ja 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.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);//ww w. jav a 2s . c om 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 w w . j a v a2 s. co 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:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java
License:Open Source License
/** * Zeige das Projekt-Hinzufuegen-Dialogfenster, bei dem ein Eingabefeld fuer * den Namen des Projekts und ein Hinzfuege-Button vorhanden ist. Funktion * bei geklicktem Button siehe Clicklistener in dieser Klasse. Das * horizontale Layout zur Darstellung besitzt ein Formlayout und den Button, * die nebeneinander dargestellt werden. * /* www . ja v a 2s .c o m*/ * @author Christian Scherer, Mirko Gpfrich */ @Override public void showAddProjectDialog() { addDialog = new Window("Projekt hinzufgen"); addDialog.setModal(true); addDialog.setWidth(410, UNITS_PIXELS); addDialog.setResizable(false); addDialog.setDraggable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(false); FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setSpacing(true); //TextFeld fr Name dem Formular hinzufgen tfName = new TextField("Name whlen:"); tfName.setRequired(true); tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2, 20, false)); tfName.setRequiredError("Pflichtfeld"); tfName.setSizeFull(); formLayout.addComponent(tfName); //TextArea fr Beschreibung dem Formular hinzufgen taDescription = new TextArea("Beschreibung whlen"); taDescription.setSizeFull(); formLayout.addComponent(taDescription); //Formular dem Layout hinzufgen layout.addComponent(formLayout); //Hinzufge-Button erstllen und dem Layout hinzufgen dialogAddBtn = new Button("Hinzufgen", this); layout.addComponent(dialogAddBtn); //Layout dem Dialog-Fenster hinzufgen addDialog.addComponent(layout); //Dialog dem Hauptfenster hinzufgen getWindow().addWindow(addDialog); logger.debug("Hinzufuege-Dialog erzeugt"); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.projectlist.ProjectListViewImpl.java
License:Open Source License
/**Methode zur Implementierung des Dialogfensters fr Projekt-nderungen. * //from ww w . j ava 2s. co m */ @Override public void showEditProjectDialog(Project project) { editDialog = new Window("Projekt bearbeiten"); editDialog.setModal(true); editDialog.setWidth(410, UNITS_PIXELS); editDialog.setResizable(false); editDialog.setDraggable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setSpacing(true); //TextFeld fr Name dem Formular hinzufgen tfName = new TextField("Name ndern:", project.getName()); tfName.setRequired(true); tfName.addValidator(new StringLengthValidator("Der Projektname muss zwischen 2 und 20 Zeichen lang sein.", 2, 20, false)); tfName.setRequiredError("Pflichtfeld"); tfName.setSizeFull(); formLayout.addComponent(tfName); //TextArea fr Beschreibung dem Formular hinzufgen taDescription = new TextArea("Beschreibung ndern:", project.getDescription()); taDescription.setSizeFull(); formLayout.addComponent(taDescription); //Formular dem Layout hinzufgen layout.addComponent(formLayout); //Speichern-Button erstllen und dem Layout hinzufgen //TODO: ist das korrekt? Gute Frage, I have no idea what u r doing dialogEditBtn = new Button("Speichern"); layout.addComponent(dialogEditBtn); dialogEditBtn.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { if (tfName.isValid()) { boolean succed = presenter.editProject(projects.get(indexEditBtn), (String) tfName.getValue(), (String) taDescription.getValue()); if (succed) { getWindow().removeWindow(editDialog); logger.debug("Projekt-bearbeiten Dialog geschlossen"); } } else { getWindow().showNotification("", "Projektname ist ein Pflichtfeld. Bitte geben Sie einen Projektnamen an", Notification.TYPE_ERROR_MESSAGE); } } }); //Layout dem Dialog-Fenster hinzufgen editDialog.addComponent(layout); //Dialog dem Hauptfenster hinzufgen getWindow().addWindow(editDialog); logger.debug("Bearbeiten-Dialog erzeugt"); }
From source file:edu.nps.moves.mmowgli.modules.cards.ShowCardCacheCountsDialog.java
License:Open Source License
private ShowCardCacheCountsDialog() { setCaption("Show Card Cache Sizes"); setModal(true);/* w w w. j a va 2 s . c o m*/ setWidth("350px"); FormLayout fl = new FormLayout(); setContent(fl); fl.setMargin(true); fl.setSpacing(true); MCacheManager mgr = MCacheManager.instance(); Object[][] caches = mgr.getCaches(); Label lab; for (int i = 0; i < caches[0].length; i++) { if (!(caches[0][i] instanceof String)) continue; if (!(caches[1][i] instanceof Map)) continue; fl.addComponent(lab = new Label("" + ((Map<?, ?>) caches[1][i]).size())); lab.setCaption(caches[0][i].toString()); } }