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