List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
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 .j a v a 2s . 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 = 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.GroupView.java
private void refreshProfiles(Group g, Layout layoutProfiles) { layoutProfiles.removeAllComponents(); GroupUtils.getAllInterestProfiles(g, UserUtils.getCurrent()).forEach((p, enabled) -> { HorizontalLayout layoutProfile = new HorizontalLayout(); layoutProfile.setWidth("100%"); CheckBox checkBoxEnabled = new CheckBox(); checkBoxEnabled.setValue(enabled); checkBoxEnabled.addValueChangeListener(v -> { GroupInterestProfileUtils.changeEnabled(p, UserUtils.getCurrent(), v.getValue()); refreshAll(g);/*from w w w . ja va 2s .co m*/ }); long subscribers = p.getEnabledUsers().values().stream().filter(v -> v).count(); Label labelProfileInfo = new Label(); Language.setCustom(Word.SUBSCRIBERS, s -> { String info = p.getName() + " (" + subscribers + " "; info += subscribers == 1 ? Language.get(Word.SUBSCRIBER) + ")" : Language.get(Word.SUBSCRIBERS) + ")"; labelProfileInfo.setValue(info); }); boolean isAdmin = g.getUsers().getOrDefault(UserUtils.getCurrent(), false); Button buttonOpen = new Button(VaadinIcons.EXTERNAL_LINK); buttonOpen.addClickListener(ce -> { UI.getCurrent().addWindow(GroupProfileWindow.show(p, isAdmin, () -> { })); }); if (isAdmin) { Button buttonRemove = new Button(VaadinIcons.MINUS); buttonRemove.addStyleName(ValoTheme.BUTTON_DANGER); buttonRemove.addClickListener(ce -> { ConfirmationDialog.show( Language.get(Word.REALLY_DELETE_PROFILE).replace("[PROFILE]", p.getName()), () -> { GroupInterestProfileUtils.delete(p); refreshAll(g); }); }); layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen, buttonRemove); } else { layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen); } layoutProfile.setExpandRatio(labelProfileInfo, 5); layoutProfile.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER); layoutProfile.setComponentAlignment(labelProfileInfo, Alignment.MIDDLE_LEFT); layoutProfiles.addComponent(layoutProfile); }); }
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);/*from w ww.ja va 2 s . co 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 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 -> {/*from w ww . j a v a2 s . com*/ 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
public Component getTags(InterestProfile profile) { 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)); Component addIncludeTagGroup = getAddTagGroup(profile, true); includedTagsLayout.addComponents(labelIncludedTags, addIncludeTagGroup); includedTagsLayout.setComponentAlignment(labelIncludedTags, Alignment.MIDDLE_CENTER); includedTagsLayout.setComponentAlignment(addIncludeTagGroup, 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)); Component addExcludeTagGroup = getAddTagGroup(profile, false); excludedTagsLayout.addComponents(labelExcludedTags, addExcludeTagGroup); excludedTagsLayout.setComponentAlignment(labelExcludedTags, Alignment.MIDDLE_CENTER); excludedTagsLayout.setComponentAlignment(addExcludeTagGroup, Alignment.MIDDLE_CENTER); profile.getTags().forEach((tag, included) -> addRow(profile, included, tag)); allTagsLayout.addComponents(includedTagsLayout, excludedTagsLayout); allTagsLayout.setWidth("100%"); return allTagsPanel; }
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 -> {//from ww w. j av a 2s.com 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 {/* ww w. j a v a2 s . co 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.NewSourceWindow.java
public Component getThirdStage(Source s) { Label header = new Label(Language.get(Word.CRAWLER)); header.addStyleName(ValoTheme.LABEL_H1); Crawler crawler;/*w ww. j av a 2 s .c om*/ 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
/** * Value is optional//from w ww . j a v a 2 s . c o m * * @param action * @param content * @param value * @return */ private Component getRow(Layout parent, Runnable onDelete, String action, String content, String value) { Panel panelRow = new Panel(); GridLayout layoutRow = new GridLayout(2, 1); Label labelInfo = new Label("", ContentMode.HTML); String stringInfo = action.toUpperCase() + "<br>"; if (value != null) { stringInfo += content + " = " + value; } else { stringInfo += content + " "; } labelInfo.setValue(stringInfo); Button buttonDelete = new Button(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { onDelete.run(); parent.removeComponent(panelRow); }); layoutRow.addComponents(labelInfo, buttonDelete); layoutRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_RIGHT); layoutRow.setComponentAlignment(labelInfo, Alignment.MIDDLE_LEFT); layoutRow.setWidth("100%"); layoutRow.setMargin(true); layoutRow.addStyleName("crawler"); panelRow.setContent(layoutRow); panelRow.setWidth("100%"); return panelRow; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.InitialScreenViewImpl.java
License:Open Source License
public void setPageDescription(String source, String page, String[] description) { int labelCount = descriptionLayout.getComponentCount(); Label oldLabel; int i;/*from www .j a v a 2 s.c o m*/ homeIcon.setSource(new ThemeResource(source)); seitenLabel.setValue(page); for (i = 0; i < labelCount && i < description.length; i++) { oldLabel = (Label) descriptionLayout.getComponent(i); oldLabel.setValue(description[i]); if (i == 0) { descriptionLayout.setComponentAlignment(oldLabel, Alignment.BOTTOM_CENTER); } else { descriptionLayout.setComponentAlignment(oldLabel, Alignment.TOP_CENTER); } } // descriptionLabel.setValue(description[0]); for (int a = i; a < description.length; a++) { Label newLabel = new Label(description[a]); newLabel.setStyleName("descriptionLabel"); newLabel.setWidth(Sizeable.SIZE_UNDEFINED, 0); descriptionLayout.addComponent(newLabel); descriptionLayout.setComponentAlignment(newLabel, Alignment.TOP_CENTER); } for (int b = i; b < labelCount; b++) { descriptionLayout.removeComponent(descriptionLayout.getComponent(b)); } }