List of usage examples for com.vaadin.ui Label addStyleName
@Override public void addStyleName(String style)
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public void createClippingViewBySource(Clipping clipping) { clippingArticlesLayout.removeAllComponents(); if (ClippingUtils.isEmpty(clipping)) { Label labelNoArticles = new Label(); Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s)); labelNoArticles.addStyleName(ValoTheme.LABEL_H3); clippingArticlesLayout.addComponent(labelNoArticles); }// ww w . j a va 2 s . co m clipping.getArticles().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted( (a1, a2) -> a1.getSourceAsSource().getName().compareToIgnoreCase(a2.getSourceAsSource().getName())) .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a))); clipping.getArticlesFromGroup().entrySet().stream().flatMap(e -> e.getValue().stream()).sorted( (a1, a2) -> a1.getSourceAsSource().getName().compareToIgnoreCase(a2.getSourceAsSource().getName())) .forEach(a -> clippingArticlesLayout.addComponent(createClippingRow(a))); }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }//from ww w. j a va2 s. c o m imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public ClippingView(Clipping clipping) { User user = UserUtils.getCurrent();/*w ww.j a v a2s . com*/ clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); HorizontalLayout clippingOptionsLayout = new HorizontalLayout(); clippingOptionsLayout.setSpacing(true); clippingOptionsLayout.setMargin(false); clippingOptionsLayout.setWidth("100%"); ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(SortOptions.BYPROFILE); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { switch (e.getValue()) { case BYDATE: createClippingViewByDate(clipping); break; case BYPROFILE: createClippingViewByProfile(clipping); break; case BYSOURCE: createClippingViewBySource(clipping); break; } }); Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH); buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonRegenerateClipping.addClickListener(ce -> { user.setLastClipping(ClippingUtils.generateClipping(user, false)); ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent()); }); clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping); clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5); clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER); addComponents(clippingOptionsLayout, clippingArticlesLayout); createClippingViewByProfile(clipping); if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) { Label labelNoProfile = new Label(); Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s)); labelNoProfile.addStyleName(ValoTheme.LABEL_H2); clippingArticlesLayout.addComponent(labelNoProfile); } }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public void createClippingViewByProfile(Clipping clipping) { clippingArticlesLayout.removeAllComponents(); clipping.getArticles().entrySet().stream().forEach(p -> { VerticalLayout layoutProfile = new VerticalLayout(); layoutProfile.setSpacing(true);/* www.ja v a2 s . co m*/ layoutProfile.setMargin(true); layoutProfile.addStyleName("tags"); layoutProfile.setWidth("100%"); if (p.getValue().isEmpty()) { Label labelNoArticles = new Label(); Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s)); labelNoArticles.addStyleName(ValoTheme.LABEL_H3); layoutProfile.addComponent(labelNoArticles); } else { p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a))); } Panel panelProfile = new Panel(p.getKey().getName(), layoutProfile); clippingArticlesLayout.addComponent(panelProfile); }); clipping.getArticlesFromGroup().entrySet().stream().forEach(p -> { VerticalLayout layoutProfile = new VerticalLayout(); layoutProfile.setSpacing(true); layoutProfile.setMargin(true); layoutProfile.addStyleName("tags"); layoutProfile.setWidth("100%"); if (p.getValue().isEmpty()) { Label labelNoArticles = new Label(); Language.setCustom(Word.NO_ARTICLES_PRESENT, s -> labelNoArticles.setValue(s)); labelNoArticles.addStyleName(ValoTheme.LABEL_H3); layoutProfile.addComponent(labelNoArticles); } else { p.getValue().forEach(a -> layoutProfile.addComponent(createClippingRow(a))); } Panel panelProfile = new Panel( Language.get(Word.GROUP) + " " + p.getKey().getGroup().getName() + ": " + p.getKey().getName(), layoutProfile); Language.setCustom(Word.GROUP, s -> panelProfile .setCaption(s + " " + p.getKey().getGroup().getName() + ": " + p.getKey().getName())); clippingArticlesLayout.addComponent(panelProfile); }); }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }//from w w w. ja va 2s. co m imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo = null; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }
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 w w.jav a2 s . co 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.views.InterestProfileView.java
public Component getCategories(InterestProfile profile) { 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 ww. j a va 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())); 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.views.InterestProfileView.java
private void addRow(InterestProfile profile, boolean included, String value) { GridLayout tagLayout = new GridLayout(2, 1); tagLayout.setWidth("100%"); Label labelTagName = new Label(value, ContentMode.HTML); labelTagName.setWidth("100%"); labelTagName.addStyleName(ValoTheme.LABEL_H3); labelTagName.addStyleName(ValoTheme.LABEL_NO_MARGIN); Button buttonDeleteTag = new Button(VaadinIcons.TRASH); buttonDeleteTag.addStyleName(ValoTheme.BUTTON_DANGER); buttonDeleteTag.addClickListener(ev -> { profile.getTags().remove(value); if (included) { includedTagsLayouts.get(profile).removeComponent(tagLayout); } else {// w ww . j a v a 2 s . c o m excludedTagsLayouts.get(profile).removeComponent(tagLayout); } }); tagLayout.addComponents(labelTagName, buttonDeleteTag); tagLayout.setComponentAlignment(labelTagName, Alignment.MIDDLE_LEFT); tagLayout.setComponentAlignment(buttonDeleteTag, Alignment.MIDDLE_RIGHT); tagLayout.setWidth("100%"); tagLayout.setColumnExpandRatio(0, 5); tagLayout.setSpacing(true); tagLayout.setMargin(false); if (included) { includedTagsLayouts.get(profile).addComponent(tagLayout, 2); } else { excludedTagsLayouts.get(profile).addComponent(tagLayout, 2); } }
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()); });/* w ww . j a va 2 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())); }); 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 ava 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; }