Search in sources :

Example 16 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class TextEditingTarget method previewRpresentation.

void previewRpresentation() {
    SessionInfo sessionInfo = session_.getSessionInfo();
    if (!fileTypeCommands_.getHTMLCapabiliites().isRMarkdownSupported()) {
        globalDisplay_.showMessage(MessageDisplay.MSG_WARNING, "Unable to Preview", "R Presentations require the knitr package " + "(version 1.2 or higher)");
        return;
    }
    PresentationState state = sessionInfo.getPresentationState();
    // if we are showing a tutorial then don't allow preview
    if (state.isTutorial()) {
        globalDisplay_.showMessage(MessageDisplay.MSG_WARNING, "Unable to Preview", "R Presentations cannot be previewed when a Tutorial " + "is active");
        return;
    }
    // if this presentation is already showing then just activate 
    if (state.isActive() && state.getFilePath().equals(docUpdateSentinel_.getPath())) {
        commands_.activatePresentation().execute();
        save();
    } else // otherwise reload
    {
        saveThenExecute(null, new Command() {

            @Override
            public void execute() {
                server_.showPresentationPane(docUpdateSentinel_.getPath(), new VoidServerRequestCallback());
            }
        });
    }
}
Also used : PresentationState(org.rstudio.studio.client.workbench.views.presentation.model.PresentationState) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 17 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class FindOutputPresenter method onDismiss.

public void onDismiss() {
    stopAndClear();
    server_.clearFindResults(new VoidServerRequestCallback());
}
Also used : VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 18 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Plots method onClearPlots.

void onClearPlots() {
    // clear plots gesture indicates we are done with locator
    safeClearLocator();
    // confirm
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Clear Plots", "Are you sure you want to clear all of the plots in the history?", new ProgressOperation() {

        public void execute(final ProgressIndicator indicator) {
            indicator.onProgress("Clearing plots...");
            server_.clearPlots(new VoidServerRequestCallback(indicator));
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 19 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class History method onHistoryRemoveEntries.

@Handler
void onHistoryRemoveEntries() {
    // get selected indexes (bail if there is no selection)
    final ArrayList<Integer> selectedRowIndexes = view_.getRecentCommandsSelectedRowIndexes();
    if (selectedRowIndexes.size() < 1) {
        globalDisplay_.showErrorMessage("Error", "No history entries currently selected.");
        return;
    }
    // bring view to front
    view_.bringToFront();
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Remove Entries", "Are you sure you want to remove the selected entries from " + "the history?", new ProgressOperation() {

        public void execute(final ProgressIndicator indicator) {
            indicator.onProgress("Removing items...");
            // for each selected row index we need to calculate
            // the offset from the bottom
            int rowCount = view_.getRecentCommandsRowsDisplayed();
            JsArrayNumber bottomIndexes = (JsArrayNumber) JsArrayNumber.createArray();
            for (int i = 0; i < selectedRowIndexes.size(); i++) bottomIndexes.push(rowCount - selectedRowIndexes.get(i) - 1);
            server_.removeHistoryItems(bottomIndexes, new VoidServerRequestCallback(indicator));
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) JsArrayNumber(com.google.gwt.core.client.JsArrayNumber) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 20 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback in project rstudio by rstudio.

the class Packages method restartForInstallWithConfirmation.

private void restartForInstallWithConfirmation(final String installCmd) {
    String msg = "One or more of the packages that will be updated by this " + "installation are currently loaded. Restarting R prior " + "to updating these packages is strongly recommended.\n\n" + "RStudio can restart R and then automatically continue " + "the installation after restarting (all work and " + "data will be preserved during the restart).\n\n" + "Do you want to restart R prior to installing?";
    final boolean haveInstallCmd = installCmd.startsWith("install.packages");
    globalDisplay_.showYesNoMessage(MessageDialog.WARNING, "Updating Loaded Packages", msg, true, new Operation() {

        public void execute() {
            events_.fireEvent(new SuspendAndRestartEvent(SuspendOptions.createSaveAll(true), installCmd));
        }
    }, new Operation() {

        public void execute() {
            server_.ignoreNextLoadedPackageCheck(new VoidServerRequestCallback() {

                @Override
                public void onSuccess() {
                    if (haveInstallCmd)
                        executePkgCommand(installCmd);
                }
            });
        }
    }, true);
}
Also used : VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Operation(org.rstudio.core.client.widget.Operation) SuspendAndRestartEvent(org.rstudio.studio.client.application.events.SuspendAndRestartEvent)

Aggregations

VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)44 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)14 Handler (org.rstudio.core.client.command.Handler)8 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)7 ServerError (org.rstudio.studio.client.server.ServerError)7 Command (com.google.gwt.user.client.Command)6 Operation (org.rstudio.core.client.widget.Operation)4 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)4 Void (org.rstudio.studio.client.server.Void)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)3 ArrayList (java.util.ArrayList)3 AppCommand (org.rstudio.core.client.command.AppCommand)3 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)3 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)3 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)3 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)3 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)2