List of usage examples for com.vaadin.ui Label setSizeUndefined
@Override public void setSizeUndefined()
From source file:annis.gui.controlpanel.CorpusListPanel.java
License:Apache License
public CorpusListPanel(InstanceConfig instanceConfig, ExampleQueriesPanel autoGenQueries, final AnnisUI ui) { this.instanceConfig = instanceConfig; this.autoGenQueries = autoGenQueries; this.ui = ui; final CorpusListPanel finalThis = this; setSizeFull();/*from w ww . j a v a2 s . com*/ selectionLayout = new HorizontalLayout(); selectionLayout.setWidth("100%"); selectionLayout.setHeight("-1px"); selectionLayout.setVisible(false); Label lblVisible = new Label("Visible: "); lblVisible.setSizeUndefined(); selectionLayout.addComponent(lblVisible); cbSelection = new ComboBox(); cbSelection.setDescription("Choose corpus selection set"); cbSelection.setWidth("100%"); cbSelection.setHeight("-1px"); cbSelection.addStyleName(ValoTheme.COMBOBOX_SMALL); cbSelection.setInputPrompt("Add new corpus selection set"); cbSelection.setNullSelectionAllowed(false); cbSelection.setNewItemsAllowed(true); cbSelection.setNewItemHandler((AbstractSelect.NewItemHandler) this); cbSelection.setImmediate(true); cbSelection.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateCorpusTable(); updateAutoGeneratedQueriesPanel(); } }); selectionLayout.addComponent(cbSelection); selectionLayout.setExpandRatio(cbSelection, 1.0f); selectionLayout.setSpacing(true); selectionLayout.setComponentAlignment(cbSelection, Alignment.MIDDLE_RIGHT); selectionLayout.setComponentAlignment(lblVisible, Alignment.MIDDLE_LEFT); addComponent(selectionLayout); txtFilter = new TextField(); txtFilter.setVisible(false); txtFilter.setInputPrompt("Filter"); txtFilter.setImmediate(true); txtFilter.setTextChangeTimeout(500); txtFilter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { BeanContainer<String, AnnisCorpus> availableCorpora = ui.getQueryState().getAvailableCorpora(); if (textFilter != null) { // remove the old filter availableCorpora.removeContainerFilter(textFilter); textFilter = null; } if (event.getText() != null && !event.getText().isEmpty()) { Set<String> selectedIDs = ui.getQueryState().getSelectedCorpora().getValue(); textFilter = new SimpleStringFilter("name", event.getText(), true, false); availableCorpora.addContainerFilter(textFilter); // select the first item List<String> filteredIDs = availableCorpora.getItemIds(); Set<String> selectedAndFiltered = new HashSet<>(selectedIDs); selectedAndFiltered.retainAll(filteredIDs); Set<String> selectedAndOutsideFilter = new HashSet<>(selectedIDs); selectedAndOutsideFilter.removeAll(filteredIDs); for (String id : selectedAndOutsideFilter) { tblCorpora.unselect(id); } if (selectedAndFiltered.isEmpty() && !filteredIDs.isEmpty()) { for (String id : selectedIDs) { tblCorpora.unselect(id); } tblCorpora.select(filteredIDs.get(0)); } } } }); txtFilter.setWidth("100%"); txtFilter.setHeight("-1px"); txtFilter.addStyleName(ValoTheme.TEXTFIELD_SMALL); addComponent(txtFilter); pbLoadCorpora = new ProgressBar(); pbLoadCorpora.setCaption("Loading corpus list..."); pbLoadCorpora.setIndeterminate(true); addComponent(pbLoadCorpora); tblCorpora = new Table(); addComponent(tblCorpora); tblCorpora.setVisible(false); // don't show list before it was not loaded tblCorpora.setContainerDataSource(ui.getQueryState().getAvailableCorpora()); tblCorpora.setMultiSelect(true); tblCorpora.setPropertyDataSource(ui.getQueryState().getSelectedCorpora()); tblCorpora.addGeneratedColumn("info", new InfoGenerator()); tblCorpora.addGeneratedColumn("docs", new DocLinkGenerator()); tblCorpora.setVisibleColumns("name", "textCount", "tokenCount", "info", "docs"); tblCorpora.setColumnHeaders("Name", "Texts", "Tokens", "", ""); tblCorpora.setHeight("100%"); tblCorpora.setWidth("100%"); tblCorpora.setSelectable(true); tblCorpora.setNullSelectionAllowed(false); tblCorpora.setColumnExpandRatio("name", 0.6f); tblCorpora.setColumnExpandRatio("textCount", 0.15f); tblCorpora.setColumnExpandRatio("tokenCount", 0.25f); tblCorpora.addStyleName(ValoTheme.TABLE_SMALL); tblCorpora.addActionHandler((Action.Handler) this); tblCorpora.setImmediate(true); tblCorpora.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Set selections = (Set) tblCorpora.getValue(); if (selections.size() == 1 && event.isCtrlKey() && tblCorpora.isSelected(event.getItemId())) { tblCorpora.setValue(null); } } }); tblCorpora.setItemDescriptionGenerator(new TooltipGenerator()); tblCorpora.addValueChangeListener(new CorpusTableChangedListener(finalThis)); Button btReload = new Button(); btReload.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { updateCorpusSetList(false, false); Notification.show("Reloaded corpus list", Notification.Type.HUMANIZED_MESSAGE); } }); btReload.setIcon(FontAwesome.REFRESH); btReload.setDescription("Reload corpus list"); btReload.addStyleName(ValoTheme.BUTTON_ICON_ONLY); selectionLayout.addComponent(btReload); selectionLayout.setComponentAlignment(btReload, Alignment.MIDDLE_RIGHT); tblCorpora.setSortContainerPropertyId("name"); setExpandRatio(tblCorpora, 1.0f); updateCorpusSetList(true, true); }
From source file:annis.gui.CorpusBrowserPanel.java
License:Apache License
/** * Places a label with the text "(No <caption>)" in the centered middle of the accordion * tab./*from w ww .j ava 2 s. co m*/ * * @param accordion the target accordion * @param caption is set as caption of the accordion tab */ private void placeEmptyLabel(Accordion accordion, String caption) { VerticalLayout v = new VerticalLayout(); v.setSizeFull(); Label l = new Label("(No " + caption + ")"); v.addComponent(l); l.setSizeUndefined(); v.setComponentAlignment(l, Alignment.MIDDLE_CENTER); accordion.addTab(v, caption, null); l.setSizeUndefined(); }
From source file:annis.gui.MetaDataPanel.java
License:Apache License
public MetaDataPanel(String toplevelCorpusName, String documentName) { super("Metadata"); this.toplevelCorpusName = toplevelCorpusName; this.documentName = documentName; setSizeFull();/*w ww. j a va 2s . co m*/ layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); if (documentName == null) { docs = getAllSubcorpora(toplevelCorpusName); HorizontalLayout selectionLayout = new HorizontalLayout(); Label selectLabel = new Label("Select corpus/document: "); corpusSelection = new ComboBox(); selectionLayout.addComponents(selectLabel, corpusSelection); layout.addComponent(selectionLayout); selectLabel.setSizeUndefined(); corpusSelection.setWidth(100, Unit.PERCENTAGE); corpusSelection.setHeight("-1px"); corpusSelection.addValueChangeListener(MetaDataPanel.this); selectionLayout.setWidth(100, Unit.PERCENTAGE); selectionLayout.setHeight("-1px"); selectionLayout.setSpacing(true); selectionLayout.setComponentAlignment(selectLabel, Alignment.MIDDLE_LEFT); selectionLayout.setComponentAlignment(corpusSelection, Alignment.MIDDLE_LEFT); selectionLayout.setExpandRatio(selectLabel, 0.4f); selectionLayout.setExpandRatio(corpusSelection, 0.6f); corpusSelection.addItem(toplevelCorpusName); corpusSelection.select(toplevelCorpusName); corpusSelection.setNullSelectionAllowed(false); corpusSelection.setImmediate(true); for (Annotation c : docs) { corpusSelection.addItem(c.getName()); } } else { Map<Integer, List<Annotation>> hashMData = splitListAnnotations(); List<BeanItemContainer<Annotation>> l = putInBeanContainer(hashMData); Accordion accordion = new Accordion(); accordion.setSizeFull(); // set output to none if no metadata are available if (l.isEmpty()) { addEmptyLabel(); } else { for (BeanItemContainer<Annotation> item : l) { String corpusName = item.getIdByIndex(0).getCorpusName(); String path = toplevelCorpusName.equals(corpusName) ? "corpus: " + corpusName : "document: " + corpusName; if (item.getItemIds().isEmpty()) { accordion.addTab(new Label("none"), path); } else { accordion.addTab(setupTable(item), path); } } layout.addComponent(accordion); } } }
From source file:annis.gui.resultview.SingleResultPanel.java
License:Apache License
public SingleResultPanel(final SDocument result, Match match, long resultNumber, ResolverProvider resolverProvider, PluginSystem ps, AnnisUI ui, Set<String> visibleTokenAnnos, String segmentationName, QueryController controller, InstanceConfig instanceConfig, DisplayedResultQuery query) {/*from ww w. j a va2 s. c o m*/ this.ps = ps; this.ui = ui; this.result = result; this.segmentationName = segmentationName; this.queryController = controller; this.resultNumber = resultNumber; this.resolverProvider = resolverProvider; this.visibleTokenAnnos = visibleTokenAnnos; this.instanceConfig = instanceConfig; this.query = query; this.match = match; calculateHelperVariables(); setWidth("100%"); setHeight("-1px"); if (query != null && query.getSelectedMatches().contains(resultNumber)) { addStyleName("selected-match"); } infoBar = new HorizontalLayout(); infoBar.addStyleName("info-bar"); infoBar.setWidth("100%"); infoBar.setHeight("-1px"); Label lblNumber = new Label("" + (resultNumber + 1)); infoBar.addComponent(lblNumber); lblNumber.setSizeUndefined(); btInfo = new Button(); btInfo.setStyleName(ValoTheme.BUTTON_BORDERLESS); btInfo.setIcon(ICON_RESOURCE); btInfo.setDescription("Show metadata"); btInfo.addClickListener((Button.ClickListener) this); infoBar.addComponent(btInfo); btLink = new Button(); btLink.setStyleName(ValoTheme.BUTTON_BORDERLESS); btLink.setIcon(FontAwesome.SHARE_ALT); btLink.setDescription("Share match reference"); btLink.setDisableOnClick(true); btLink.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { showShareSingleMatchGenerator(); } }); infoBar.addComponent(btLink); /** * Extract the top level corpus name and the document name of this single * result. */ path = CommonHelper.getCorpusPath(result.getGraph(), result); Collections.reverse(path); corpusName = path.get(0); documentName = path.get(path.size() - 1); MinMax minMax = getIds(result.getDocumentGraph()); // build label StringBuilder sb = new StringBuilder("Path: "); sb.append(StringUtils.join(path, " > ")); sb.append(" (" + minMax.segName + " ").append(minMax.min); sb.append(" - ").append(minMax.max).append(")"); Label lblPath = new Label(sb.toString()); lblPath.addStyleName("path-label"); lblPath.setWidth("100%"); lblPath.setHeight("-1px"); infoBar.addComponent(lblPath); infoBar.setExpandRatio(lblPath, 1.0f); infoBar.setSpacing(false); this.visualizerState = new HashMap<>(); // init context combox lftCtxCombo = new ComboBox(); rghtCtxCombo = new ComboBox(); lftCtxCombo.setWidth(50, Unit.PIXELS); rghtCtxCombo.setWidth(50, Unit.PIXELS); lftCtxCombo.setNullSelectionAllowed(false); rghtCtxCombo.setNullSelectionAllowed(false); lftCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL); rghtCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL); IndexedContainer lftCtxContainer = new IndexedContainer(); IndexedContainer rghtCtxContainer = new IndexedContainer(); // and a property for sorting lftCtxContainer.addContainerProperty("number", Integer.class, 0); rghtCtxContainer.addContainerProperty("number", Integer.class, 0); for (int i = 0; i < 30; i += 5) { lftCtxContainer.addItem(i).getItemProperty("number").setValue(i); rghtCtxContainer.addItem(i).getItemProperty("number").setValue(i); } int lftContextIdx = query == null ? 0 : query.getLeftContext(); lftCtxContainer.addItemAt(lftContextIdx, lftContextIdx); lftCtxContainer.sort(new Object[] { "number" }, new boolean[] { true }); int rghtCtxIdx = query == null ? 0 : query.getRightContext(); rghtCtxContainer.addItem(rghtCtxIdx); rghtCtxContainer.sort(new Object[] { "number" }, new boolean[] { true }); lftCtxCombo.setContainerDataSource(lftCtxContainer); rghtCtxCombo.setContainerDataSource(rghtCtxContainer); lftCtxCombo.select(lftContextIdx); rghtCtxCombo.select(rghtCtxIdx); lftCtxCombo.setNewItemsAllowed(true); rghtCtxCombo.setNewItemsAllowed(true); lftCtxCombo.setImmediate(true); rghtCtxCombo.setImmediate(true); lftCtxCombo.setNewItemHandler(new AddNewItemHandler(lftCtxCombo)); rghtCtxCombo.setNewItemHandler(new AddNewItemHandler(rghtCtxCombo)); lftCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, true)); rghtCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, false)); Label leftCtxLabel = new Label("left context: "); Label rightCtxLabel = new Label("right context: "); leftCtxLabel.setWidth("-1px"); rightCtxLabel.setWidth("-1px"); HorizontalLayout ctxLayout = new HorizontalLayout(); ctxLayout.setSpacing(true); ctxLayout.addComponents(leftCtxLabel, lftCtxCombo, rightCtxLabel, rghtCtxCombo); infoBar.addComponent(ctxLayout); addComponent(infoBar); initVisualizer(); }
From source file:annis.visualizers.htmlvis.HTMLVis.java
License:Apache License
@Override public Panel createComponent(VisualizerInput vi, VisualizationToggle vt) { Panel scrollPanel = new Panel(); scrollPanel.setSizeFull();//from w w w.j av a 2 s . c o m Label lblResult = new Label("ERROR", ContentMode.HTML); lblResult.setSizeUndefined(); List<String> corpusPath = CommonHelper.getCorpusPath(vi.getDocument().getGraph(), vi.getDocument()); String corpusName = corpusPath.get(corpusPath.size() - 1); corpusName = urlPathEscape.escape(corpusName); String wrapperClassName = "annis-wrapped-htmlvis-" + corpusName.replaceAll("[^0-9A-Za-z-]", "_"); scrollPanel.addStyleName(wrapperClassName); String visConfigName = vi.getMappings().getProperty("config"); String hitMarkConfig = vi.getMappings().getProperty("hitmark", "true"); hitMark = Boolean.parseBoolean(hitMarkConfig); mc = vi.getMarkedAndCovered(); VisualizationDefinition[] definitions = parseDefinitions(corpusName, vi.getMappings()); if (definitions != null) { lblResult.setValue(createHTML(vi.getSResult().getDocumentGraph(), definitions)); String labelClass = vi.getMappings().getProperty("class", "htmlvis"); lblResult.addStyleName(labelClass); InputStream inStreamCSSRaw = null; if (visConfigName == null) { inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css"); } else { WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName) .path(corpusName).path("binary").path(visConfigName + ".css"); ClientResponse response = resBinary.get(ClientResponse.class); if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) { inStreamCSSRaw = response.getEntityInputStream(); } } if (inStreamCSSRaw != null) { try (InputStream inStreamCSS = inStreamCSSRaw) { String cssContent = IOUtils.toString(inStreamCSS); UI currentUI = UI.getCurrent(); if (currentUI instanceof AnnisBaseUI) { // do not add identical CSS files ((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName); } } catch (IOException ex) { log.error("Could not parse the HTML visualizer CSS file", ex); Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(), Notification.Type.ERROR_MESSAGE); } } } if (vi.getMappings().containsKey("debug")) { TextArea txtDebug = new TextArea(); txtDebug.setValue(lblResult.getValue()); txtDebug.setReadOnly(true); txtDebug.setWidth("100%"); Label sep = new Label("<hr/>", ContentMode.HTML); VerticalLayout layout = new VerticalLayout(txtDebug, sep, lblResult); layout.setSizeUndefined(); scrollPanel.setContent(layout); } else { scrollPanel.setContent(lblResult); } return scrollPanel; }
From source file:at.peppol.webgui.app.MainWindow.java
License:Mozilla Public License
@SuppressWarnings("unused") private void createTopBar() { topBarCSSLayout.setStyleName("toolbar"); topBarCSSLayout.setSizeFull();//from w w w . j a v a 2 s. c o m topBarLayout.setMargin(false, true, false, true); topBarLayout.setSizeFull(); topBarLayoutLeft = new HorizontalLayout(); topBarLayoutRight = new HorizontalLayout(); final Label pawgLabel = new Label("PAWG"); pawgLabel.setStyleName("h1"); pawgLabel.setSizeUndefined(); topBarLayoutLeft.addComponent(pawgLabel); final HorizontalLayout segBtns = createTopBarButtons(); topBarLayoutLeft.addComponent(segBtns); // IUser user = (IUser) PawgApp.getInstance().getUser(); final Label loggedInLabel = new Label("Test User"); loggedInLabel.setSizeUndefined(); topBarLayoutRight.addComponent(loggedInLabel); topBarLayoutRight.setComponentAlignment(loggedInLabel, Alignment.MIDDLE_RIGHT); topBarLayoutLeft.setComponentAlignment(segBtns, Alignment.MIDDLE_CENTER); topBarLayoutLeft.setSpacing(true); topBarLayout.addComponent(topBarLayoutLeft); topBarLayout.addComponent(topBarLayoutRight); topBarLayout.setComponentAlignment(topBarLayoutRight, Alignment.MIDDLE_RIGHT); topBarLayout.setExpandRatio(topBarLayoutLeft, 1); topBarLayout.setExpandRatio(topBarLayoutRight, 1); topBarCSSLayout.addComponent(topBarLayout); addComponent(topBarCSSLayout); }
From source file:be.rvponp.build.CommitViewerUI.java
License:Apache License
private HorizontalLayout createBuildDateLayout() { HorizontalLayout buildDateLayout = new HorizontalLayout(); Label labelBuildDate = new Label("Build date: " + getBuildDate()); buildDateLayout.addComponent(labelBuildDate); labelBuildDate.setSizeUndefined(); buildDateLayout.setSizeUndefined();//from ww w . ja v a 2s . c o m return buildDateLayout; }
From source file:by.bigvova.ui.LoginUI.java
License:Apache License
private Component buildLabels() { CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label welcome = new Label("Welcome"); welcome.setSizeUndefined(); welcome.addStyleName(ValoTheme.LABEL_H4); welcome.addStyleName(ValoTheme.LABEL_COLORED); labels.addComponent(welcome);//from www. ja v a2 s. com Label title = new Label("QuickTickets Dashboard"); title.setSizeUndefined(); title.addStyleName(ValoTheme.LABEL_H3); title.addStyleName(ValoTheme.LABEL_LIGHT); labels.addComponent(title); return labels; }
From source file:ch.wscr.management.ui.view.MemberView.java
/** * Header der View erstellen/* w w w. j a v a 2s.c om*/ * * @return der Header */ private Component buidViewHeader() { HorizontalLayout header = new HorizontalLayout(); header.setWidth(100f, Unit.PERCENTAGE); header.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); header.setSpacing(true); Label title = new Label("Mitgliederverwaltung"); title.setSizeUndefined(); title.addStyleName(ValoTheme.LABEL_H1); header.addComponent(title); Label gap = new Label(); gap.setWidth(10, Unit.PIXELS); header.addComponent(gap); header.setExpandRatio(title, 1); return header; }
From source file:com.adonis.ui.menu.Menu.java
public Menu(PersonService personService, VehicleService vehicleService, Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); setPersonsCrudProperties(personService); setVehiclesCrudProperties(vehicleService); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);//from ww w.j a va 2 s. co m Label title = new Label("Vehicle manager"); title.addStyleName(ValoTheme.LABEL_H1); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/car.png")); image.setStyleName(ValoTheme.MENU_LOGO); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item // HorizontalLayout logoutLayout = new HorizontalLayout(); // logoutLayout.addStyleName(ValoTheme.MENU_ITEM); // logoutLayout.setSpacing(false); // // MenuBar logoutMenu = new MenuBar(); // logoutMenu.setStyleName(VALO_MENUITEMS); // logoutMenu.addItem("Logout", new MenuBar.Command() { // // @Override // public void menuSelected(MenuBar.MenuItem selectedItem) { // VaadinSession.getCurrent().getSession().invalidate(); // Page.getCurrent().reload(); // } // }); // // logoutMenu.addStyleName("user-menu"); // Image logout = new Image(null, new ThemeResource("img/logout.png")); // logoutLayout.addComponent(logout, 0); // logoutLayout.addComponent(logoutMenu, 1); // menuPart.addComponent(logoutLayout); // button for toggling the visibility of the menu when on a small screen showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); // showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); addStyleName("backImage"); }