List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER
Alignment MIDDLE_CENTER
To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.
Click Source Link
From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java
public GroupProfileWindow(GroupInterestProfile p, Runnable onClose, boolean isAdmin) { VerticalLayout profileSettingsLayout = new VerticalLayout(); GridLayout windowContent;/*from www .j a v a2s . co 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"); }
From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java
public Component getSources(GroupInterestProfile profile, boolean isAdmin) { 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())); sourceSelected.setEnabled(isAdmin); checkBoxes.add(sourceSelected); Image sourceLogo = new Image(); sourceLogo.addStyleName("logosmall"); sourceLogo.setSource(new ExternalResource(source.getLogo())); if (isAdmin) { sourceLogo.addClickListener(c -> { sourceSelected.setValue(!sourceSelected.getValue()); profile.getSources().replace(source, sourceSelected.getValue()); });//from w w w . j av a2s . 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())); }); checkBoxSelectAll.setEnabled(isAdmin); 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.GroupProfileWindow.java
public Component getCategories(GroupInterestProfile profile, boolean isAdmin) { Map<Category, Boolean> categories = profile.getCategories(); VerticalLayout categoriesLayout = new VerticalLayout(); categoriesLayout.setWidth("100%"); Panel categoriesPanel = new Panel(categoriesLayout); categories.entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName())) .forEach(e -> {/* w w w. j a v a 2 s . c o m*/ Category category = e.getKey(); boolean enabled = e.getValue(); GridLayout categoryLayout = new GridLayout(3, 1); categoryLayout.setWidth("100%"); CheckBox categorySelected = new CheckBox(); categorySelected.setValue(enabled); categorySelected.addStyleName(ValoTheme.CHECKBOX_LARGE); categorySelected.addValueChangeListener(v -> categories.replace(category, v.getValue())); categorySelected.setEnabled(isAdmin); Label categoryIcon = new Label(category.getIcon().getHtml(), ContentMode.HTML); categoryIcon.addStyleName(ValoTheme.LABEL_H3); categoryIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN); Label categoryName = new Label(category.getName(), ContentMode.HTML); Language.setCustom(null, s -> categoryName.setValue(category.getName())); categoryName.addStyleName(ValoTheme.LABEL_H3); categoryName.addStyleName(ValoTheme.LABEL_NO_MARGIN); categoryLayout.addComponents(categorySelected, categoryIcon, categoryName); categoryLayout.setComponentAlignment(categorySelected, Alignment.MIDDLE_CENTER); categoryLayout.setComponentAlignment(categoryIcon, Alignment.MIDDLE_LEFT); categoryLayout.setComponentAlignment(categoryName, Alignment.MIDDLE_LEFT); categoryLayout.setColumnExpandRatio(2, 5); categoryLayout.setSpacing(true); categoriesLayout.addComponent(categoryLayout); }); categoriesPanel.setContent(categoriesLayout); categoriesPanel.setHeight("100%"); categoriesPanel.setCaption(Language.get(Word.CATEGORIES)); Language.setCustom(Word.CATEGORIES, s -> categoriesPanel.setCaption(s)); return categoriesPanel; }
From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java
public Component getTags(GroupInterestProfile profile, boolean isAdmin) { GridLayout allTagsLayout = new GridLayout(2, 1); Panel allTagsPanel = new Panel(allTagsLayout); allTagsPanel.setWidth("100%"); allTagsPanel.setHeight("265px"); allTagsPanel.setCaption(Language.get(Word.TAGS)); Language.setCustom(Word.TAGS, s -> allTagsPanel.setCaption(s)); VerticalLayout includedTagsLayout = new VerticalLayout(); includedTagsLayouts.put(profile, includedTagsLayout); includedTagsLayout.setWidth("100%"); includedTagsLayout.addStyleName("tags"); Label labelIncludedTags = new Label(Language.get(Word.INCLUDE_TAGS));//Evtl only included Language.setCustom(Word.INCLUDE_TAGS, s -> labelIncludedTags.setValue(s)); if (isAdmin) { Component addIncludeTagGroup = getAddTagGroup(profile, true); includedTagsLayout.addComponents(labelIncludedTags, addIncludeTagGroup); includedTagsLayout.setComponentAlignment(addIncludeTagGroup, Alignment.MIDDLE_CENTER); } else {// w w w. j a va 2s. c o m includedTagsLayout.addComponents(labelIncludedTags); } includedTagsLayout.setComponentAlignment(labelIncludedTags, Alignment.MIDDLE_CENTER); VerticalLayout excludedTagsLayout = new VerticalLayout(); excludedTagsLayouts.put(profile, excludedTagsLayout); excludedTagsLayout.setWidth("100%"); excludedTagsLayout.addStyleName("tags"); Label labelExcludedTags = new Label(Language.get(Word.EXCLUDE_TAGS));//Evtl only included Language.setCustom(Word.EXCLUDE_TAGS, s -> labelExcludedTags.setValue(s)); if (isAdmin) { Component addExcludeTagGroup = getAddTagGroup(profile, false); excludedTagsLayout.addComponents(labelExcludedTags, addExcludeTagGroup); excludedTagsLayout.setComponentAlignment(addExcludeTagGroup, Alignment.MIDDLE_CENTER); } else { excludedTagsLayout.addComponents(labelExcludedTags); } excludedTagsLayout.setComponentAlignment(labelExcludedTags, Alignment.MIDDLE_CENTER); profile.getTags().forEach((tag, included) -> addRow(profile, included, tag, isAdmin)); allTagsLayout.addComponents(includedTagsLayout, excludedTagsLayout); allTagsLayout.setWidth("100%"); return allTagsPanel; }
From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java
public Component getSourcesList() { VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setSizeFull();/*ww w. j ava 2 s . co m*/ sourcesLayout = new VerticalLayout(); sourcesLayout.setWidth("100%"); Panel sourcesPanel = new Panel(sourcesLayout); refreshSources(); sourcesPanel.setContent(sourcesLayout); sourcesPanel.setHeight("100%"); windowLayout.addComponent(sourcesPanel); windowLayout.setExpandRatio(sourcesPanel, 1); windowLayout.setSpacing(false); windowLayout.setMargin(false); TextField textFieldSearch = new TextField(); 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); } }); }); Button buttonAddSource = new Button(Language.get(Word.ADD_SOURCE), VaadinIcons.PLUS); buttonAddSource.addClickListener(ce -> UI.getCurrent().addWindow(NewSourceWindow.create())); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { close(); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); GridLayout footer = new GridLayout(4, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.addStyleName("menubar"); footer.setWidth(100.0f, Unit.PERCENTAGE); footer.addComponents(textFieldSearch, placeholder, buttonAddSource, buttonSave); footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonAddSource, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); footer.setColumnExpandRatio(1, 5); windowLayout.addComponent(footer); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.ManageSourcesWindow.java
public void refreshSources() { sourcesLayout.removeAllComponents(); SourceUtils.getSources().stream().sorted((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName())) .forEach(source -> {/*from www . j a v a 2 s .com*/ try { GridLayout sourceLayout = new GridLayout(4, 1); sourceLayout.setSizeFull(); Image sourceLogo = new Image(); URL url = source.getLogo(); if (url != null) { sourceLogo.setSource(new ExternalResource(url)); } sourceLogo.setWidth("150px"); VerticalLayout sourceText = new VerticalLayout(); sourceText.setSizeFull(); Label labelHeadLine = new Label( source.getCategory().getIcon().getHtml() + " " + source.getName(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); Label labelDescription = new Label(source.getDescription(), ContentMode.HTML); labelDescription.addStyleName(ValoTheme.LABEL_SMALL); labelDescription.setWidth("100%"); sourceText.setMargin(false); sourceText.addComponents(labelHeadLine, labelDescription); Button buttonEdit = new Button(VaadinIcons.EDIT); buttonEdit.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonEdit.addClickListener( ce -> UI.getCurrent().addWindow(NewSourceWindow.createEditMode(source))); Button buttonDelete = new Button(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { sourcesLayout.removeComponent(sourceLayout); sourceLayouts.remove(source.getName().toLowerCase().replaceAll(" ", "") .replaceAll("-", "").replaceAll("_", "")); SourceUtils.removeSource(source); }); sourceLayout.addComponents(sourceLogo, sourceText, buttonEdit, buttonDelete); sourceLayout.setComponentAlignment(sourceLogo, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(buttonEdit, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); sourceLayout.setColumnExpandRatio(1, 5); sourceLayout.setSpacing(true); sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "") .replaceAll("_", ""), sourceLayout); sourcesLayout.addComponent(sourceLayout); } catch (Exception e) { Log.error("Skipping Source! ", e); } }); }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
public Component getFirstStage() { Label header = new Label(Language.get(Word.RSS)); header.addStyleName(ValoTheme.LABEL_H1); FormLayout forms = new FormLayout(); forms.setSizeFull();/*w ww .j a va 2 s . c o m*/ TextField rssField = new TextField(Language.get(Word.RSS)); rssField.setWidth("750px"); forms.addComponents(rssField); Runnable cancel = () -> close(); Runnable next = () -> validateFirstStage(rssField.getValue()); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.addComponents(header, forms, getFooter(cancel, next)); windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
/** * If no value present, choose a empty string * * @param title/*from w ww. j a va2s . com*/ * @param link * @param description * @param language * @param imageUrl * @return */ private Component getSecondStage(Source s) { Label header = new Label(Language.get(Word.SOURCE)); header.addStyleName(ValoTheme.LABEL_H1); FormLayout forms = new FormLayout(); forms.setSizeFull(); TextField textFieldId = new TextField(Language.get(Word.ID)); textFieldId.setEnabled(false); textFieldId.setValue(s.getId()); textFieldId.setWidth("750px"); TextField textFieldName = new TextField(Language.get(Word.NAME)); textFieldName.setValue(s.getName()); textFieldName.setWidth("750px"); TextField textFieldDescription = new TextField(Language.get(Word.DESCRIPTION)); textFieldDescription.setValue(s.getDescription()); textFieldDescription.setWidth("750px"); TextField textFieldURL = new TextField(Language.get(Word.URL)); if (s.getUrl() != null) { textFieldURL.setValue(s.getUrl().toExternalForm()); } textFieldURL.setWidth("750px"); ComboBox<Category> comboBoxCategories = new ComboBox<>(Language.get(Word.CATEGORY), EnumSet.allOf(Category.class)); comboBoxCategories.setItemCaptionGenerator(c -> c.getName()); comboBoxCategories.setItemIconGenerator(c -> c.getIcon()); comboBoxCategories.setEmptySelectionAllowed(false); comboBoxCategories.setTextInputAllowed(false); comboBoxCategories.setWidth("375px"); if (s.getCategory() != null) { comboBoxCategories.setSelectedItem(s.getCategory()); } ComboBox<Locale> comboBoxLanguage = new ComboBox<>(Language.get(Word.LANGUAGE), getLanguages()); comboBoxLanguage.setItemCaptionGenerator(l -> l.getDisplayLanguage(VaadinSession.getCurrent().getLocale())); comboBoxLanguage.setEmptySelectionAllowed(false); comboBoxLanguage.setWidth("375px"); if (!s.getLanguage().isEmpty()) { Locale selected = new Locale(s.getLanguage()); comboBoxLanguage.setSelectedItem(selected); } Locale loc = VaadinSession.getCurrent().getLocale(); Map<String, Locale> countries = getCountries(); List<Locale> locales = countries.values().parallelStream() .sorted((l1, l2) -> l1.getDisplayCountry(loc).compareTo(l2.getDisplayCountry(loc))) .collect(Collectors.toList()); ComboBox<Locale> comboBoxCountry = new ComboBox<>(Language.get(Word.COUNTRY), locales); comboBoxCountry.setItemCaptionGenerator(l -> l.getDisplayCountry(VaadinSession.getCurrent().getLocale())); comboBoxCountry.setItemIconGenerator(l -> FamFamFlags.fromLocale(l)); comboBoxCountry.setEmptySelectionAllowed(false); comboBoxCountry.setWidth("375px"); if (!s.getCountry().isEmpty()) { comboBoxCountry.setSelectedItem(countries.getOrDefault(s.getCountry(), Locale.ROOT)); } Image imageLogo = new Image(Language.get(Word.LOGO)); TextField textFieldLogo = new TextField(Language.get(Word.LOGO_URL)); if (s.getLogo() != null) { textFieldLogo.setValue(s.getLogo().toExternalForm()); imageLogo.setSource(new ExternalResource(s.getLogo())); } textFieldLogo.addValueChangeListener(ce -> imageLogo.setSource(new ExternalResource(ce.getValue()))); textFieldLogo.setWidth("750px"); if (imageLogo.getHeight() > 125) { imageLogo.setHeight("125px"); } forms.addComponents(textFieldId, textFieldName, textFieldDescription, textFieldURL, comboBoxCategories, comboBoxLanguage, comboBoxCountry, textFieldLogo, imageLogo); Runnable cancel = () -> close(); Runnable next = () -> validateSecondStage(s, textFieldId.getValue(), textFieldName.getValue(), textFieldURL.getValue(), textFieldDescription.getValue(), comboBoxCategories.getSelectedItem().orElse(null), comboBoxLanguage.getSelectedItem().orElse(Locale.ROOT), comboBoxCountry.getSelectedItem().orElse(Locale.ROOT), textFieldLogo.getValue()); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.addComponents(header, forms, getFooter(cancel, next)); windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
public Component getThirdStage(Source s) { Label header = new Label(Language.get(Word.CRAWLER)); header.addStyleName(ValoTheme.LABEL_H1); Crawler crawler;//from w w w .j a v a2 s . c o m if (s.getCrawler() != null) { crawler = s.getCrawler(); } else { crawler = new Crawler(s); s.setCrawler(crawler); } GridLayout mainGrid = new GridLayout(2, 2); mainGrid.setSizeFull(); mainGrid.setSpacing(true); FormLayout layoutForms = new FormLayout(); //Exclude or Include RadioButtonGroup<Boolean> radios = new RadioButtonGroup<>(); radios.setItems(true, false); radios.setItemCaptionGenerator(b -> b ? Language.get(Word.INCLUDE_TAGS) : Language.get(Word.EXCLUDE_TAGS)); radios.setItemIconGenerator(b -> b ? VaadinIcons.CHECK : VaadinIcons.CLOSE); radios.setSelectedItem(true); radios.addValueChangeListener(event -> include = event.getValue()); //By Class CssLayout addByClassGroup = new CssLayout(); addByClassGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByClass = new TextField(); textFieldAddByClass.setWidth("465px"); Button buttonAddByClass = new Button(VaadinIcons.PLUS); buttonAddByClass.addClickListener(e -> { crawler.addByClass(textFieldAddByClass.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByClass.clear(); }); addByClassGroup.addComponents(textFieldAddByClass, buttonAddByClass); addByClassGroup.setCaption(Language.get(Word.BYCLASS)); //ByTag CssLayout addByTagGroup = new CssLayout(); addByTagGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByTag = new TextField(); Button buttonAddByTag = new Button(VaadinIcons.PLUS); textFieldAddByTag.setWidth("465px"); buttonAddByTag.addClickListener(e -> { crawler.addByTag(textFieldAddByTag.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByTag.clear(); }); addByTagGroup.addComponents(textFieldAddByTag, buttonAddByTag); addByTagGroup.setCaption(Language.get(Word.BYTAG)); //ByID CssLayout addByIDGroup = new CssLayout(); addByIDGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByID = new TextField(); textFieldAddByID.setWidth("465px"); Button buttonAddByID = new Button(VaadinIcons.PLUS); buttonAddByID.addClickListener(e -> { crawler.addByID(textFieldAddByID.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByID.clear(); }); addByIDGroup.addComponents(textFieldAddByID, buttonAddByID); addByIDGroup.setCaption(Language.get(Word.BYID)); //ByAttribute CssLayout addByAttributeGroup = new CssLayout(); addByAttributeGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldAddByAttributeKey = new TextField(); textFieldAddByAttributeKey.setWidth("233px"); TextField textFieldAddByAttributeValue = new TextField(); textFieldAddByAttributeValue.setWidth("232px"); Button buttonAddByAttribute = new Button(VaadinIcons.PLUS); buttonAddByAttribute.addClickListener(e -> { crawler.addByAttribute(textFieldAddByAttributeKey.getValue(), textFieldAddByAttributeValue.getValue(), include); refreshList(mainGrid, crawler); textFieldAddByAttributeKey.clear(); textFieldAddByAttributeValue.clear(); }); addByAttributeGroup.addComponents(textFieldAddByAttributeKey, textFieldAddByAttributeValue, buttonAddByAttribute); addByAttributeGroup.setCaption(Language.get(Word.BYATTRIBUTEVALUE)); layoutForms.addComponents(radios, addByClassGroup, addByTagGroup, addByIDGroup, addByAttributeGroup); mainGrid.addComponent(layoutForms); Label labelResult = new Label(); Panel panelResult = new Panel(labelResult); labelResult.setWidth("100%"); panelResult.setWidth("100%"); panelResult.setHeight("175px"); mainGrid.addComponent(panelResult, 0, 1, 1, 1); Button buttonTestURL = new Button(); buttonTestURL.setIcon(VaadinIcons.EXTERNAL_LINK); buttonTestURL.setCaption(Language.get(Word.OPEN_LINK)); Button buttonTest = new Button(Language.get(Word.TEST), VaadinIcons.CLIPBOARD_CHECK); buttonTest.addClickListener(ce -> { Article a = CrawlerUtils.executeRandom(crawler); labelResult.setValue(a.getBody()); if (reg != null) { reg.remove(); } reg = buttonTestURL .addClickListener(cev -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); }); refreshList(mainGrid, crawler); Runnable cancel = () -> close(); Runnable next = () -> validateThirdStage(s); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.addComponents(header, mainGrid, getFooter(cancel, next, buttonTest, buttonTestURL)); windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER); windowLayout.setExpandRatio(mainGrid, 5); windowLayout.setWidth("1250px"); return windowLayout; }
From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java
public Component getFooter(Runnable cancelRunnable, Runnable nextRunnable, Component... extraComponents) { Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL), VaadinIcons.CLOSE); cancel.addClickListener(ce -> cancelRunnable.run()); Button next = new Button(Language.get(Word.NEXT), VaadinIcons.ARROW_RIGHT); next.addClickListener(ce -> nextRunnable.run()); GridLayout footer = new GridLayout(3 + extraComponents.length, 1); footer.setSpacing(true);//from ww w . j a v a2 s. co m footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); footer.setSizeUndefined(); footer.setWidth("100%"); for (Component extraComponent : extraComponents) { footer.addComponent(extraComponent); footer.setComponentAlignment(extraComponent, Alignment.MIDDLE_CENTER); } footer.addComponents(placeholder, cancel, next); footer.setColumnExpandRatio(footer.getColumns() - 1 - 2, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(next, Alignment.MIDDLE_CENTER); return footer; }