List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
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 www . 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.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()); });/* w w w.jav a 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())); }); 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 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 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()); });// ww w . j a v a 2 s . c om } 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 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 ww . j a va2s . 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.NewSourceWindow.java
public Component getFirstStage() { Label header = new Label(Language.get(Word.RSS)); header.addStyleName(ValoTheme.LABEL_H1); FormLayout forms = new FormLayout(); forms.setSizeFull();/*from w ww.j a v a2 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 .ja v a 2s .c o m*/ * @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;// w w w . j a v a2 s . com 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.PreferencesWindow.java
private Component buildSupportTab(User user) { VerticalLayout root = new VerticalLayout(); root.setCaption(Language.get(Word.SUPPORT)); root.setIcon(VaadinIcons.HEADSET);//from ww w . ja va2s . co m root.setWidth("100%"); root.setHeight("100%"); root.setSpacing(true); root.setMargin(true); TextArea textAreaMessage = new TextArea(Language.get(Word.MESSAGE)); textAreaMessage.setWidth("100%"); textAreaMessage.setHeight("100%"); Button buttonSend = new Button(Language.get(Word.SEND), VaadinIcons.ENVELOPE); buttonSend.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSend.addClickListener(ce -> { try { if (emailsSend.containsKey(user)) { Map<LocalDate, Integer> times = emailsSend.get(user); if (times.containsKey(LocalDate.now())) { if (times.get(LocalDate.now()) > 3) { if (times.get(LocalDate.now()) > 15) { UserUtils.banUser(user); VaadinUtils.errorNotification("BANNED DUE TO TOO MUCH EMAILS"); } else { VaadinUtils.errorNotification("TOO MUCH EMAILS"); } return; } else { times.put(LocalDate.now(), times.get(LocalDate.now()) + 1); } } else { times.put(LocalDate.now(), 1); } } else { HashMap<LocalDate, Integer> times = new HashMap<>(); times.put(LocalDate.now(), 1); emailsSend.put(user, times); } Mail.send(Props.get("supportmail"), "SUPPORT", user.toString() + "\n" + textAreaMessage.getValue()); VaadinUtils.middleInfoNotification(Language.get(Word.SUCCESSFULLY_SEND)); textAreaMessage.clear(); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.SEND_FAILED)); Log.error("Could not send Supportmail: ", ex); } }); root.addComponents(textAreaMessage, buttonSend); root.setExpandRatio(textAreaMessage, 5); root.setComponentAlignment(buttonSend, Alignment.MIDDLE_LEFT); return root; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.InitialScreenViewImpl.java
License:Open Source License
public void createImportButton() { importButton = new VerticalLayout(); importButton.setWidth(150, com.vaadin.terminal.Sizeable.UNITS_PIXELS); importButton.setHeight(80, com.vaadin.terminal.Sizeable.UNITS_PIXELS); importButton.setStyleName("topBarButtonContainer"); UploadReceiver receiver = new UploadReceiver(eventBus); Upload upload = new Upload(null, receiver); upload.setButtonCaption(""); upload.setImmediate(true);/* w w w . ja va 2s . c o m*/ upload.addListener(receiver); upload.setStyleName("importButton"); upload.setWidth(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS); upload.setHeight(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS); Label gap = new Label(); gap.setHeight("5px"); Label label = new Label("Projekte"); label.setStyleName("topBarButtonLabel"); label.setSizeUndefined(); Label label2 = new Label("importieren"); label2.setStyleName("topBarButtonLabel"); label2.setSizeUndefined(); VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setHeight(45, com.vaadin.terminal.Sizeable.UNITS_PIXELS); labelLayout.setWidth(100, UNITS_PERCENTAGE); importButton.addComponent(upload); labelLayout.addComponent(label); labelLayout.addComponent(label2); importButton.addComponent(gap); importButton.addComponent(labelLayout); importButton.setComponentAlignment(upload, Alignment.TOP_CENTER); labelLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); labelLayout.setComponentAlignment(label2, Alignment.MIDDLE_CENTER); }