List of usage examples for com.vaadin.ui JavaScript eval
public static void eval(String script)
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 w w . j a v a 2 s. c om } 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:com.hazelcast.examples.Tutorial.java
License:Open Source License
private final void prepareSourceCode() { String source = "/" + getClass().getName().replaceAll("\\.", "/") + ".java"; try {//from www . java2 s.com String code = StringUtils.replaceEach(IOUtils.toString(getClass().getResourceAsStream(source)), new String[] { "&", "<", ">", "\"", "'", "/" }, new String[] { "&", "<", ">", """, "'", "/" }); Label c = new Label("<pre class='prettyprint'>" + code + "</pre>"); c.setContentMode(ContentMode.HTML); c.setSizeUndefined(); addSelectedTabChangeListener(e -> JavaScript.eval("setTimeout(function(){prettyPrint();},300);")); sourceCode.add(c); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.rd.monitoring.charts.AbstractHighCharts.java
License:Open Source License
/** * <p>/*from w ww . ja v a 2 s .co m*/ * Executes the given JavaScript code to manipulate the chart. * Use the JavaScript variable <code>chart</code> to access the chart. * </p> * <p>Example:</p> * <pre> chart.manipulateChart("chart.addSeries({name: 'new', data: [1, 2]});");</pre> * * @param js JavaScript code to be executed */ public void manipulateChart(String js) { JavaScript.eval("var chart = $('#" + getDomId() + "').highcharts();\n" + js); }
From source file:org.opencms.ui.apps.CmsLegacyApp.java
License:Open Source License
/** * Constructor.<p>// www. j a v a2 s.c om * * @param toolHandler the tool handler */ public CmsLegacyApp(I_CmsToolHandler toolHandler) { m_toolHandler = toolHandler; addAttachListener(new AttachListener() { private static final long serialVersionUID = 1L; public void attach(AttachEvent event) { JavaScript.eval(VAR_IS_LEGACY_APP + " = true;"); } }); addDetachListener(new DetachListener() { private static final long serialVersionUID = 1L; public void detach(DetachEvent event) { JavaScript.eval(VAR_IS_LEGACY_APP + " = false;"); } }); setSizeFull(); }
From source file:org.opencms.ui.components.CmsFakeWindow.java
License:Open Source License
/** * Sets the window title.<p>/* w w w. jav a 2 s . c om*/ * * @param title the new window title */ public void setWindowTitle(String title) { /* HACK: Using a Label destroys the layout for some reason, so we resort to setting the caption directly in the element via an explicit JavaScript call. */ m_windowTitle = title; JavaScript.eval("document.querySelector('#" + getId() + " .fakewindowheader').innerHTML = '" + StringEscapeUtils.escapeJavaScript(title) + "'"); }
From source file:org.opencms.ui.dialogs.embedded.CmsDataViewDialog.java
License:Open Source License
/** * Creates a new instance.<p>//ww w . j a va2s. c om * * @param context the dialog context */ public CmsDataViewDialog(I_CmsDialogContext context) { m_context = context; CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); final CmsDataViewParams params = new CmsDataViewParams(A_CmsUI.get().getPage().getLocation()); I_CmsDataView example = params.createViewInstance(context.getCms(), A_CmsUI.get().getLocale()); final CmsDataViewPanel panel = new CmsDataViewPanel(example, params.isMultiSelect()); panel.setSizeFull(); m_container.addComponent(panel); m_okButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void buttonClick(ClickEvent event) { List<I_CmsDataViewItem> result = panel.getSelection(); String script = params.prepareCallbackScript(result); JavaScript.eval(script); m_context.finish(null); } }); m_cancelButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public void buttonClick(ClickEvent event) { m_context.finish(null); } }); }
From source file:org.opencms.ui.error.CmsErrorUI.java
License:Open Source License
/** * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) */// ww w . java2 s. co m @Override protected void init(VaadinRequest request) { readErrorAttributes(); CmsErrorDialog.showErrorDialog(getErrorMessage(m_throwable), m_throwable, new Runnable() { public void run() { JavaScript.eval("if (window.parent && window.parent." + CmsLegacyApp.VAR_IS_LEGACY_APP + ") window.parent.location.reload();"); } }); }
From source file:org.opencms.ui.report.CmsReportOverlay.java
License:Open Source License
/** * Constructor.<p>/*from w w w. jav a2 s .c o m*/ * * @param thread the report thread */ public CmsReportOverlay(A_CmsReportThread thread) { setId(RandomStringUtils.randomAlphabetic(8)); try { @SuppressWarnings("resource") InputStream layoutStream = CmsVaadinUtils.readCustomLayout(getClass(), "reportoverlay.html"); initTemplateContentsFromInputStream(layoutStream); } catch (IOException e) { LOG.error(e.getLocalizedMessage(), e); } m_report = new CmsReportWidget(thread); m_report.setWidth("100%"); m_report.setHeight((Page.getCurrent().getBrowserWindowHeight() - 200) + "px"); CmsBasicDialog dialogContent = new CmsBasicDialog(); dialogContent.setContent(m_report); addComponent(dialogContent, "content"); m_report.addReportFinishedHandler(new Runnable() { public void run() { setVisible(false); } }); // add a timeout to show the report window JavaScript.eval("setTimeout(function(){ " + "var el= document.getElementById('" + getId() + "'); if (el!=null) el.classList.add('o-report-show'); }," + REPORT_VIEW_DELAY + ")"); }
From source file:org.opencms.ui.report.CmsReportOverlay.java
License:Open Source License
/** * Sets the window title.<p>//from www . j a v a2 s . com * * @param title the new window title */ public void setTitle(String title) { /* HACK: Using a Label destroys the layout for some reason, so we resort to setting the caption directly in the element via an explicit JavaScript call. */ JavaScript.eval("document.querySelector('#" + getId() + " .fakewindowheader').innerHTML = '" + StringEscapeUtils.escapeJavaScript(title) + "'"); }
From source file:org.opencms.ui.sitemap.CmsLocaleComparePanel.java
License:Open Source License
/** * Initializes the tree with the given resource as a root.<p> * * @param rootRes the new tree root resource * @throws CmsException if something goes wrong *///from w ww . jav a2 s . c o m protected void initTree(CmsResource rootRes) throws CmsException { m_currentRoot = rootRes; m_treeContainer.removeAllComponents(); showHeader(); CmsSitemapTreeController controller = new CmsSitemapTreeController(A_CmsUI.getCmsObject(), rootRes, this, m_treeContainer); // no need to escape a structure id JavaScript.eval(CmsGwtConstants.VAR_LOCALE_ROOT + "='" + rootRes.getStructureId() + "'"); CmsSitemapUI ui = (CmsSitemapUI) (A_CmsUI.get()); ui.getSitemapExtension().setSitemapTreeController(controller); CmsSitemapTreeNode root1 = controller.createRootNode(); controller.initEventHandlers(root1); m_treeContainer.addComponent(root1); controller.onClickOpen(root1); }