Search in sources :

Example 1 with QuitContext

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.");
    }
}
Also used : QuitContext(org.rstudio.studio.client.application.ApplicationQuit.QuitContext) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) Operation(org.rstudio.core.client.widget.Operation)

Example 2 with QuitContext

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());
        }
    });
}
Also used : QuitContext(org.rstudio.studio.client.application.ApplicationQuit.QuitContext)

Aggregations

QuitContext (org.rstudio.studio.client.application.ApplicationQuit.QuitContext)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ArrayList (java.util.ArrayList)1 Operation (org.rstudio.core.client.widget.Operation)1