List of usage examples for com.vaadin.ui GridLayout addStyleName
@Override public void addStyleName(String style)
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(5, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true);//from w ww . j a v a 2s . com taskDetails.setMargin(new MarginInfo(false, false, true, false)); // Add image Embedded image = new Embedded(null, Images.TASK_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(historicTask.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 4, 0); // Add due date PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT), historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false); dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE); taskDetails.addComponent(dueDateLabel, 1, 1); // Add priority Integer lowMedHighPriority = convertPriority(historicTask.getPriority()); Label priorityLabel = new Label(); switch (lowMedHighPriority) { case 1: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW); break; case 2: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM); break; case 3: default: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH); } taskDetails.addComponent(priorityLabel, 2, 1); // Add create date PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT), historicTask.getStartTime(), "", true); createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME); taskDetails.addComponent(createLabel, 3, 1); // Add label to fill excess space Label spacer = new Label(); spacer.setContentMode(Label.CONTENT_XHTML); spacer.setValue(" "); spacer.setSizeUndefined(); taskDetails.addComponent(spacer); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); taskDetails.setColumnExpandRatio(3, 1.0f); taskDetails.setColumnExpandRatio(4, 1.0f); centralLayout.addComponent(taskDetails); }
From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(2, 2); taskDetails.setWidth(100, Unit.PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true);/*from w ww.j av a 2 s. c o m*/ taskDetails.setMargin(new MarginInfo(false, false, true, false)); taskDetails.setColumnExpandRatio(1, 1.0f); centralLayout.addComponent(taskDetails); // Add image Embedded image = new Embedded(null, Images.TASK_50); //?? taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(task.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0); taskDetails.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT); // Properties HorizontalLayout propertiesLayout = new HorizontalLayout();// propertiesLayout.setSpacing(true); taskDetails.addComponent(propertiesLayout); propertiesLayout.addComponent(new DueDateComponent(task, i18nManager, taskService)); propertiesLayout.addComponent(new PriorityComponent(task, i18nManager, taskService)); //? initCreateTime(propertiesLayout); }
From source file:com.m4gik.views.component.LibraryScreen.java
/** * This method builds library screen. This method overrides an existing * method./* ww w .j ava 2 s. c om*/ * * @see com.m4gik.views.component.ViewScreen#build() */ @Override public Layout build() { HorizontalLayout root = new HorizontalLayout(); root.setSizeFull(); root.setCaption("Media Library"); root.setHeight("200%"); root.setWidth("100%"); this.content = new VerticalLayout(); content.setSizeFull(); root.addComponent(content); final GridLayout grid = new GridLayout(4, 1); Panel top = new Panel("Music Collection", grid); top.setSizeFull(); top.addStyleName(Runo.PANEL_LIGHT); grid.setWidth("100%"); grid.setMargin(true); grid.addStyleName(Runo.LAYOUT_DARKER); content.addComponent(top); content.setExpandRatio(top, 1); grid.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = -1864555729437118182L; @Override public void layoutClick(LayoutClickEvent event) { for (Iterator<Component> it = grid.iterator(); it.hasNext();) { Component c = it.next(); c.removeStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED); } if (event.getChildComponent() != null) { event.getChildComponent().addStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED); } } }); buildAudioLibrary(grid, null); return root; }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the current info.//from ww w . j a va 2 s . c om * * @param labels the labels * @param values the values * @return the component */ private Component createCurrentInfo(Label[] labels, String[] values) { GridLayout currentGrid = new GridLayout(2, labels.length); currentGrid.addStyleName("currentInfo"); currentGrid.setSpacing(true); currentGrid.setMargin(new MarginInfo(false, false, false, true)); currentGrid.setSizeUndefined(); for (int i = 0; i < labels.length; i++) { Label label = new Label(values[i]); label.setSizeUndefined(); currentGrid.addComponent(label, 0, i); labels[i] = new Label(""); labels[i].setSizeUndefined(); currentGrid.addComponent(labels[i], 1, i); } return (currentGrid); }
From source file:de.catma.ui.tagmanager.TagsetTree.java
License:Open Source License
private void initComponents() { setSizeFull();/*from w w w . j a v a2 s . c o m*/ tagTree = new EndorsedTreeTable(); tagTree.setImmediate(true); tagTree.setSizeFull(); tagTree.setSelectable(true); tagTree.setMultiSelect(false); tagTree.setContainerDataSource(new HierarchicalContainer()); tagTree.addContainerProperty(TagTreePropertyName.caption, String.class, null); tagTree.setColumnHeader(TagTreePropertyName.caption, "Tagsets"); tagTree.addContainerProperty(TagTreePropertyName.icon, Resource.class, null); tagTree.setItemCaptionPropertyId(TagTreePropertyName.caption); tagTree.setItemIconPropertyId(TagTreePropertyName.icon); tagTree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY); tagTree.setVisibleColumns(new Object[] { TagTreePropertyName.caption }); if (colorButtonListener != null) { tagTree.addGeneratedColumn(TagTreePropertyName.color, new ColorButtonColumnGenerator(colorButtonListener)); tagTree.setColumnReorderingAllowed(true); } else { tagTree.addGeneratedColumn(TagTreePropertyName.color, new ColorLabelColumnGenerator()); } tagTree.setColumnHeader(TagTreePropertyName.color, "Tag Color"); addComponent(tagTree); setExpandRatio(tagTree, 2); GridLayout buttonGrid = new GridLayout(1, 19); buttonGrid.setMargin(true); buttonGrid.setSpacing(true); buttonGrid.addStyleName("taglibrary-action-grid"); int buttonGridRowCount = 0; if (withTagsetButtons) { btReload = new Button(""); btReload.setIcon(new ClassResource("ui/resources/icon-reload.gif", getApplication())); btReload.addStyleName("icon-button"); buttonGrid.addComponent(btReload); buttonGrid.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT); buttonGridRowCount++; Label tagsetLabel = new Label(); tagsetLabel.setIcon(new ClassResource("ui/tagmanager/resources/grndiamd.gif", application)); tagsetLabel.setCaption("Tagset"); buttonGrid.addComponent(tagsetLabel); buttonGridRowCount++; btInsertTagset = new Button("Create Tagset"); btInsertTagset.setEnabled(true); btInsertTagset.setWidth("100%"); buttonGrid.addComponent(btInsertTagset); buttonGridRowCount++; btRemoveTagset = new Button("Remove Tagset"); btRemoveTagset.setWidth("100%"); buttonGrid.addComponent(btRemoveTagset); buttonGridRowCount++; btEditTagset = new Button("Edit Tagset"); btEditTagset.setWidth("100%"); buttonGrid.addComponent(btEditTagset); buttonGridRowCount++; } Label tagLabel = new Label(); tagLabel.setIcon(new ClassResource("ui/tagmanager/resources/reddiamd.gif", application)); tagLabel.setCaption("Tag"); buttonGrid.addComponent(tagLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4); buttonGridRowCount += 5; buttonGrid.setComponentAlignment(tagLabel, Alignment.BOTTOM_LEFT); btInsertTag = new Button("Create Tag"); btInsertTag.setWidth("100%"); if (withTagsetButtons) { btInsertTag.setEnabled(true); } buttonGrid.addComponent(btInsertTag); buttonGridRowCount++; btRemoveTag = new Button("Remove Tag"); btRemoveTag.setWidth("100%"); buttonGrid.addComponent(btRemoveTag); buttonGridRowCount++; btEditTag = new Button("Edit Tag"); btEditTag.setWidth("100%"); buttonGrid.addComponent(btEditTag); buttonGridRowCount++; Label propertyLabel = new Label(); propertyLabel.setIcon(new ClassResource("ui/tagmanager/resources/ylwdiamd.gif", application)); propertyLabel.setCaption("Property"); buttonGrid.addComponent(propertyLabel, 0, buttonGridRowCount, 0, buttonGridRowCount + 4); buttonGridRowCount += 5; buttonGrid.setComponentAlignment(propertyLabel, Alignment.BOTTOM_LEFT); btInsertProperty = new Button("Create Property"); btInsertProperty.setWidth("100%"); buttonGrid.addComponent(btInsertProperty); buttonGridRowCount++; btRemoveProperty = new Button("Remove Property"); // commented out on purpose: somehow this forces all the other buttons to // show up in natural size... // btRemoveProperty.setWidth("100%"); buttonGrid.addComponent(btRemoveProperty); buttonGridRowCount++; btEditProperty = new Button("Edit Property"); btEditProperty.setWidth("100%"); buttonGrid.addComponent(btEditProperty); buttonGridRowCount++; addComponent(buttonGrid); setExpandRatio(buttonGrid, 0); if (!withButtonPanel) { buttonGrid.setVisible(false); } }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public VerticalLayout createTab(Group g) { User u = UserUtils.getCurrent();/*from w w w . j a v a 2 s. co m*/ VerticalLayout groupSettingsLayout = new VerticalLayout(); groupSettingsLayouts.put(g, groupSettingsLayout); GridLayout tabContent; TextField textFieldName = new TextField(); if (GroupUtils.isAdmin(g, u)) { tabContent = new GridLayout(3, 2); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(g.getName()); textFieldName.setMaxLength(255); tabContent.addComponent(textFieldName); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); } else { tabContent = new GridLayout(3, 1); } buttonLeave = new Button(); Language.set(Word.LEAVE, buttonLeave); buttonLeave.setIcon(VaadinIcons.MINUS); buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER); buttonLeave.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> { long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count(); if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) { GroupUtils.removeUser(g, u); refreshAll(g); } else { VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP)); } }); }); buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> { GroupUtils.removeGroup(g); refreshAll(g); }); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { if (GroupUtils.isAdmin(g, u)) { GroupUtils.changeName(g, textFieldName.getValue()); accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue()); } VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label placeholder3 = new Label(); GridLayout footer = new GridLayout(4, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(false, true)); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); if (GroupUtils.isAdmin(g, u)) { footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); } else { footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave); } footer.setColumnExpandRatio(0, 5); footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); if (GroupUtils.isAdmin(g, u)) { tabContent.addComponent(getProfiles(g), 0, 1, 1, 1); tabContent.addComponent(getMembers(g), 2, 1); } else { tabContent.addComponent(getProfiles(g), 0, 0, 1, 0); tabContent.addComponent(getMembers(g), 2, 0); } tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); groupSettingsLayout.addComponents(tabContent, footer); groupSettingsLayout.setMargin(false); groupSettingsLayout.setSpacing(false); groupSettingsLayout.setWidth("100%"); return groupSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public VerticalLayout createTab(InterestProfile profile) { VerticalLayout profileSettingsLayout = new VerticalLayout(); GridLayout tabContent = new GridLayout(3, 3); TextField textFieldName = new TextField(); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(profile.getName()); textFieldName.setMaxLength(255);//ww w . ja v a 2 s. c o m CheckBox checkBoxEnabled = new CheckBox(); checkBoxEnabled.setValue(profile.isEnabled()); Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s)); Button buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { InterestProfileUtils.delete(profile); accordion.removeTab(accordion.getTab(profileSettingsLayout)); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { InterestProfileUtils.changeName(profile, textFieldName.getValue()); accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue()); InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue()); InterestProfileUtils.changeSources(profile, profile.getSources()); InterestProfileUtils.changeCategories(profile, profile.getCategories()); InterestProfileUtils.changeAllTags(profile, profile.getTags()); VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML); Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s)); 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 = new GridLayout(5, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave); footer.setColumnExpandRatio(2, 5); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2); tabContent.addComponent(getSources(profile), 0, 1, 1, 1); tabContent.addComponent(getCategories(profile), 2, 1); tabContent.addComponent(getTags(profile), 0, 2, 2, 2); tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER); profileSettingsLayout.addComponents(tabContent, footer); profileSettingsLayout.setMargin(false); profileSettingsLayout.setSpacing(false); profileSettingsLayout.setWidth("100%"); return profileSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public Component getSources(InterestProfile profile) { VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setWidth("100%"); VerticalLayout sourcesLayout = new VerticalLayout(); sourcesLayout.setWidth("100%"); Panel sourcesPanel = new Panel(sourcesLayout); List<CheckBox> checkBoxes = new ArrayList<>(); HashMap<String, GridLayout> sourceLayouts = new HashMap<>(); profile.getSources().entrySet().stream() .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> { Source source = e.getKey(); boolean enabled = e.getValue(); GridLayout sourceLayout = new GridLayout(5, 1); sourceLayout.setSizeFull(); CheckBox sourceSelected = new CheckBox(); sourceSelected.setValue(enabled); sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE); sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue())); checkBoxes.add(sourceSelected); Image sourceLogo = new Image(); sourceLogo.addStyleName("logosmall"); sourceLogo.setSource(new ExternalResource(source.getLogo())); sourceLogo.addClickListener(c -> { sourceSelected.setValue(!sourceSelected.getValue()); profile.getSources().replace(source, sourceSelected.getValue()); });//from w ww .j a va2 s .c o m VerticalLayout layoutLogo = new VerticalLayout(sourceLogo); layoutLogo.setWidth("150px"); layoutLogo.setHeight("50px"); layoutLogo.setMargin(false); layoutLogo.setSpacing(false); layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT); Label labelHeadLine = new Label( source.getCategory().getIcon().getHtml() + " " + source.getName(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H3); Label labelDescription = new Label(source.getDescription(), ContentMode.HTML); labelDescription.setWidth("300px"); PopupView popup = new PopupView(null, labelDescription); Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O); buttonDescription.addClickListener(ce -> { popup.setPopupVisible(true); }); sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription); sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER); sourceLayout.setColumnExpandRatio(2, 5); sourceLayout.setSpacing(true); sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "") .replaceAll("_", ""), sourceLayout); sourcesLayout.addComponent(sourceLayout); }); sourcesPanel.setContent(sourcesLayout); sourcesPanel.setHeight("100%"); sourcesPanel.setCaption(Language.get(Word.SOURCES)); Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s)); windowLayout.addComponent(sourcesPanel); windowLayout.setExpandRatio(sourcesPanel, 1); windowLayout.setSpacing(false); windowLayout.setMargin(false); CheckBox checkBoxSelectAll = new CheckBox(); Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s)); checkBoxSelectAll.setWidth("100%"); checkBoxSelectAll.addValueChangeListener(e -> { profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue()); checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue())); }); TextField textFieldSearch = new TextField(); Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s)); textFieldSearch.setWidth("100%"); textFieldSearch.setMaxLength(255); textFieldSearch.setPlaceholder(Language.get(Word.SEARCH)); textFieldSearch.addValueChangeListener(searchValue -> { sourceLayouts.forEach((sourceName, sourceLayout) -> { if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "") .replaceAll("-", "").replaceAll("_", ""))) { sourcesLayout.removeComponent(sourceLayout); } else { sourcesLayout.addComponent(sourceLayout); } }); }); Label placeholder = new Label(); placeholder.setWidth("100%"); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(true, false, false, false)); footer.addStyleName("menubar"); footer.setWidth("100%"); footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder); footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT); footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER); windowLayout.addComponent(footer); windowLayout.setHeight("350px"); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);//from www . ja va2 s . 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.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 w ww. j a v a2s . c om*/ 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); }