List of usage examples for com.vaadin.ui VerticalLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);//from w ww . ja v a2 s.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.ConfirmationDialog.java
public ConfirmationDialog(String confirmationText, Runnable onOk, Runnable onCancel) { addCloseListener(ce -> onCancel.run()); setCaption(Language.get(Word.CONFIRMATION)); VerticalLayout root = new VerticalLayout(); root.setSpacing(false);/*from www . ja va 2 s . c o m*/ root.setMargin(false); root.setSizeFull(); Label text = new Label(confirmationText); text.setStyleName(ValoTheme.LABEL_H3); text.setWidth("100%"); VerticalLayout layoutText = new VerticalLayout(text); layoutText.setSizeFull(); layoutText.addStyleName("tags"); layoutText.setSpacing(false); root.addComponent(layoutText); Label ignoreMe = new Label(); Button ok = new Button(Language.get(Word.OK)); ok.addClickListener(c -> { close(); onOk.run(); }); ok.addStyleName(ValoTheme.BUTTON_DANGER); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.addClickListener(c -> { close(); onCancel.run(); }); cancel.addStyleName(ValoTheme.BUTTON_FRIENDLY); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); footer.addComponents(ignoreMe, ok, cancel); footer.setColumnExpandRatio(0, 5); footer.setComponentAlignment(ok, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); root.setExpandRatio(layoutText, 5); root.addComponent(footer); setContent(root); setModal(true); center(); setDraggable(false); setResizable(false); setWidth("350px"); setHeight("200px"); UI.getCurrent().addWindow(this); }
From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java
public GroupProfileWindow(GroupInterestProfile p, Runnable onClose, boolean isAdmin) { VerticalLayout profileSettingsLayout = new VerticalLayout(); GridLayout windowContent;// w ww . j a va 2s. c o m Button buttonSave = new Button(); if (isAdmin) { windowContent = new GridLayout(3, 3); TextField textFieldName = new TextField(); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(p.getName()); textFieldName.setMaxLength(255); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { GroupInterestProfileUtils.changeName(p, textFieldName.getValue()); GroupInterestProfileUtils.changeSources(p, p.getSources()); GroupInterestProfileUtils.changeCategories(p, p.getCategories()); GroupInterestProfileUtils.changeAllTags(p, p.getTags()); VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); close(); onClose.run(); }); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); windowContent.addComponents(textFieldName, placeholder2); windowContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); windowContent.addComponent(getSources(p, true), 0, 1, 1, 1); windowContent.addComponent(getCategories(p, true), 2, 1); windowContent.addComponent(getTags(p, true), 0, 2, 2, 2); } else { windowContent = new GridLayout(3, 2); Language.set(Word.CLOSE, buttonSave); buttonSave.setIcon(VaadinIcons.CLOSE); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { close(); onClose.run(); }); windowContent.addComponent(getSources(p, false), 0, 0, 1, 0); windowContent.addComponent(getCategories(p, false), 2, 0); windowContent.addComponent(getTags(p, false), 0, 1, 2, 1); } buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML); labelHelp.setWidth("500px"); PopupView popupHelp = new PopupView(null, labelHelp); Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION); buttonHelp.addClickListener(ce -> { popupHelp.setPopupVisible(true); }); GridLayout footer; if (isAdmin) { footer = new GridLayout(4, 1); footer.addComponents(buttonHelp, popupHelp, placeholder, buttonSave); footer.setColumnExpandRatio(2, 5); } else { footer = new GridLayout(2, 1); footer.addComponents(placeholder, buttonSave); footer.setColumnExpandRatio(0, 5); } footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); windowContent.setWidth("100%"); windowContent.setSpacing(true); windowContent.setMargin(true); windowContent.addStyleName("profiles"); profileSettingsLayout.addComponents(windowContent, footer); profileSettingsLayout.setMargin(false); profileSettingsLayout.setSpacing(false); profileSettingsLayout.setWidth("100%"); setContent(profileSettingsLayout); center(); setWidthUndefined(); setCaption(p.getName()); setWidth("950px"); }