use of org.rstudio.studio.client.application.ApplicationQuit.QuitContext in project rstudio by rstudio.
the class DesktopApplicationHeader method respondToUpdateCheck.
private void respondToUpdateCheck(final UpdateCheckResult result, boolean manual) {
boolean ignoredUpdate = false;
if (result.getUpdateVersion().length() > 0) {
JsArrayString ignoredUpdates = ignoredUpdates_.getIgnoredUpdates();
for (int i = 0; i < ignoredUpdates.length(); i++) {
if (ignoredUpdates.get(i).equals(result.getUpdateVersion())) {
ignoredUpdate = true;
}
}
}
if (result.getUpdateVersion().length() > 0 && !ignoredUpdate) {
ArrayList<String> buttonLabels = new ArrayList<String>();
ArrayList<Operation> buttonOperations = new ArrayList<Operation>();
buttonLabels.add("Quit and Download...");
buttonOperations.add(new Operation() {
@Override
public void execute() {
appQuit_.prepareForQuit("Update RStudio", new QuitContext() {
@Override
public void onReadyToQuit(boolean saveChanges) {
Desktop.getFrame().browseUrl(result.getUpdateUrl());
appQuit_.performQuit(saveChanges);
}
});
}
});
buttonLabels.add("Remind Later");
buttonOperations.add(new Operation() {
@Override
public void execute() {
// Don't do anything here; the prompt will re-appear the next
// time we do an update check
}
});
// Only provide the option to ignore the update if it's not urgent.
if (result.getUpdateUrgency() == 0) {
buttonLabels.add("Ignore Update");
buttonOperations.add(new Operation() {
@Override
public void execute() {
ignoredUpdates_.addIgnoredUpdate(result.getUpdateVersion());
ignoredUpdatesDirty_ = true;
}
});
}
globalDisplay_.showGenericDialog(GlobalDisplay.MSG_QUESTION, "Update Available", result.getUpdateMessage(), buttonLabels, buttonOperations, 0);
} else if (manual) {
globalDisplay_.showMessage(GlobalDisplay.MSG_INFO, "No Update Available", "You're using the newest version of RStudio.");
}
}
use of org.rstudio.studio.client.application.ApplicationQuit.QuitContext in project rstudio by rstudio.
the class Application method onSwitchToRVersion.
@Override
public void onSwitchToRVersion(final SwitchToRVersionEvent event) {
final ApplicationQuit applicaitonQuit = pApplicationQuit_.get();
applicaitonQuit.prepareForQuit("Switch R Version", new QuitContext() {
public void onReadyToQuit(boolean saveChanges) {
// see if we have a project (otherwise switch to "None")
String project = session_.getSessionInfo().getActiveProjectFile();
if (project == null)
project = Projects.NONE;
// do the quit
applicaitonQuit.performQuit(saveChanges, project, event.getRVersionSpec());
}
});
}
Aggregations