List of usage examples for com.google.gwt.core.client JavaScriptObject cast
@Override @SuppressWarnings("unchecked") public <T extends JavascriptObjectEquivalent> T cast()
From source file:org.rstudio.studio.client.rsconnect.RSConnect.java
License:Open Source License
private void deployToRSConnect(String path, JsArrayString deployFiles, JsArrayString additionalFiles, JsArrayString ignoredFiles, String file, boolean launch, JavaScriptObject jsoRecord) { // this can be invoked by a satellite, so bring the main frame to the // front if we can if (Desktop.isDesktop()) Desktop.getFrame().bringMainFrameToFront(); else/*from w w w . j ava 2 s.c om*/ WindowEx.get().focus(); ArrayList<String> deployFilesList = JsArrayUtil.fromJsArrayString(deployFiles); ArrayList<String> additionalFilesList = JsArrayUtil.fromJsArrayString(additionalFiles); ArrayList<String> ignoredFilesList = JsArrayUtil.fromJsArrayString(ignoredFiles); RSConnectDeploymentRecord record = jsoRecord.cast(); events_.fireEvent(new RSConnectDeployInitiatedEvent(path, deployFilesList, additionalFilesList, ignoredFilesList, file, launch, record)); }
From source file:org.rstudio.studio.client.shiny.ShinyApplication.java
License:Open Source License
private void notifyShinyAppClosed(JavaScriptObject params) { ShinyApplicationParams appState = params.cast(); // if we don't know that an app is running, ignore this event if (currentAppFilePath_ == null) return;/*from w w w . j av a 2 s .c o m*/ // If the application is stopping, then the user initiated the stop by // closing the app window. Interrupt R to stop the Shiny app. if (appState.getState().equals(ShinyApplicationParams.STATE_STOPPING)) { if (commands_.interruptR().isEnabled()) commands_.interruptR().execute(); appState.setState(ShinyApplicationParams.STATE_STOPPED); } eventBus_.fireEvent(new ShinyApplicationStatusEvent((ShinyApplicationParams) params.cast())); }
From source file:org.rstudio.studio.client.shiny.ShinyApps.java
License:Open Source License
private void deployToShinyApps(String path, String file, boolean launch, JavaScriptObject jsoRecord) { // this can be invoked by a satellite, so bring the main frame to the // front if we can if (Desktop.isDesktop()) Desktop.getFrame().bringMainFrameToFront(); else/*from w w w.j a v a 2s . co m*/ WindowEx.get().focus(); ShinyAppsDeploymentRecord record = jsoRecord.cast(); events_.fireEvent(new ShinyAppsDeployInitiatedEvent(path, file, launch, record)); }
From source file:org.rstudio.studio.client.shiny.ShinyFrameHelper.java
License:Open Source License
private void onMessage(JavaScriptObject data) { // reject messages that don't match the expected origin ShinyFrameEvent event = data.cast(); if (!url_.startsWith(event.getOrigin())) return;//from w w w . ja v a 2s . co m String eventName = event.getEvent(); if (eventName.equals(EVENT_SCROLL_CHANGE)) { scrollPosition_ = event.getIntData(); } else if (eventName.equals(EVENT_HASH_CHANGE)) { url_ = event.getStringData(); } else if (eventName.equals(EVENT_READY)) { window_ = event.getSource(); origin_ = event.getOrigin(); if (onInitComplete_ != null) { onInitComplete_.execute(); onInitComplete_ = null; } } }
From source file:org.rstudio.studio.client.shiny.ui.ShinyApplicationWindow.java
License:Open Source License
@Override protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) { ShinyApplicationParams appParams = params.cast(); Window.setTitle(appParams.getPath() + " - " + "Shiny"); ShinyApplicationPresenter appPresenter = pPresenter_.get(); appPresenter.loadApp(appParams);/*from w w w . j a v a 2s . c om*/ // make it fill the containing layout panel Widget presWidget = appPresenter.asWidget(); mainPanel.add(presWidget); mainPanel.setWidgetLeftRight(presWidget, 0, Unit.PX, 0, Unit.PX); mainPanel.setWidgetTopBottom(presWidget, 0, Unit.PX, 0, Unit.PX); }
From source file:org.rstudio.studio.client.workbench.views.presentation.Presentation.java
License:Open Source License
private void onPresentationSlideChanged(final int index, final JavaScriptObject jsCmds) { // note the slide index and save it currentState_.setSlideIndex(index);//from w w w . java2 s . co m indexPersister_.setIndex(index); handlerManager_.fireEvent(new SlideIndexChangedEvent(index)); // execute commands if we stay on the slide for > 500ms new Timer() { @Override public void run() { // execute commands if we're still on the same slide if (index == currentState_.getSlideIndex()) { JsArray<JavaScriptObject> cmds = jsCmds.cast(); for (int i = 0; i < cmds.length(); i++) dispatchCommand(cmds.get(i)); } } }.schedule(500); }
From source file:org.rstudio.studio.client.workbench.views.presentation.Presentation.java
License:Open Source License
private void initPresentationNavigator(JavaScriptObject jsNavigator) { // record current slides SlideNavigation navigation = jsNavigator.cast(); handlerManager_.fireEvent(new SlideNavigationChangedEvent(navigation)); }
From source file:org.rstudio.studio.client.workbench.views.presentation.PresentationDispatcher.java
License:Open Source License
public void dispatchCommand(JavaScriptObject jsCommand) { // cast// ww w.j ava 2 s . co m PresentationCommand command = jsCommand.cast(); // crack parameters String param1 = null, param2 = null; String params = command.getParams(); if (params.length() > 0) { // find the first space and split on that int spaceLoc = params.indexOf(' '); if (spaceLoc == -1) { param1 = params; } else { param1 = params.substring(0, spaceLoc); param2 = params.substring(spaceLoc + 1); } } String cmdName = command.getName().toLowerCase(); if (cmdName.equals("source")) performSourceCommand(param1, param2); else performOtherCommand(cmdName, params, param1, param2); }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.AceVimCommandHandler.java
License:Open Source License
private boolean isNormalMode(JavaScriptObject data) { VimHandlerData vimData = data.cast(); return "start".equals(vimData.getState()); }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputStream.java
License:Open Source License
public List<ChunkOutputPage> extractPages() { // flush any errors so they are properly accounted for flushQueuedErrors();/*from www .j a v a 2s .c o m*/ List<ChunkOutputPage> pages = new ArrayList<ChunkOutputPage>(); List<Widget> removed = new ArrayList<Widget>(); for (Widget w : this) { // extract ordinal and metadata JavaScriptObject metadata = null; String ord = w.getElement().getAttribute(ORDINAL_ATTRIBUTE); int ordinal = 0; if (!StringUtil.isNullOrEmpty(ord)) ordinal = StringUtil.parseInt(ord, 0); if (metadata_.containsKey(ordinal)) metadata = metadata_.get(ordinal); if (w instanceof ChunkDataWidget) { ChunkDataWidget widget = (ChunkDataWidget) w; ChunkDataPage data = new ChunkDataPage(widget, (NotebookFrameMetadata) metadata.cast(), ordinal); pages.add(data); removed.add(w); continue; } else if (w instanceof ChunkOrdinalWidget) { pages.add(new ChunkOrdinalPage(ordinal)); removed.add(w); continue; } // extract the inner element if this is a fixed-ratio widget (or just // use raw if it's not) Widget inner = w; if (w instanceof FixedRatioWidget) inner = ((FixedRatioWidget) w).getWidget(); if (inner instanceof ChunkPlotWidget) { ChunkPlotWidget plot = (ChunkPlotWidget) inner; ChunkPlotPage page = new ChunkPlotPage(plot.plotUrl(), plot.getMetadata(), ordinal, null, chunkOutputSize_); pages.add(page); removed.add(w); } else if (inner instanceof ChunkOutputFrame) { ChunkOutputFrame frame = (ChunkOutputFrame) inner; ChunkHtmlPage html = new ChunkHtmlPage(frame.getUrl(), (NotebookHtmlMetadata) metadata.cast(), ordinal, null, chunkOutputSize_); // cancel any pending page load frame.cancelPendingLoad(); pages.add(html); removed.add(w); } } for (Widget r : removed) this.remove(r); return pages; }