List of usage examples for com.vaadin.ui CssLayout setCaption
@Override public void setCaption(String caption)
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 a v a2 s. co 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:fi.semantum.strategia.Utils.java
License:Open Source License
public static void editTags(final Main main, String title, final Base container) { final Database database = main.getDatabase(); final Window subwindow = new Window(title, new VerticalLayout()); subwindow.setModal(true);// w w w . j a v a 2 s.c o m subwindow.setWidth("400px"); subwindow.setHeight("360px"); subwindow.setResizable(true); VerticalLayout winLayout = (VerticalLayout) subwindow.getContent(); winLayout.setMargin(true); winLayout.setSpacing(true); // Add some content; a label and a close-button final List<String> tags = new ArrayList<String>(); for (Tag t : container.getRelatedTags(database)) tags.add(t.getId(database)); final CssLayout vl = new CssLayout(); vl.setCaption("Kytss olevat aihetunnisteet:"); fillTagEditor(database, vl, tags, Account.canWrite(main, container)); winLayout.addComponent(vl); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); hl.setSpacing(true); final TagCombo combo = new TagCombo(); final CustomLazyContainer comboContainer = new CustomLazyContainer(database, combo, Tag.enumerate(database)); combo.setWidth("100%"); combo.setCaption("Uusi aihetunniste:"); combo.setInputPrompt("valitse listasta tai kirjoita"); combo.setFilteringMode(FilteringMode.STARTSWITH); combo.setTextInputAllowed(true); combo.setImmediate(true); combo.setNullSelectionAllowed(false); combo.setInvalidAllowed(true); combo.setInvalidCommitted(true); combo.setItemCaptionMode(ItemCaptionMode.PROPERTY); combo.setItemCaptionPropertyId("id"); //should set combo.setContainerDataSource(comboContainer); hl.addComponent(combo); hl.setExpandRatio(combo, 1.0f); Button add = new Button("Lis", new Button.ClickListener() { private static final long serialVersionUID = -2848576385076605664L; public void buttonClick(ClickEvent event) { String filter = (String) combo.getValue(); if (filter != null && filter.length() > 0) { Tag t = database.getOrCreateTag(filter); if (tags.contains(t.getId(database))) return; tags.add(t.getId(database)); fillTagEditor(database, vl, tags, main.account != null); combo.clear(); } } }); hl.addComponent(add); hl.setComponentAlignment(add, Alignment.BOTTOM_LEFT); hl.setExpandRatio(add, 0.0f); winLayout.addComponent(hl); Button close = new Button("Tallenna", new Button.ClickListener() { private static final long serialVersionUID = -451523776456589591L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); List<Tag> newTags = new ArrayList<Tag>(); for (String s : tags) newTags.add(database.getOrCreateTag(s)); container.setRelatedTags(database, newTags); Updates.update(main, true); } }); Button discard = new Button("Peru muutokset", new Button.ClickListener() { private static final long serialVersionUID = -2387057110951581993L; public void buttonClick(ClickEvent event) { main.removeWindow(subwindow); } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.addComponent(close); hl2.addComponent(discard); winLayout.addComponent(hl2); winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); main.addWindow(subwindow); }
From source file:org.escidoc.browser.ui.maincontent.SearchAdvancedView.java
License:Open Source License
public SearchAdvancedView(final Router router, final EscidocServiceLocation serviceLocation) { this.router = router; this.serviceLocation = serviceLocation; setWidth("100.0%"); setHeight("85%"); setMargin(true);/* w w w. java 2 s .c om*/ // CssLayout to hold the BreadCrumb final CssLayout cssLayout = new CssLayout(); cssLayout.setWidth("60%"); cssLayout.setCaption("Advanced Search"); // Css Hack * Clear Div final Label lblClear = new Label(); lblClear.setStyleName("clear"); txtTitle = new TextField(); txtTitle.setInputPrompt("Title"); txtTitle.setImmediate(false); txtDescription = new TextField(); txtDescription.setInputPrompt("Description"); txtDescription.setImmediate(false); // Clean Divs cssLayout.addComponent(lblClear); txtCreator = new TextField(); txtCreator.setInputPrompt("Creator"); txtCreator.setImmediate(false); // DatePicker for CreationDate creationDate = new PopupDateField(); creationDate.setInputPrompt("Creation date"); creationDate.setResolution(PopupDateField.RESOLUTION_DAY); creationDate.setImmediate(false); // Dropdown for MimeType final String[] mimetypes = new String[] { "application/octet-stream", "text/html", "audio/aiff", "video/avi", "image/bmp", "application/book", "text/plain", "image/gif", "image/jpeg", "audio/midi", "video/quicktime", "audio/mpeg", "application/xml", "text/xml" }; mimes = new ComboBox(); for (final String mimetype : mimetypes) { mimes.addItem(mimetype); } mimes.setInputPrompt("Mime Types"); mimes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); mimes.setImmediate(true); // Dropdown for Resource Type final String[] resourcearr = new String[] { "Context", "Container", "Item" }; resource = new ComboBox(); for (final String element : resourcearr) { resource.addItem(element); } resource.setInputPrompt("Resource Type"); resource.setFilteringMode(Filtering.FILTERINGMODE_OFF); resource.setImmediate(true); txtFullText = new TextField(); txtFullText.setInputPrompt("FullText"); txtFullText.setImmediate(false); final Button bSearch = new Button("Search", this, "onClick"); bSearch.setDescription("Search Tooltip"); // Placing the elements in the design: txtTitle.setWidth("50%"); txtTitle.setStyleName("floatleft paddingtop20 "); cssLayout.addComponent(txtTitle); txtDescription.setWidth("50%"); txtDescription.setStyleName("floatright paddingtop20 "); cssLayout.addComponent(txtDescription); txtCreator.setWidth("50%"); txtCreator.setStyleName("floatleft paddingtop20"); cssLayout.addComponent(txtCreator); creationDate.setWidth("50%"); creationDate.setStyleName("floatright"); cssLayout.addComponent(creationDate); // Clean Divs cssLayout.addComponent(lblClear); mimes.setWidth("45%"); mimes.setStyleName("floatleft"); cssLayout.addComponent(mimes); resource.setWidth("45%"); resource.setStyleName("floatright"); cssLayout.addComponent(resource); txtFullText.setWidth("70%"); txtFullText.setStyleName("floatleft"); cssLayout.addComponent(txtFullText); bSearch.setStyleName("floatright"); cssLayout.addComponent(bSearch); addComponent(cssLayout); this.setComponentAlignment(cssLayout, VerticalLayout.ALIGNMENT_HORIZONTAL_CENTER, VerticalLayout.ALIGNMENT_VERTICAL_CENTER); }
From source file:org.vaadin.haijian.dynamictabsheet.DynamicTabSheet.java
License:Apache License
@Override public void onAddNewTab() { CssLayout emptyContent = new CssLayout(); emptyContent.setCaption("Empty"); addComponent(emptyContent);// w w w .j a v a2 s. c o m }