Search in sources :

Example 56 with Command

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

the class FileTypeRegistry method openFile.

public void openFile(final FileSystemItem file, final boolean canUseBrowser) {
    FileType fileType = getTypeForFile(file);
    if (fileType != null) {
        fileType.openFile(file, eventBus_);
    } else {
        // build default command to use if we have an error or the
        // file is not a text file
        final Command defaultCommand = new Command() {

            @Override
            public void execute() {
                if (canUseBrowser) {
                    if (session_.getSessionInfo().getAllowFileDownloads()) {
                        BROWSER.openFile(file, eventBus_);
                    } else {
                        globalDisplay_.showErrorMessage("File Download Error", "Unable to show file because file downloads are " + "restricted on this server.\n");
                    }
                }
            }
        };
        // check with the server to see if this is likely to be a text file
        server_.isTextFile(file.getPath(), new ServerRequestCallback<Boolean>() {

            @Override
            public void onResponseReceived(Boolean isText) {
                if (isText)
                    TEXT.openFile(file, eventBus_);
                else
                    defaultCommand.execute();
            }

            @Override
            public void onError(ServerError error) {
                defaultCommand.execute();
            }
        });
    }
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError)

Example 57 with Command

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

the class LocatorPanel method showFeedbackAt.

private void showFeedbackAt(Point p) {
    cancelFeedback();
    setWidgetTopHeight(feedbackImage_, p.getY() - FB_OFFSET_Y, Unit.PX, FB_HEIGHT, Unit.PX);
    setWidgetLeftWidth(feedbackImage_, p.getX() - FB_OFFSET_X, Unit.PX, FB_WIDTH, Unit.PX);
    forceLayout();
    feedbackImage_.setVisible(true);
    feedbackImage_.getElement().getStyle().setOpacity(1.0);
    feedbackTimer_ = new Timer() {

        @Override
        public void run() {
            feedbackTimer_ = null;
            ArrayList<Widget> widgets = new ArrayList<Widget>();
            widgets.add(feedbackImage_);
            feedbackAnimation_ = new FadeOutAnimation(widgets, new Command() {

                public void execute() {
                    feedbackAnimation_ = null;
                }
            });
            feedbackAnimation_.run(300);
        }
    };
    feedbackTimer_.schedule(700);
}
Also used : Timer(com.google.gwt.user.client.Timer) FadeOutAnimation(org.rstudio.core.client.layout.FadeOutAnimation) Command(com.google.gwt.user.client.Command) ArrayList(java.util.ArrayList)

Example 58 with Command

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

the class CompilePdfOutputPresenter method onSelected.

@Override
public void onSelected() {
    super.onSelected();
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            view_.scrollToBottom();
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command)

Example 59 with Command

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

the class DataImportPresenter method getImportDatasetCommandFromMode.

public Command getImportDatasetCommandFromMode(final DataImportModes dataImportMode, final String dialogTitle, final String path) {
    return new Command() {

        @Override
        public void execute() {
            DataImportDialog dataImportDialog = new DataImportDialog(dataImportMode, dialogTitle, path, new OperationWithInput<String>() {

                @Override
                public void execute(final String importCode) {
                    eventBus_.fireEvent(new SendToConsoleEvent(importCode, true, true));
                }
            });
            dataImportDialog.showModal();
        }
    };
}
Also used : DataImportDialog(org.rstudio.studio.client.workbench.views.environment.dataimport.DataImportDialog) Command(com.google.gwt.user.client.Command) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)

Example 60 with Command

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

the class PlotsPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_PLOT, true, commands_.savePlotAsImage());
    publishButton_.setPublishHtmlSource(new PublishHtmlSource() {

        @Override
        public String getTitle() {
            return "Current Plot";
        }

        @Override
        public void generatePublishHtml(final CommandWithArg<String> onComplete) {
            dependencies_.withRMarkdown("Publishing plots", new Command() {

                @Override
                public void execute() {
                    final Size size = ZoomUtils.getZoomedSize(getPlotFrameSize(), new Size(400, 350), new Size(800, 700));
                    server_.plotsCreateRPubsHtml("Plot", "", size.width, size.height, new SimpleRequestCallback<String>() {

                        @Override
                        public void onResponseReceived(String rpubsHtmlFile) {
                            onComplete.execute(rpubsHtmlFile);
                        }
                    });
                }
            });
        }
    });
    plotsToolbar_ = new PlotsToolbar(commands_, publishButton_);
    return plotsToolbar_;
}
Also used : Command(com.google.gwt.user.client.Command) RSConnectPublishButton(org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton) PublishHtmlSource(org.rstudio.studio.client.rsconnect.model.PublishHtmlSource) Size(org.rstudio.core.client.Size) PlotsToolbar(org.rstudio.studio.client.workbench.views.plots.ui.PlotsToolbar)

Aggregations

Command (com.google.gwt.user.client.Command)189 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 Test (org.junit.Test)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 ArrayList (java.util.ArrayList)11 ServerError (org.rstudio.studio.client.server.ServerError)11 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)10 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)9 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 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 Widget (com.google.gwt.user.client.ui.Widget)7 Operation (org.rstudio.core.client.widget.Operation)7 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)7