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);
}
}
}
Aggregations