Search in sources :

Example 1 with SuspendAndRestartEvent

use of org.rstudio.studio.client.application.events.SuspendAndRestartEvent 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)

Example 2 with SuspendAndRestartEvent

use of org.rstudio.studio.client.application.events.SuspendAndRestartEvent in project rstudio by rstudio.

the class ApplicationQuit method onRestartR.

@Handler
public void onRestartR() {
    boolean saveChanges = saveAction_.getAction() != SaveAction.NOSAVE;
    eventBus_.fireEvent(new SuspendAndRestartEvent(SuspendOptions.createSaveMinimal(saveChanges), null));
}
Also used : SuspendAndRestartEvent(org.rstudio.studio.client.application.events.SuspendAndRestartEvent) BarrierReleasedHandler(org.rstudio.core.client.events.BarrierReleasedHandler) SuspendAndRestartHandler(org.rstudio.studio.client.application.events.SuspendAndRestartHandler) SaveActionChangedHandler(org.rstudio.studio.client.application.events.SaveActionChangedHandler) Handler(org.rstudio.core.client.command.Handler) HandleUnsavedChangesHandler(org.rstudio.studio.client.application.events.HandleUnsavedChangesHandler)

Aggregations

SuspendAndRestartEvent (org.rstudio.studio.client.application.events.SuspendAndRestartEvent)2 Handler (org.rstudio.core.client.command.Handler)1 BarrierReleasedHandler (org.rstudio.core.client.events.BarrierReleasedHandler)1 Operation (org.rstudio.core.client.widget.Operation)1 HandleUnsavedChangesHandler (org.rstudio.studio.client.application.events.HandleUnsavedChangesHandler)1 SaveActionChangedHandler (org.rstudio.studio.client.application.events.SaveActionChangedHandler)1 SuspendAndRestartHandler (org.rstudio.studio.client.application.events.SuspendAndRestartHandler)1 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)1