Search in sources :

Example 1 with QuitInitiatedEvent

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

the class ApplicationQuit method prepareForQuit.

public void prepareForQuit(final String caption, final boolean forceSaveAll, final QuitContext quitContext) {
    boolean busy = workbenchContext_.isServerBusy() || workbenchContext_.isTerminalBusy();
    String msg = null;
    if (busy) {
        if (workbenchContext_.isServerBusy() && !workbenchContext_.isTerminalBusy())
            msg = "The R session is currently busy.";
        else if (workbenchContext_.isServerBusy() && workbenchContext_.isTerminalBusy())
            msg = "The R session and the terminal are currently busy.";
        else
            msg = "The terminal is currently busy.";
    }
    eventBus_.fireEvent(new QuitInitiatedEvent());
    if (busy && !forceSaveAll) {
        globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, caption, msg + " Are you sure you want to quit?", new Operation() {

            @Override
            public void execute() {
                handleUnsavedChanges(caption, forceSaveAll, quitContext);
            }
        }, true);
    } else {
        // if we aren't restoring source documents then close them all now
        if (!pUiPrefs_.get().restoreSourceDocuments().getValue()) {
            sourceShim_.closeAllSourceDocs(caption, new Command() {

                @Override
                public void execute() {
                    handleUnsavedChanges(caption, forceSaveAll, quitContext);
                }
            });
        } else {
            handleUnsavedChanges(caption, forceSaveAll, quitContext);
        }
    }
}
Also used : Command(com.google.gwt.user.client.Command) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) QuitInitiatedEvent(org.rstudio.studio.client.application.events.QuitInitiatedEvent) Operation(org.rstudio.core.client.widget.Operation)

Aggregations

RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 Command (com.google.gwt.user.client.Command)1 Operation (org.rstudio.core.client.widget.Operation)1 QuitInitiatedEvent (org.rstudio.studio.client.application.events.QuitInitiatedEvent)1