List of usage examples for com.vaadin.ui Notification show
public static Notification show(String caption, Type type)
From source file:annis.gui.querybuilder.QueryBuilderChooser.java
License:Apache License
@Override public void valueChange(ValueChangeEvent event) { QueryBuilderPlugin plugin = pluginRegistry.get((String) event.getProperty().getValue()); if (plugin == null) { Notification.show("Invalid selection (plugin not found)", Notification.Type.WARNING_MESSAGE); } else {/*from w w w . j a v a2s.c o m*/ component = plugin.createComponent(controller); if (lastComponent != null) { layout.removeComponent(lastComponent); } layout.addComponent(component); layout.setExpandRatio(component, 1.0f); lastComponent = component; } }
From source file:annis.gui.querybuilder.TigerQueryBuilderCanvas.java
License:Apache License
public void addEdge(NodeWindow target) { for (NodeWindow w : nodes.keySet()) { w.setPrepareEdgeDock(false);//from ww w . ja v a2 s .c o m } if (preparedEdgeSource != target) { boolean valid = true; for (EdgeWindow e : edges) { if (e.getSource() == preparedEdgeSource && e.getTarget() == target) { valid = false; break; } } if (valid) { EdgeWindow e = new EdgeWindow(this, preparedEdgeSource, target); e.setWidth("170px"); e.setHeight("70px"); e.addStyleName("tigerquery-builder-overlay"); edges.add(e); area.addComponent(e); updateLinesAndEdgePositions(); updateQuery(); } else { Notification.show("There is already such an edge", Notification.Type.WARNING_MESSAGE); } } }
From source file:annis.gui.QueryController.java
License:Apache License
/** * Executes a query./*from w ww . j a v a2 s .c o m*/ * @param replaceOldTab * @param freshQuery If true the offset and the selected matches are reset before executing the query. */ public void executeSearch(boolean replaceOldTab, boolean freshQuery) { if (freshQuery) { getState().getOffset().setValue(0l); getState().getSelectedMatches().setValue(new TreeSet<Long>()); // get the value for the visible segmentation from the configured context Set<String> selectedCorpora = getState().getSelectedCorpora().getValue(); CorpusConfig config = new CorpusConfig(); if (selectedCorpora != null && !selectedCorpora.isEmpty()) { config = ui.getCorpusConfigWithCache(selectedCorpora.iterator().next()); } if (config.containsKey(SearchOptionsPanel.KEY_DEFAULT_BASE_TEXT_SEGMENTATION)) { String configVal = config.getConfig(SearchOptionsPanel.KEY_DEFAULT_BASE_TEXT_SEGMENTATION); if ("".equals(configVal) || "tok".equals(configVal)) { configVal = null; } getState().getVisibleBaseText().setValue(configVal); } else { getState().getVisibleBaseText().setValue(getState().getContextSegmentation().getValue()); } } // construct a query from the current properties DisplayedResultQuery displayedQuery = getSearchQuery(); searchView.getControlPanel().getQueryPanel().setStatus("Searching..."); cancelSearch(); // cleanup resources VaadinSession session = VaadinSession.getCurrent(); session.setAttribute(IFrameResourceMap.class, new IFrameResourceMap()); if (session.getAttribute(MediaController.class) != null) { session.getAttribute(MediaController.class).clearMediaPlayers(); } searchView.updateFragment(displayedQuery); if (displayedQuery.getCorpora() == null || displayedQuery.getCorpora().isEmpty()) { Notification.show("Please select a corpus", Notification.Type.WARNING_MESSAGE); return; } if ("".equals(displayedQuery.getQuery())) { Notification.show("Empty query", Notification.Type.WARNING_MESSAGE); return; } addHistoryEntry(displayedQuery); AsyncWebResource res = Helper.getAnnisAsyncWebResource(); // // begin execute match fetching // ResultViewPanel oldPanel = searchView.getLastSelectedResultView(); if (replaceOldTab) { // remove old panel from view searchView.closeTab(oldPanel); } ResultViewPanel newResultView = new ResultViewPanel(ui, ui, ui.getInstanceConfig(), displayedQuery); newResultView.getPaging() .addCallback(new SpecificPagingCallback(ui, searchView, newResultView, displayedQuery)); TabSheet.Tab newTab; List<ResultViewPanel> existingResultPanels = getResultPanels(); String caption = existingResultPanels.isEmpty() ? "Query Result" : "Query Result #" + (existingResultPanels.size() + 1); newTab = searchView.getMainTab().addTab(newResultView, caption); newTab.setClosable(true); newTab.setIcon(FontAwesome.SEARCH); searchView.getMainTab().setSelectedTab(newResultView); searchView.notifiyQueryStarted(); Background.run(new ResultFetchJob(displayedQuery, newResultView, ui)); // // end execute match fetching // // // begin execute count // // start count query searchView.getControlPanel().getQueryPanel().setCountIndicatorEnabled(true); AsyncWebResource countRes = res.path("query").path("search").path("count") .queryParam("q", Helper.encodeJersey(displayedQuery.getQuery())) .queryParam("corpora", Helper.encodeJersey(StringUtils.join(displayedQuery.getCorpora(), ","))); Future<MatchAndDocumentCount> futureCount = countRes.get(MatchAndDocumentCount.class); state.getExecutedTasks().put(QueryUIState.QueryType.COUNT, futureCount); Background.run(new CountCallback(newResultView, displayedQuery.getLimit(), ui)); // // end execute count // }
From source file:annis.gui.QueryController.java
License:Apache License
public void executeFrequency(FrequencyQueryPanel panel) { // kill old request Future freqFuture = state.getExecutedTasks().get(QueryUIState.QueryType.FREQUENCY); if (freqFuture != null && !freqFuture.isDone()) { freqFuture.cancel(true);/* www.ja va 2 s .c om*/ } if ("".equals(state.getAql().getValue())) { Notification.show("Empty query", Notification.Type.WARNING_MESSAGE); panel.showQueryDefinitionPanel(); return; } else if (state.getSelectedCorpora().getValue().isEmpty()) { Notification.show("Please select a corpus", Notification.Type.WARNING_MESSAGE); panel.showQueryDefinitionPanel(); return; } BeanContainer<Integer, UserGeneratedFrequencyEntry> container = state.getFrequencyTableDefinition(); FrequencyTableQuery freqDefinition = new FrequencyTableQuery(); for (Integer id : container.getItemIds()) { UserGeneratedFrequencyEntry userGen = container.getItem(id).getBean(); freqDefinition.add(userGen.toFrequencyTableEntry()); } // additionally add meta data columns for (String m : state.getFrequencyMetaData().getValue()) { FrequencyTableEntry entry = new FrequencyTableEntry(); entry.setType(FrequencyTableEntryType.meta); entry.setKey(m); freqDefinition.add(entry); } FrequencyQuery query = QueryGenerator.frequency().query(state.getAql().getValue()) .corpora(state.getSelectedCorpora().getValue()).def(freqDefinition).build(); addHistoryEntry(query); FrequencyBackgroundJob job = new FrequencyBackgroundJob(ui, query, panel); freqFuture = Background.call(job); state.getExecutedTasks().put(QueryUIState.QueryType.FREQUENCY, freqFuture); }
From source file:annis.gui.resultview.ResultSetPanel.java
License:Apache License
private void addQueryResult(SaltProject p, int offset) { List<SingleResultPanel> newPanels = new LinkedList<SingleResultPanel>(); try {/*from ww w . ja v a 2 s . c o m*/ if (p == null) { Notification.show("Could not get subgraphs", Notification.Type.TRAY_NOTIFICATION); } else { updateVariables(p); newPanels = createPanels(p, offset); } } catch (Exception ex) { log.error(null, ex); } for (SingleResultPanel panel : newPanels) { resultPanelList.add(panel); layout.addComponent(panel); } }
From source file:annis.gui.resultview.ResultViewPanel.java
License:Apache License
private void addQueryResult(PagedResultQuery q, List<SaltProject> subgraphList) { if (q == null) { return;/*from w ww . j av a 2 s .c o m*/ } List<SingleResultPanel> newPanels = new LinkedList<>(); try { if (subgraphList == null || subgraphList.isEmpty()) { Notification.show("Could not get subgraphs", Notification.Type.TRAY_NOTIFICATION); } else { for (SaltProject p : subgraphList) { updateVariables(p); newPanels = createPanels(p, currentResults, q.getOffset() + currentResults); currentResults += newPanels.size(); String strResults = numberOfResults > 1 ? "results" : "result"; sui.getSearchView().getControlPanel().getQueryPanel().setStatus( sui.getSearchView().getControlPanel().getQueryPanel().getLastPublicStatus(), " (showing " + currentResults + "/" + numberOfResults + " " + strResults + ")"); if (currentResults == numberOfResults) { resetQueryResultQueue(); } for (SingleResultPanel panel : newPanels) { resultPanelList.add(panel); resultLayout.addComponent(panel); panel.setSegmentationLayer(sui.getQueryState().getVisibleBaseText().getValue()); } } if (currentResults == numberOfResults) { showFinishedSubgraphSearch(); if (!initialQuery.getSelectedMatches().isEmpty()) { // scroll to the first selected match JavaScript.eval( "$(\".v-panel-content-result-view-panel\").animate({scrollTop: $(\".selected-match\").offset().top - $(\".result-view-panel\").offset().top}, 1000);"); } } if (projectQueue != null && !newPanels.isEmpty() && currentResults < numberOfResults) { log.debug("adding callback for result " + currentResults); // add a callback so we can load the next single result OnLoadCallbackExtension ext = new OnLoadCallbackExtension(this, 250); ext.extend(newPanels.get(newPanels.size() - 1)); } } } catch (Throwable ex) { log.error(null, ex); } }
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);/*from ww w . j a va2 s .c o m*/ 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.SearchUI.java
License:Apache License
@Override public void onLogin() { AnnisUser user = Helper.getUser();/*from ww w . j a va 2s . c o m*/ if (user != null) { Notification.show("Logged in as \"" + user.getUserName() + "\"", Notification.Type.TRAY_NOTIFICATION); } updateUserInformation(); }
From source file:annis.gui.SearchView.java
License:Apache License
public void evaluateCitation(String relativeUri) { Matcher m = citationPattern.matcher(relativeUri); if (m.matches()) { // AQL// w w w. j ava 2 s. c om String aql = ""; if (m.group(1) != null) { aql = m.group(1); } // CIDS Set<String> selectedCorpora = new HashSet<>(); if (m.group(2) != null) { String[] cids = m.group(2).split(","); selectedCorpora.addAll(Arrays.asList(cids)); } // filter by actually avaible user corpora in order not to get any exception later WebResource res = Helper.getAnnisWebResource(); List<AnnisCorpus> userCorpora = res.path("query").path("corpora").get(new AnnisCorpusListType()); LinkedList<String> userCorporaStrings = new LinkedList<>(); for (AnnisCorpus c : userCorpora) { userCorporaStrings.add(c.getName()); } selectedCorpora.retainAll(userCorporaStrings); // CLEFT and CRIGHT if (m.group(4) != null && m.group(6) != null) { int cleft = 0; int cright = 0; try { cleft = Integer.parseInt(m.group(4)); cright = Integer.parseInt(m.group(6)); } catch (NumberFormatException ex) { log.error("could not parse context value", ex); } ui.getQueryController() .setQuery(new PagedResultQuery(cleft, cright, 0, 10, null, aql, selectedCorpora)); } else { ui.getQueryController().setQuery(new Query(aql, selectedCorpora)); } // remove all currently openend sub-windows Set<Window> all = new HashSet<>(ui.getWindows()); for (Window w : all) { ui.removeWindow(w); } } else { Notification.show("Invalid citation", Notification.Type.WARNING_MESSAGE); } }
From source file:annis.gui.SearchView.java
License:Apache License
/** * Takes a list of raw corpus names as given by the #c parameter and returns a * list of corpus names that are known to exist. It also replaces alias names * with the real corpus names./* w w w .j a v a 2s . co m*/ * * @param originalNames * @return */ private Set<String> getMappedCorpora(List<String> originalNames) { WebResource rootRes = Helper.getAnnisWebResource(); Set<String> mappedNames = new HashSet<>(); // iterate over given corpora and map names if necessary for (String selectedCorpusName : originalNames) { // get the real corpus descriptions by the name (which could be an alias) try { List<AnnisCorpus> corporaByName = rootRes.path("query").path("corpora") .path(urlPathEscape.escape(selectedCorpusName)).get(new GenericType<List<AnnisCorpus>>() { }); if (corporaByName != null && !corporaByName.isEmpty()) { for (AnnisCorpus c : corporaByName) { mappedNames.add(c.getName()); } } } catch (ClientHandlerException ex) { String msg = "alias mapping does not work for alias: " + selectedCorpusName; log.error(msg, ex); Notification.show(msg, Notification.Type.TRAY_NOTIFICATION); } } return mappedNames; }