List of usage examples for com.vaadin.ui HorizontalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:adminviews.MCCView.java
License:Open Source License
public MCCView(IOpenBisClient openbis, OpenbisCreationController creationController, String user) { this.openbis = openbis; this.creator = creationController; this.user = user; this.cases = new HashSet<String>(); this.patients = new ArrayList<String>(); mccProjects = new ComboBox("Source Project"); List<String> projects = new ArrayList<String>(); for (Project p : openbis.getProjectsOfSpace(mccSpace)) projects.add(p.getCode());/*from w ww.ja va2 s . c o m*/ mccProjects.addStyleName(Styles.boxTheme); mccProjects.addItems(projects); mccProjects.setImmediate(true); newProject = new StandardTextField("New Project"); newProject.setImmediate(true); newProject.setWidth("80px"); HorizontalLayout projectTab = new HorizontalLayout(); projectTab.setSpacing(true); projectTab.addComponent(mccProjects); projectTab.addComponent(newProject); treatment = new StandardTextField("Treatment"); timepoint = new StandardTextField("Timepoint"); timepoint.setWidth("40px"); patient = new StandardTextField("Patient #"); patient.setWidth("50px"); HorizontalLayout paramTab = new HorizontalLayout(); paramTab.setSpacing(true); paramTab.addComponent(treatment); paramTab.addComponent(patient); paramTab.addComponent(timepoint); existingPatients = new Table("Existing Patients"); existingPatients.setStyleName(Styles.tableTheme); existingPatients.setPageLength(1); editView = new TabSheet(); editView.addStyleName(ValoTheme.TABSHEET_FRAMED); samples = new Table("Samples"); samples.setStyleName(Styles.tableTheme); samples.setPageLength(1); metaData = new Table(); metaData.setEditable(true); metaData.setStyleName(Styles.tableTheme); editView.addTab(samples, "Overview"); editView.addTab(metaData, "Change Metadata"); editView.setVisible(false); registerInfo = new Label(); bar = new ProgressBar(); addSamples = new Button("Add Samples"); addSamples.setEnabled(false); initMCCListeners(); addComponent(Styles.questionize(projectTab, "Samples can only be added if Timepoint, Treatment, Project and Patient Number " + "are filled in and they don't already exist in the current project. E.g. you can add a new timepoint for the same patient and " + "treatment but not the same timepoint.", "Adding new Samples")); addComponent(paramTab); addComponent(existingPatients); addComponent(editView); addComponent(registerInfo); addComponent(bar); addComponent(addSamples); }
From source file:annis.gui.admin.ImportPanel.java
License:Apache License
public ImportPanel() { setSizeFull();/* w w w. ja v a2s.c o m*/ layout = new VerticalLayout(); layout.setWidth("100%"); layout.setHeight("100%"); layout.setMargin(true); setContent(layout); FormLayout form = new FormLayout(); layout.addComponent(form); cbOverwrite = new CheckBox("Overwrite existing corpus"); form.addComponent(cbOverwrite); txtMail = new TextField("e-mail address for status updates"); txtMail.addValidator(new EmailValidator("Must be a valid e-mail address")); form.addComponent(txtMail); txtAlias = new TextField("alias name"); form.addComponent(txtAlias); HorizontalLayout actionBar = new HorizontalLayout(); actionBar.setSpacing(true); actionBar.setWidth("100%"); upload = new Upload("", this); upload.setButtonCaption("Upload ZIP file with relANNIS corpus and start import"); upload.setImmediate(true); upload.addStartedListener(this); upload.addFinishedListener(this); upload.setEnabled(true); actionBar.addComponent(upload); progress = new ProgressBar(); progress.setIndeterminate(true); progress.setVisible(false); actionBar.addComponent(progress); lblProgress = new Label(); lblProgress.setWidth("100%"); actionBar.addComponent(lblProgress); actionBar.setExpandRatio(lblProgress, 1.0f); actionBar.setComponentAlignment(lblProgress, Alignment.MIDDLE_LEFT); actionBar.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); actionBar.setComponentAlignment(progress, Alignment.MIDDLE_LEFT); layout.addComponent(actionBar); btDetailedLog = new Button(); btDetailedLog.setStyleName(BaseTheme.BUTTON_LINK); btDetailedLog.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setLogVisible(!isLogVisible()); } }); layout.addComponent(btDetailedLog); txtMessages = new TextArea(); txtMessages.setSizeFull(); txtMessages.setValue(""); txtMessages.setReadOnly(true); layout.addComponent(txtMessages); layout.setExpandRatio(txtMessages, 1.0f); setLogVisible(false); appendMessage("Ready."); }
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);/* w w w .jav a 2 s . com*/ 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 w w. ja v a 2 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.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);/*ww w .j a v a 2s.c o m*/ 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.MetaDataPanel.java
License:Apache License
public MetaDataPanel(String toplevelCorpusName, String documentName) { super("Metadata"); this.toplevelCorpusName = toplevelCorpusName; this.documentName = documentName; setSizeFull();//from w w w .j ava2 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.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 . jav a 2s . c om 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.gui.SearchUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { super.init(request); this.instanceConfig = getInstanceConfig(request); getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)"); queryController = new QueryController(this); refresh = new Refresher(); // deactivate refresher by default refresh.setRefreshInterval(-1);//w ww . java2s.com refresh.addListener(queryController); addExtension(refresh); // always get the resize events directly setImmediate(true); VerticalLayout mainLayout = new VerticalLayout(); setContent(mainLayout); mainLayout.setSizeFull(); mainLayout.setMargin(false); final ScreenshotMaker screenshot = new ScreenshotMaker(this); addExtension(screenshot); css = new CSSInject(this); HorizontalLayout layoutToolbar = new HorizontalLayout(); layoutToolbar.setWidth("100%"); layoutToolbar.setHeight("-1px"); mainLayout.addComponent(layoutToolbar); layoutToolbar.addStyleName("toolbar"); layoutToolbar.addStyleName("border-layout"); Button btAboutAnnis = new Button("About ANNIS"); btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL); btAboutAnnis.setIcon(new ThemeResource("info.gif")); btAboutAnnis.addClickListener(new AboutClickListener()); btBugReport = new Button("Report Bug"); btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL); btBugReport.setDisableOnClick(true); btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png")); btBugReport.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { screenshot.makeScreenshot(); btBugReport.setCaption("bug report is initialized..."); } }); String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail"); if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${") && new EmailValidator("").isValid(bugmail)) { this.bugEMailAddress = bugmail; } btBugReport.setVisible(this.bugEMailAddress != null); lblUserName = new Label("not logged in"); lblUserName.setWidth("-1px"); lblUserName.setHeight("-1px"); lblUserName.addStyleName("right-aligned-text"); btLoginLogout = new Button("Login", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (isLoggedIn()) { // logout Helper.setUser(null); Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION); updateUserInformation(); } else { showLoginWindow(); } } }); btLoginLogout.setSizeUndefined(); btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL); btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png")); Button btOpenSource = new Button("Help us to make ANNIS better!"); btOpenSource.setStyleName(BaseTheme.BUTTON_LINK); btOpenSource.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Window w = new HelpUsWindow(); w.setCaption("Help us to make ANNIS better!"); w.setModal(true); w.setResizable(true); w.setWidth("600px"); w.setHeight("500px"); addWindow(w); w.center(); } }); layoutToolbar.addComponent(btAboutAnnis); layoutToolbar.addComponent(btBugReport); layoutToolbar.addComponent(btOpenSource); layoutToolbar.addComponent(lblUserName); layoutToolbar.addComponent(btLoginLogout); layoutToolbar.setSpacing(true); layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER); layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT); layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT); layoutToolbar.setExpandRatio(btOpenSource, 1.0f); //HorizontalLayout hLayout = new HorizontalLayout(); final HorizontalSplitPanel hSplit = new HorizontalSplitPanel(); hSplit.setSizeFull(); mainLayout.addComponent(hSplit); mainLayout.setExpandRatio(hSplit, 1.0f); AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this); controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries); controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE); controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE); hSplit.setFirstComponent(controlPanel); tutorial = new TutorialPanel(); tutorial.setHeight("99%"); mainTab = new TabSheet(); mainTab.setSizeFull(); mainTab.addTab(autoGenQueries, "example queries"); mainTab.addTab(tutorial, "Tutorial"); queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig); mainTab.addTab(queryBuilder, "Query Builder"); hSplit.setSecondComponent(mainTab); hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() { @Override public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) { if (event.isDoubleClick()) { if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) { // make small hSplit.setSplitPosition(0.0f, Unit.PIXELS); } else { // reset to default width hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); } } } }); // hLayout.setExpandRatio(mainTab, 1.0f); addAction(new ShortcutListener("^Query builder") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(queryBuilder); } }); addAction(new ShortcutListener("Tutor^eial") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(tutorial); } }); getPage().addUriFragmentChangedListener(this); getSession().addRequestHandler(new RequestHandler() { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { checkCitation(request); if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) { String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/"); UUID uuid = UUID.fromString(uuidString); IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class); if (map == null) { response.setStatus(404); } else { IFrameResource res = map.get(uuid); if (res != null) { response.setStatus(200); response.setContentType(res.getMimeType()); response.getOutputStream().write(res.getData()); } } return true; } return false; } }); getSession().setAttribute(MediaController.class, new MediaControllerImpl()); getSession().setAttribute(PDFController.class, new PDFControllerImpl()); loadInstanceFonts(); checkCitation(request); lastQueriedFragment = ""; evaluateFragment(getPage().getUriFragment()); updateUserInformation(); }
From source file:annis.gui.ShareSingleMatchGenerator.java
License:Apache License
public ShareSingleMatchGenerator(List<ResolverEntry> visualizers, Match match, PagedResultQuery query, String segmentation, PluginSystem ps) { this.match = match; this.query = query; this.segmentation = segmentation; this.ps = ps; setResizeLazy(true);//from w ww . ja v a 2 s . co m directURL = new ObjectProperty<>(""); iframeCode = new ObjectProperty<>(""); visContainer = new BeanItemContainer<>(ResolverEntry.class); visContainer.addAll(visualizers); txtDirectURL = new TextArea(directURL); txtDirectURL.setCaption("Link for publications"); txtDirectURL.setWidth("100%"); txtDirectURL.setHeight("-1px"); txtDirectURL.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtDirectURL.addStyleName("shared-text"); txtDirectURL.setWordwrap(true); txtDirectURL.setReadOnly(true); txtIFrameCode = new TextArea(iframeCode); txtIFrameCode.setCaption("Code for embedding visualization into web page"); txtIFrameCode.setWidth("100%"); txtIFrameCode.setHeight("-1px"); txtIFrameCode.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtIFrameCode.addStyleName("shared-text"); txtIFrameCode.setWordwrap(true); txtIFrameCode.setReadOnly(true); preview = new BrowserFrame(); preview.setCaption("Preview"); preview.addStyleName("shared-text"); preview.setSizeFull(); generatedLinks = new VerticalLayout(txtDirectURL, txtIFrameCode, preview); generatedLinks.setComponentAlignment(txtDirectURL, Alignment.TOP_LEFT); generatedLinks.setComponentAlignment(txtIFrameCode, Alignment.TOP_LEFT); generatedLinks.setExpandRatio(preview, 1.0f); visSelector = new Grid(visContainer); visSelector.setCaption("Select visualization"); visSelector.setHeight("100%"); visSelector.setColumns("displayName"); visSelector.setSelectionMode(Grid.SelectionMode.SINGLE); visSelector.addSelectionListener(ShareSingleMatchGenerator.this); visSelector.select(visContainer.getIdByIndex(0)); visSelector.setWidth("300px"); visSelector.getColumn("displayName").setSortable(false); generatedLinks.setSizeFull(); Label infoText = new Label( "<p style=\"font-size: 18px\" >" + "<strong>Share your match:</strong> " + "1. Choose the visualization to share. 2. Copy the generated link or code. " + "3. Share this link with your peers or include the code in your website. " + "</p>", ContentMode.HTML); HorizontalLayout hLayout = new HorizontalLayout(visSelector, generatedLinks); hLayout.setSizeFull(); hLayout.setSpacing(true); hLayout.setExpandRatio(generatedLinks, 1.0f); Button btClose = new Button("Close"); btClose.setSizeUndefined(); btClose.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { getUI().removeWindow(ShareSingleMatchGenerator.this); } }); layout = new VerticalLayout(infoText, hLayout, btClose); layout.setSizeFull(); layout.setExpandRatio(hLayout, 1.0f); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); setContent(layout); }
From source file:at.peppol.webgui.app.components.InvoiceTabForm.java
License:Mozilla Public License
private void initElements() { supplierForm = new PartyDetailForm("Supplier", supplier.getParty()); supplierForm.setImmediate(true);// w w w . j ava 2 s .c o m customerForm = new PartyDetailForm("Customer", customer.getParty()); customerForm.setImmediate(true); //supplierForm.setSizeFull (); //customerForm.setSizeFull (); final HorizontalLayout footerLayout = new HorizontalLayout(); footerLayout.setSpacing(true); footerLayout.setMargin(true); footerLayout.addComponent(new Button("Save Invoice", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { SetCommonCurrency(); ValidatorHandler vh = new ValidatorHandler(footerLayout); AbstractUBLDocumentMarshaller.setGlobalValidationEventHandler(vh); vh.clearErrors(); clearTabErrorStyles(); boolean invoiceHasErrors = false; List<ValidationError> errors = GlobalValidationsRegistry.runAll(); if (errors.size() > 0) { invoiceHasErrors = true; Window errorWindow = new Window("Errors"); //position and size of the window errorWindow.setPositionX(200); errorWindow.setPositionY(200); errorWindow.setWidth("600px"); errorWindow.setHeight("300px"); //add the error messages String errorMessage = "<ol>"; for (int i = 0; i < errors.size(); i++) { errorMessage += "<li style=\"margin-top: 4px;\"><b>" + errors.get(i).getRuleID() + "</b>: " + errors.get(i).getErrorInfo() + "</li>"; //mark the appropriate Tab as error Tab tab = invTabSheet.getTab(errors.get(i).getMainComponent()); if (tab != null) tab.setStyleName("test111"); } errorMessage += "</ol>"; errorWindow.addComponent(new Label(errorMessage, Label.CONTENT_XHTML)); //show the error window getParent().getWindow().addWindow(errorWindow); errors.clear(); } ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { invoiceHasErrors = true; } if (invoiceHasErrors) { getWindow().showNotification("Validation error. Could not save invoice", Notification.TYPE_TRAY_NOTIFICATION); } else { try { if (invoiceFilePath.equals("")) { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"))); invoiceFilePath = um.getDrafts().getFolder().toString() + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis() + ".xml"; } else { UBL20DocumentMarshaller.writeInvoice(invoice, new StreamResult(new File(invoiceFilePath))); } getWindow() .showNotification( "Validation passed. Invoice saved in " + um.getDrafts().getName().toUpperCase() + " folder", Notification.TYPE_TRAY_NOTIFICATION); } catch (Exception e) { getWindow().showNotification("Disk access error. Could not save invoice", Notification.TYPE_ERROR_MESSAGE); } } /*PEPPOL validation * final ValidationPyramid vp = new ValidationPyramid (EValidationDocumentType.INVOICE, ValidationTransaction.createUBLTransaction (ETransaction.T10)); final List <ValidationPyramidResultLayer> aResults = vp.applyValidation (new FileSystemResource ("invoice.xml")) .getAllValidationResultLayers (); if (aResults.isEmpty ()) System.out.println (" The document is valid!"); else for (final ValidationPyramidResultLayer aResultLayer : aResults) for (final IResourceError aError : aResultLayer.getValidationErrors ()) System.out.println (" " + aResultLayer.getValidationLevel () + " " + aError.getAsString (Locale.US)); */ /*ValidatorsList.validateListenersNotify(); if (ValidatorsList.validateListeners() == false) { getParent().getWindow().showNotification("Validation error... ",Notification.TYPE_TRAY_NOTIFICATION); } else getParent().getWindow().showNotification("Validation passed! ",Notification.TYPE_TRAY_NOTIFICATION); */ } })); /* footerLayout.addComponent (new Button ("Save Invoice", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { try { SetCommonCurrency (); System.out.println (invoice.getDelivery ().get (0).getDeliveryAddress ().getStreetName ().getValue ()); } catch (final Exception ex) { LOGGER.error ("Error creating files. ", ex); } } })); */ footerLayout.addComponent(new Button("Read Invoice from disk", new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { SetCommonCurrency(); InvoiceType inv = UBL20DocumentMarshaller .readInvoice(new StreamSource(new FileInputStream(new File("invoice.xml")))); } catch (final Exception ex) { LOGGER.error("Error creating files. ", ex); } } })); getFooter().addComponent(footerLayout); }