Search in sources :

Example 6 with Command

use of com.google.gwt.user.client.Command in project rstudio by rstudio.

the class ShinyApplication method launchShinyApplication.

// Public methods ----------------------------------------------------------
// Private methods ---------------------------------------------------------
private void launchShinyApplication(final String filePath, final String extendedType) {
    String fileDir = filePath.substring(0, filePath.lastIndexOf("/"));
    if (fileDir.equals(currentAppPath())) {
        // reload the app.
        if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_WINDOW) {
            satelliteManager_.dispatchCommand(commands_.reloadShinyApp(), ShinyApplicationSatellite.NAME);
            activateWindow();
        } else if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_PANE && commands_.viewerRefresh().isEnabled()) {
            commands_.viewerRefresh().execute();
        } else if (currentViewType_ == ShinyViewerType.SHINY_VIEWER_BROWSER) {
            eventBus_.fireEvent(new ShinyApplicationStatusEvent(params_));
        }
        return;
    } else if (params_ != null && isBusy_) {
        // There's another app running. Interrupt it and then start this one.
        interrupt_.interruptR(new InterruptHandler() {

            @Override
            public void onInterruptFinished() {
                launchShinyFile(filePath, extendedType);
            }
        });
    } else {
        // Nothing else running, start this app.
        dependencyManager_.withShiny("Running Shiny applications", new Command() {

            @Override
            public void execute() {
                launchShinyFile(filePath, extendedType);
            }
        });
    }
}
Also used : Command(com.google.gwt.user.client.Command) InterruptHandler(org.rstudio.studio.client.application.ApplicationInterrupt.InterruptHandler) ShinyApplicationStatusEvent(org.rstudio.studio.client.shiny.events.ShinyApplicationStatusEvent)

Example 7 with Command

use of com.google.gwt.user.client.Command in project rstudio by rstudio.

the class CopyPlotToClipboardDesktopDialog method copyAsBitmap.

protected void copyAsBitmap(final Operation onCompleted) {
    final ExportPlotSizeEditor sizeEditor = getSizeEditor();
    sizeEditor.prepareForExport(new Command() {

        @Override
        public void execute() {
            if (BrowseCap.isCocoaDesktop()) {
                clipboard_.copyPlotToCocoaPasteboard(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {

                    @Override
                    public void execute() {
                        onCompleted.execute();
                    }
                });
            } else {
                WindowEx win = sizeEditor.getPreviewIFrame().getContentWindow();
                Document doc = win.getDocument();
                NodeList<Element> images = doc.getElementsByTagName("img");
                if (images.getLength() > 0) {
                    ElementEx img = images.getItem(0).cast();
                    DesktopFrame frame = Desktop.getFrame();
                    frame.copyImageToClipboard(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
                }
                onCompleted.execute();
            }
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ElementEx(org.rstudio.core.client.dom.ElementEx) NodeList(com.google.gwt.dom.client.NodeList) WindowEx(org.rstudio.core.client.dom.WindowEx) Document(com.google.gwt.dom.client.Document) DesktopFrame(org.rstudio.studio.client.application.DesktopFrame) ExportPlotSizeEditor(org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)

Example 8 with Command

use of com.google.gwt.user.client.Command in project rstudio by rstudio.

the class CopyPlotToClipboardDesktopMetafileDialog method copyAsMetafile.

private void copyAsMetafile(final Operation onCompleted) {
    ExportPlotSizeEditor sizeEditor = getSizeEditor();
    clipboard_.copyPlotToClipboardMetafile(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {

        @Override
        public void execute() {
            onCompleted.execute();
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ExportPlotSizeEditor(org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)

Example 9 with Command

use of com.google.gwt.user.client.Command in project rstudio by rstudio.

the class CppCompletionManager method performCompletionRequest.

private void performCompletionRequest(final CompletionPosition completionPosition, final boolean explicit) {
    terminateCompletionRequest();
    final Invalidation.Token invalidationToken = completionRequestInvalidation_.getInvalidationToken();
    completionContext_.withUpdatedDoc(new CommandWith2Args<String, String>() {

        @Override
        public void execute(String docPath, String docId) {
            if (invalidationToken.isInvalid())
                return;
            request_ = new CppCompletionRequest(docPath, docId, completionPosition, docDisplay_, invalidationToken, explicit, CppCompletionManager.this, new Command() {

                @Override
                public void execute() {
                    suggestionTimer_.cancel();
                }
            });
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Invalidation(org.rstudio.core.client.Invalidation)

Example 10 with Command

use of com.google.gwt.user.client.Command in project rstudio by rstudio.

the class ViewerPresenter method onViewerSaveAsWebPage.

@Handler
public void onViewerSaveAsWebPage() {
    display_.bringToFront();
    if (saveAsWebPageDefaultPath_ == null)
        saveAsWebPageDefaultPath_ = workbenchContext_.getCurrentWorkingDir();
    dependencyManager_.withRMarkdown("Saving standalone web pages", new Command() {

        @Override
        public void execute() {
            fileDialogs_.saveFile("Save As Web Page", fileSystemContext_, saveAsWebPageDefaultPath_, ".html", false, new ProgressOperationWithInput<FileSystemItem>() {

                @Override
                public void execute(final FileSystemItem targetFile, ProgressIndicator indicator) {
                    if (targetFile == null) {
                        indicator.onCompleted();
                        return;
                    }
                    indicator.onProgress("Saving as web page...");
                    server_.viewerSaveAsWebPage(targetFile.getPath(), new VoidServerRequestCallback(indicator) {

                        @Override
                        public void onSuccess() {
                            saveAsWebPageDefaultPath_ = targetFile.getParentPath();
                        }
                    });
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Aggregations

Command (com.google.gwt.user.client.Command)208 AppCommand (org.rstudio.core.client.command.AppCommand)39 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)38 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)21 JsArrayString (com.google.gwt.core.client.JsArrayString)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)16 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)16 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)12 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)11 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)11 ServerError (org.rstudio.studio.client.server.ServerError)11 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)9 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)9 MenuItem (com.google.gwt.user.client.ui.MenuItem)8 Handler (org.rstudio.core.client.command.Handler)8 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)8 Timer (com.google.gwt.user.client.Timer)7 Widget (com.google.gwt.user.client.ui.Widget)7 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)7