Search in sources :

Example 1 with RestartStatusEvent

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

the class ApplicationQuit method onSuspendAndRestart.

@Override
public void onSuspendAndRestart(final SuspendAndRestartEvent event) {
    // Ignore nested restarts once restart starts
    if (suspendingAndRestarting_)
        return;
    // set restart pending for desktop
    setPendinqQuit(DesktopFrame.PENDING_QUIT_AND_RESTART);
    final TimedProgressIndicator progress = new TimedProgressIndicator(globalDisplay_.getProgressIndicator("Error"));
    progress.onTimedProgress("Restarting R", 1000);
    final Operation onRestartComplete = new Operation() {

        @Override
        public void execute() {
            suspendingAndRestarting_ = false;
            progress.onCompleted();
        }
    };
    // perform the suspend and restart
    suspendingAndRestarting_ = true;
    eventBus_.fireEvent(new RestartStatusEvent(RestartStatusEvent.RESTART_INITIATED));
    server_.suspendForRestart(event.getSuspendOptions(), new VoidServerRequestCallback() {

        @Override
        protected void onSuccess() {
            // send pings until the server restarts
            sendPing(event.getAfterRestartCommand(), 200, 25, new Command() {

                @Override
                public void execute() {
                    onRestartComplete.execute();
                    eventBus_.fireEvent(new RestartStatusEvent(RestartStatusEvent.RESTART_COMPLETED));
                }
            });
        }

        @Override
        protected void onFailure() {
            onRestartComplete.execute();
            eventBus_.fireEvent(new RestartStatusEvent(RestartStatusEvent.RESTART_COMPLETED));
            setPendinqQuit(DesktopFrame.PENDING_QUIT_NONE);
        }
    });
}
Also used : TimedProgressIndicator(org.rstudio.studio.client.common.TimedProgressIndicator) Command(com.google.gwt.user.client.Command) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) RestartStatusEvent(org.rstudio.studio.client.application.events.RestartStatusEvent) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) 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 RestartStatusEvent (org.rstudio.studio.client.application.events.RestartStatusEvent)1 TimedProgressIndicator (org.rstudio.studio.client.common.TimedProgressIndicator)1 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)1