List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout
public HorizontalLayout()
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 w w . ja v a 2s . c o m 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.flatquerybuilder.FlatQueryBuilder.java
License:Apache License
private void launch(QueryController cp) { this.cp = cp; rsc = new ReducingStringComparator(); this.query = ""; mainLayout = new VerticalLayout(); // tracking lists for vertical nodes, edgeboxes and metaboxes vnodes = new ArrayList<>(); eboxes = new ArrayList<>(); mboxes = new ArrayList<>(); spbox = null;//from w w w. j a v a2 s . c om // buttons and checks btGo = new Button(BUTTON_GO_LABEL, (Button.ClickListener) this); btGo.setStyleName(ChameleonTheme.BUTTON_SMALL); btClear = new Button(BUTTON_CLEAR_LABEL, (Button.ClickListener) this); btClear.setStyleName(ChameleonTheme.BUTTON_SMALL); btInverse = new Button(BUTTON_INV_LABEL, (Button.ClickListener) this); btInverse.setStyleName(ChameleonTheme.BUTTON_SMALL); btInitLanguage = new Button("Initialize", (Button.ClickListener) this); btInitLanguage.setDescription(INFO_INIT_LANG); btInitSpan = new Button("Initialize", (Button.ClickListener) this); btInitSpan.setDescription(INFO_INIT_SPAN); btInitMeta = new Button("Initialize", (Button.ClickListener) this); btInitMeta.setDescription(INFO_INIT_META); filtering = new NativeSelect("Filtering mechanisms"); filtering.setDescription(INFO_FILTER); ReducingStringComparator rdc = new ReducingStringComparator(); Set mappings = rdc.getMappings().keySet(); int i; for (i = 0; i < mappings.size(); i++) { String mapname = (String) mappings.toArray()[i]; filtering.addItem(i); filtering.setItemCaption(i, mapname); } filtering.addItem(i + 1); filtering.setItemCaption(i + 1, "generic"); filtering.select(i + 1); filtering.setNullSelectionAllowed(false); filtering.setImmediate(true); // language layout language = new HorizontalLayout(); languagenodes = new HorizontalLayout(); language.addComponent(languagenodes); language.addComponent(btInitLanguage); language.setMargin(true); language.setCaption(LANG_CAPTION); language.addStyleName("linguistics-panel"); // span layout span = new HorizontalLayout(); span.setSpacing(true); span.addComponent(btInitSpan); span.setMargin(true); span.setCaption(SPAN_CAPTION); span.addStyleName("span-panel"); // meta layout meta = new HorizontalLayout(); meta.setSpacing(true); meta.addComponent(btInitMeta); meta.setMargin(true); meta.setCaption(META_CAPTION); meta.addStyleName("meta-panel"); // toolbar layout toolbar = new HorizontalLayout(); toolbar.setSpacing(true); toolbar.addComponent(btGo); toolbar.addComponent(btClear); toolbar.addComponent(btInverse); toolbar.setMargin(true); toolbar.setCaption(TOOLBAR_CAPTION); toolbar.addStyleName("toolbar-panel"); // advanced advanced = new HorizontalLayout(); advanced.setSpacing(true); advanced.addComponent(filtering); advanced.setMargin(true); advanced.setCaption(ADVANCED_CAPTION); advanced.addStyleName("advanced-panel"); // put everything on the layout mainLayout.setSpacing(true); mainLayout.addComponent(language); mainLayout.addComponent(span); mainLayout.addComponent(meta); mainLayout.addComponent(toolbar); mainLayout.addComponent(advanced); setContent(mainLayout); getContent().setWidth("100%"); getContent().setHeight("-1px"); }
From source file:annis.gui.flatquerybuilder.SearchBox.java
License:Apache License
public SearchBox(final String ebene, final FlatQueryBuilder sq, final VerticalNode vn, boolean isRegex, boolean negativeSearch) { this.vn = vn; this.ebene = ebene; this.sq = sq; this.vfs = new ArrayList<>(); vnframe = new VerticalLayout(); vnframe.setSpacing(true);/*from ww w . j a v a2s.c om*/ vnframe.setImmediate(true); this.sb = new VerticalLayout(); //maybe other name? sb is "reserved" by SearchBox sb.setImmediate(true); sb.setSpacing(false); //used to be true lbl = new Label(ebene); HorizontalLayout sbtoolbar = new HorizontalLayout(); sbtoolbar.setSpacing(false); // searchbox tickbox for regex reBox = new CheckBox(CAPTION_REBOX); reBox.setImmediate(true); sbtoolbar.addComponent(reBox); reBox.addValueChangeListener(new ValueChangeListener() { // TODO make this into a nice subroutine @Override public void valueChange(ValueChangeEvent event) { if (reBox.getValue()) { for (ValueField vf : vfs) { String value = vf.getValue(); vf.setValueMode(ValueField.ValueMode.REGEX); if (value != null) { vf.setValue(sq.escapeRegexCharacters(value)); } } } else { for (ValueField vf : vfs) { String value = vf.getValue(); vf.setValueMode(ValueField.ValueMode.NORMAL); if (value != null) { vf.setValue(sq.unescape(value)); } } } } }); reBox.setValue(isRegex); reBox.setEnabled(true); reBoxSingleValue = isRegex; // searchbox tickbox for negative search negSearchBox = new CheckBox(NEGATIVE_SEARCH_LABEL); negSearchBox.setImmediate(true); negSearchBox.setValue(negativeSearch); sbtoolbar.addComponent(negSearchBox); // close the searchbox btClose = new Button(BUTTON_CLOSE_LABEL, (Button.ClickListener) this); btClose.setStyleName(ValoTheme.BUTTON_SMALL); HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setWidth(vnframe.getWidth(), vnframe.getWidthUnits()); titleBar.addComponent(lbl); titleBar.setComponentAlignment(lbl, Alignment.BOTTOM_LEFT); titleBar.addComponent(btClose); titleBar.setComponentAlignment(btClose, Alignment.TOP_RIGHT); btAdd = new Button(LABEL_BUTTON_ADD); btAdd.addClickListener((Button.ClickListener) this); btAdd.setStyleName(ValoTheme.BUTTON_SMALL); vnframe.addComponent(titleBar); vnframe.addComponent(sb); vnframe.addComponent(btAdd); vnframe.setComponentAlignment(btAdd, Alignment.BOTTOM_RIGHT); vnframe.addComponent(sbtoolbar); ValueField vf = new ValueField(sq, this, ebene); vf.setProtected(true); vfs.add(vf); sb.addComponent(vf); setContent(vnframe); }
From source file:annis.gui.flatquerybuilder.SpanBox.java
License:Apache License
public SpanBox(final String ebene, final FlatQueryBuilder sq, boolean isRegex) { this.ebene = ebene; this.sq = sq; sb = new HorizontalLayout(); sb.setImmediate(true);//from w ww. ja va2 s. c o m sb.setSpacing(true); sb.setMargin(true); ConcurrentSkipListSet<String> annos = new ConcurrentSkipListSet<>(); for (String a : sq.getAvailableAnnotationLevels(ebene)) { annos.add(a); } this.annonames = annos; Label tf = new Label(ebene); sb.addComponent(tf); this.cb = new SensitiveComboBox(); cb.setWidth(SB_CB_WIDTH); cb.addStyleName(Helper.CORPUS_FONT_FORCE); // configure & load content cb.setImmediate(true); cb.setNewItemsAllowed(true); cb.setTextInputAllowed(true); for (String annoname : this.annonames) { cb.addItem(annoname); } cb.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_OFF); cb.addListener((FieldEvents.TextChangeListener) this); sb.addComponent(cb); HorizontalLayout sbtoolbar = new HorizontalLayout(); sbtoolbar.setSpacing(true); // searchbox tickbox for regex CheckBox tb = new CheckBox("Regex"); tb.setImmediate(true); tb.setValue(isRegex); sbtoolbar.addComponent(tb); tb.addValueChangeListener(new ValueChangeListener() { // TODO make this into a nice subroutine @Override public void valueChange(ValueChangeEvent event) { boolean r = reBox.getValue(); if (!r) { SpanBox.buildBoxValues(cb, ebene, sq); } else if (cb.getValue() != null) { String escapedItem = sq.escapeRegexCharacters(cb.getValue().toString()); cb.addItem(escapedItem); cb.setValue(escapedItem); } } }); reBox = tb; // close the searchbox btClose = new Button(BUTTON_CLOSE_LABEL, (Button.ClickListener) this); btClose.setStyleName(ChameleonTheme.BUTTON_SMALL); sbtoolbar.addComponent(btClose); // make visable sb.addComponent(sbtoolbar); setContent(sb); }
From source file:annis.gui.flatquerybuilder.ValueField.java
License:Apache License
public ValueField(FlatQueryBuilder sq, SearchBox sb, String level) { /*INIT VALUES*/ this.sq = sq; this.sb = sb; this.level = level; vm = (sb.isRegEx()) ? ValueMode.REGEX : ValueMode.NORMAL; values = new ConcurrentSkipListMap<>(); for (String v : sq.getAvailableAnnotationLevels(level)) { values.put(v, sq.escapeRegexCharacters(v)); }/*from w w w .j a v a 2 s. c o m*/ /*SENSITIVE COMBOBOX*/ scb = new SensitiveComboBox(); scb.setImmediate(true); scb.setNewItemsAllowed(true); scb.setTextInputAllowed(true); scb.setFilteringMode(FilteringMode.OFF); scb.addListener((TextChangeListener) this); scb.setItemCaptionMode(ItemCaptionMode.ID); buildValues(vm); scb.addStyleName(SCB_STYLE_NAME); scb.setWidth(SCB_WIDTH); /*BUTTON*/ bt = new Button(BUTTON_LABEL_REMOVE); bt.addClickListener((Button.ClickListener) this); bt.setStyleName(ChameleonTheme.BUTTON_SMALL); /*HORIZONTAL LAYOUT*/ frame = new HorizontalLayout(); frame.setSpacing(true);//used to be true frame.setCaption(level); /*VISUALIZE*/ frame.addComponent(scb); frame.addComponent(bt); frame.setComponentAlignment(bt, Alignment.BOTTOM_RIGHT); setContent(frame); }
From source file:annis.gui.frequency.FrequencyQueryPanel.java
License:Apache License
public FrequencyQueryPanel(final QueryController controller, QueryUIState state) { this.controller = controller; this.state = state; setWidth("99%"); setHeight("99%"); setMargin(true);//from ww w . j a v a2s.com queryLayout = new VerticalLayout(); queryLayout.setWidth("100%"); queryLayout.setHeight("100%"); HorizontalLayout queryDescriptionLayout = new HorizontalLayout(); queryDescriptionLayout.setSpacing(true); queryDescriptionLayout.setWidth("100%"); queryDescriptionLayout.setHeight("-1px"); queryLayout.addComponent(queryDescriptionLayout); lblCorpusList = new Label(""); lblCorpusList.setCaption("selected corpora:"); lblCorpusList.setWidth("100%"); lblAQL = new Label(""); lblAQL.setCaption("query to analyze:"); lblAQL.setWidth("100%"); lblAQL.addStyleName(Helper.CORPUS_FONT_FORCE); queryDescriptionLayout.addComponent(lblCorpusList); queryDescriptionLayout.addComponent(lblAQL); queryDescriptionLayout.setComponentAlignment(lblCorpusList, Alignment.MIDDLE_LEFT); queryDescriptionLayout.setComponentAlignment(lblAQL, Alignment.MIDDLE_RIGHT); tblFrequencyDefinition = new Table(); tblFrequencyDefinition.setImmediate(true); tblFrequencyDefinition.setSortEnabled(false); tblFrequencyDefinition.setSelectable(true); tblFrequencyDefinition.setMultiSelect(true); tblFrequencyDefinition.setTableFieldFactory(new FieldFactory()); tblFrequencyDefinition.setEditable(true); tblFrequencyDefinition.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (tblFrequencyDefinition.getValue() == null || ((Set<Object>) tblFrequencyDefinition.getValue()).isEmpty()) { btDeleteRow.setEnabled(false); } else { btDeleteRow.setEnabled(true); } } }); lblErrorOrMsg = new Label("No node with explicit name in OR expression found! " + "When using OR expression you need to explicitly name the nodes " + "you want to include in the frequency analysis with \"#\", " + "like e.g. in <br />" + "<pre>" + "(n1#tok=\"fun\" | n1#tok=\"severity\")" + "</pre>"); lblErrorOrMsg.setContentMode(ContentMode.HTML); lblErrorOrMsg.addStyleName("embedded-warning"); lblErrorOrMsg.setWidth("100%"); lblErrorOrMsg.setVisible(false); queryLayout.addComponent(lblErrorOrMsg); tblFrequencyDefinition.setWidth("100%"); tblFrequencyDefinition.setHeight("100%"); tblFrequencyDefinition.setContainerDataSource(state.getFrequencyTableDefinition()); tblFrequencyDefinition.setColumnHeader("nr", "Node number/name"); tblFrequencyDefinition.setColumnHeader("annotation", "Selected annotation of node"); tblFrequencyDefinition.setColumnHeader("comment", "Comment"); tblFrequencyDefinition.addStyleName(Helper.CORPUS_FONT_FORCE); tblFrequencyDefinition.setRowHeaderMode(Table.RowHeaderMode.INDEX); tblFrequencyDefinition.setColumnExpandRatio("nr", 0.15f); tblFrequencyDefinition.setColumnExpandRatio("annotation", 0.35f); tblFrequencyDefinition.setColumnExpandRatio("comment", 0.5f); tblFrequencyDefinition.setVisibleColumns("nr", "annotation", "comment"); queryLayout.addComponent(tblFrequencyDefinition); metaNamesContainer = new IndexedContainer(); PopupTwinColumnSelect metaSelect = new PopupTwinColumnSelect(); metaSelect.setSelectableContainer(metaNamesContainer); metaSelect.setPropertyDataSource(state.getFrequencyMetaData()); metaSelect.setCaption("Metadata"); queryLayout.addComponent(metaSelect); if (controller != null) { createAutomaticEntriesForQuery(state.getAql().getValue()); updateQueryInfo(state.getAql().getValue()); } HorizontalLayout layoutButtons = new HorizontalLayout(); btAdd = new Button("Add"); btAdd.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { cbAutomaticMode.setValue(Boolean.FALSE); int nr = 1; // get the highest number of values from the existing defitions for (Object id : tblFrequencyDefinition.getItemIds()) { String textNr = (String) tblFrequencyDefinition.getItem(id).getItemProperty("nr").getValue(); try { nr = Math.max(nr, Integer.parseInt(textNr)); } catch (NumberFormatException ex) { // was not a number but a named node } } if (controller != null) { List<QueryNode> nodes = parseQuery(FrequencyQueryPanel.this.state.getAql().getValue()); nr = Math.min(nr, nodes.size() - 1); int id = counter++; UserGeneratedFrequencyEntry entry = new UserGeneratedFrequencyEntry(); entry.setAnnotation("tok"); entry.setComment(""); entry.setNr("" + (nr + 1)); FrequencyQueryPanel.this.state.getFrequencyTableDefinition().addItem(id, entry); } } }); layoutButtons.addComponent(btAdd); btDeleteRow = new Button("Delete selected row(s)"); btDeleteRow.setEnabled(false); btDeleteRow.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Set<Object> selected = new HashSet((Set<Object>) tblFrequencyDefinition.getValue()); for (Object o : selected) { cbAutomaticMode.setValue(Boolean.FALSE); tblFrequencyDefinition.removeItem(o); } } }); layoutButtons.addComponent(btDeleteRow); cbAutomaticMode = new CheckBox("Automatic mode", true); cbAutomaticMode.setImmediate(true); cbAutomaticMode.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { btShowFrequencies.setEnabled(true); if (cbAutomaticMode.getValue()) { tblFrequencyDefinition.removeAllItems(); if (controller != null) { createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue()); } } } }); layoutButtons.addComponent(cbAutomaticMode); btReset = new Button("Reset to default"); btReset.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { cbAutomaticMode.setValue(Boolean.TRUE); btShowFrequencies.setEnabled(true); tblFrequencyDefinition.removeAllItems(); if (controller != null) { createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue()); } } }); //layoutButtons.addComponent(btReset); layoutButtons.setComponentAlignment(btAdd, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(btDeleteRow, Alignment.MIDDLE_LEFT); layoutButtons.setComponentAlignment(cbAutomaticMode, Alignment.MIDDLE_RIGHT); layoutButtons.setExpandRatio(btAdd, 0.0f); layoutButtons.setExpandRatio(btDeleteRow, 0.0f); layoutButtons.setExpandRatio(cbAutomaticMode, 1.0f); layoutButtons.setMargin(true); layoutButtons.setSpacing(true); layoutButtons.setHeight("-1px"); layoutButtons.setWidth("100%"); queryLayout.addComponent(layoutButtons); btShowFrequencies = new Button("Perform frequency analysis"); btShowFrequencies.setDisableOnClick(true); btShowFrequencies.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (controller != null) { try { if (resultPanel != null) { removeComponent(resultPanel); } queryLayout.setVisible(false); pbQuery.setCaption("Please wait, the frequencies analysis can take some time"); pbQuery.setIndeterminate(true); pbQuery.setEnabled(true); pbQuery.setVisible(true); controller.executeFrequency(FrequencyQueryPanel.this); } catch (Exception ex) { btShowFrequencies.setEnabled(true); } } } }); queryLayout.addComponent(btShowFrequencies); queryLayout.setComponentAlignment(tblFrequencyDefinition, Alignment.TOP_CENTER); queryLayout.setComponentAlignment(layoutButtons, Alignment.TOP_CENTER); queryLayout.setComponentAlignment(btShowFrequencies, Alignment.TOP_CENTER); queryLayout.setExpandRatio(tblFrequencyDefinition, 1.0f); queryLayout.setExpandRatio(layoutButtons, 0.0f); queryLayout.setExpandRatio(btShowFrequencies, 0.0f); queryLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { Component c = event.getClickedComponent(); if (c instanceof Field) { Object itemID = getField2ItemID().get((Field) c); if (itemID != null) { if (!event.isCtrlKey() && !event.isShiftKey()) { // deselect everything else if no modifier key was clicked tblFrequencyDefinition.setValue(null); } // select the item tblFrequencyDefinition.select(itemID); } } } }); btShowQuery = new Button("New Analysis", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { showQueryDefinitionPanel(); } }); btShowQuery.setVisible(false); pbQuery.setVisible(false); addComponent(pbQuery); addComponent(queryLayout); addComponent(btShowQuery); setComponentAlignment(btShowQuery, Alignment.TOP_CENTER); setComponentAlignment(pbQuery, Alignment.TOP_CENTER); if (controller != null) { state.getSelectedCorpora().addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (cbAutomaticMode.getValue()) { createAutomaticEntriesForQuery(FrequencyQueryPanel.this.state.getAql().getValue()); } updateQueryInfo(FrequencyQueryPanel.this.state.getAql().getValue()); } }); } }
From source file:annis.gui.HelpUsWindow.java
License:Apache License
public HelpUsWindow() { setSizeFull();// w ww . j a v a 2 s . c om layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); layout.setMargin(new MarginInfo(false, false, true, false)); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setMargin(false); VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setMargin(true); labelLayout.setSizeFull(); Label lblOpenSource = new Label(); lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> " + "software.</h1>" + "<p>This means you are free to download the source code and add new " + "features or make other adjustments to ANNIS on your own.<p/>" + "Here are some examples how you can help ANNIS:" + "<ul>" + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>" + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>" + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>"); lblOpenSource.setContentMode(ContentMode.HTML); lblOpenSource.setStyleName("opensource"); lblOpenSource.setWidth("100%"); lblOpenSource.setHeight("-1px"); labelLayout.addComponent(lblOpenSource); Link lnkFork = new Link(); lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS")); lnkFork.setIcon( new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png")); lnkFork.setTargetName("_blank"); hLayout.addComponent(labelLayout); hLayout.addComponent(lnkFork); hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT); hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT); hLayout.setExpandRatio(labelLayout, 1.0f); layout.addComponent(hLayout); final HelpUsWindow finalThis = this; btClose = new Button("Close"); btClose.addClickListener(new OkClickListener(finalThis)); layout.addComponent(btClose); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); layout.setExpandRatio(hLayout, 1.0f); }
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 w w . j a v a2 s .c om 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.paging.PagingComponent.java
License:Apache License
public PagingComponent(int count, int pageSize) { if (pageSize <= 0) { pageSize = 1;/* ww w .j a v a 2 s .c om*/ } if (count < 0) { count = 0; } currentPage = 1; this.count = new AtomicInteger(pageSize); this.pageSize = pageSize; setWidth("100%"); setHeight("-1px"); addStyleName("toolbar"); callbacks = new HashSet<>(); layout = new HorizontalLayout(); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); setContent(layout); addStyleName(ChameleonTheme.PANEL_LIGHT); lblInfo = new Label(); lblInfo.setContentMode(ContentMode.HTML); lblInfo.addStyleName("right-aligned-text"); btShareQuery = new Button(FontAwesome.SHARE_ALT); btShareQuery.setDescription("Share query reference link"); btShareQuery.addStyleName(ValoTheme.BUTTON_BORDERLESS); layout.setWidth("100%"); layout.setHeight("-1px"); btFirst = new Button(); btFirst.setIcon(FIRST); btFirst.setDescription("jump to first page"); btFirst.addClickListener((Button.ClickListener) this); btFirst.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btFirst.addStyleName(ChameleonTheme.BUTTON_SMALL); btFirst.setDisableOnClick(true); btLast = new Button(); btLast.setIcon(LAST); btLast.setDescription("jump to last page"); btLast.addClickListener((Button.ClickListener) this); btLast.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btLast.addStyleName(ChameleonTheme.BUTTON_SMALL); btLast.setDisableOnClick(true); btNext = new Button(); btNext.setIcon(RIGHT_ARROW); btNext.setDescription("jump to next page"); btNext.addClickListener((Button.ClickListener) this); btNext.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btNext.addStyleName(ChameleonTheme.BUTTON_SMALL); btNext.setDisableOnClick(true); btPrevious = new Button(); btPrevious.setIcon(LEFT_ARROW); btPrevious.setDescription("jump to previous page"); btPrevious.addClickListener((Button.ClickListener) this); btPrevious.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btPrevious.addStyleName(ChameleonTheme.BUTTON_SMALL); btPrevious.setDisableOnClick(true); txtPage = new TextField(); txtPage.setDescription("current page"); txtPage.setHeight("-1px"); txtPage.setWidth(5.f, UNITS_EM); Validator pageValidator = new PageValidator("must be an integer greater than zero"); txtPage.addValidator(pageValidator); addActionHandler(new EnterHandler(txtPage)); lblMaxPages = new Label(); lblMaxPages.setDescription("maximal pages"); lblMaxPages.setSizeUndefined(); lblStatus = new Label(); lblStatus.setSizeUndefined(); layout.addComponent(btFirst); layout.addComponent(btPrevious); layout.addComponent(txtPage); layout.addComponent(lblMaxPages); layout.addComponent(btNext); layout.addComponent(btLast); layout.addComponent(lblStatus); layout.addComponent(lblInfo); layout.addComponent(btShareQuery); layout.setComponentAlignment(btFirst, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(btPrevious, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblStatus, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblMaxPages, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(txtPage, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btNext, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btLast, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblStatus, 1.0f); layout.setComponentAlignment(lblInfo, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblInfo, 10.0f); update(false); }
From source file:annis.gui.querybuilder.EdgeWindow.java
License:Apache License
public EdgeWindow(final TigerQueryBuilderCanvas parent, NodeWindow source, NodeWindow target) { this.parent = parent; this.source = source; this.target = target; setSizeFull();//from w w w .java 2 s. c o m // HACK: use our own border since the one from chameleon does not really work addStyleName(ValoTheme.PANEL_BORDERLESS); addStyleName("border-layout"); addStyleName("white-panel"); VerticalLayout vLayout = new VerticalLayout(); setContent(vLayout); vLayout.setMargin(false); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addStyleName("toolbar"); toolbar.setWidth("100%"); toolbar.setHeight("-1px"); vLayout.addComponent(toolbar); Label lblTitle = new Label("AQL Operator"); lblTitle.setWidth("100%"); toolbar.addComponent(lblTitle); toolbar.setComponentAlignment(lblTitle, Alignment.MIDDLE_LEFT); toolbar.setExpandRatio(lblTitle, 1.0f); btClose = new Button(); btClose.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btClose.addStyleName(ValoTheme.BUTTON_SMALL); btClose.setIcon(FontAwesome.TIMES_CIRCLE); btClose.setWidth("-1px"); btClose.addListener((Button.ClickListener) this); toolbar.addComponent(btClose); toolbar.setComponentAlignment(btClose, Alignment.MIDDLE_RIGHT); toolbar.setExpandRatio(btClose, 0.0f); cbOperator = new ComboBox(); cbOperator.setNewItemsAllowed(false); cbOperator.setTextInputAllowed(false); cbOperator.setNullSelectionAllowed(true); cbOperator.addItem(CUSTOM); cbOperator.setItemCaption(CUSTOM, "custom"); cbOperator.setNullSelectionItemId(CUSTOM); cbOperator.setNewItemHandler(new SimpleNewItemHandler(cbOperator)); cbOperator.setImmediate(true); vLayout.addComponent(cbOperator); for (AQLOperator o : AQLOperator.values()) { cbOperator.addItem(o); cbOperator.setItemCaption(o, o.getDescription() + " (" + o.getOp() + ")"); } cbOperator.setValue(AQLOperator.DIRECT_PRECEDENCE); cbOperator.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { Object val = event.getProperty().getValue(); if (val instanceof AQLOperator) { txtOperator.setValue(((AQLOperator) val).getOp()); } } }); cbOperator.setWidth("100%"); cbOperator.setHeight("20px"); txtOperator = new TextField(); txtOperator.setValue("."); txtOperator.setInputPrompt("select operator definition"); txtOperator.setSizeFull(); txtOperator.addValueChangeListener(new OperatorValueChangeListener(parent)); txtOperator.setImmediate(true); vLayout.addComponent(txtOperator); vLayout.setExpandRatio(cbOperator, 1.0f); }