Source:
public AskSecretManager(final RStudioAPIServerOperations server, EventBus eventBus, final GlobalDisplay globalDisplay, final Satellite satellite, final SatelliteManager satelliteManager, final DependencyManager dependencyManager) { eventBus.addHandler(AskSecretEvent.TYPE, new AskSecretEvent.Handler() { private boolean handleAskSecret(String targetWindow) { String window = StringUtil.notNull(satellite.getSatelliteName()); if (window.equals(targetWindow)) return true; if (!Satellite.isCurrentWindowSatellite() && !satelliteManager.satelliteWindowExists(targetWindow)) return true; else return false; } @Override public void onAskSecret(final AskSecretEvent e) { if (!handleAskSecret(e.getWindow())) return; asksecretPending_ = true; AskSecretDialog dialog = new AskSecretDialog( e.getTitle(), e.getPrompt(), e.getCanRemember(), e.getHasSecret(), dependencyManager, new ProgressOperationWithInput<AskSecretDialogResult>() { @Override public void execute(final AskSecretDialogResult result, final ProgressIndicator indicator) { asksecretPending_ = false; RSAEncrypt.encrypt_ServerOnly( server, result.getSecret(), new RSAEncrypt.ResponseCallback() { @Override public void onSuccess(String encryptedData) { server.askSecretCompleted( encryptedData, result.getRemember(), result.getHasChanged(), new VoidServerRequestCallback(indicator)); } @Override public void onFailure(ServerError error) { Debug.logError(error); } }); } }, new Operation() { @Override public void execute() { asksecretPending_ = false; server.askSecretCompleted( null, false, false, new SimpleRequestCallback<Void>()); } } ); dialog.showModal(); } }); Window.addWindowClosingHandler(new ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { if (asksecretPending_) { asksecretPending_ = false; server.askSecretCompleted( null, false, false, new SimpleRequestCallback<Void>()); } } }); }

Target:
public AskSecretManager(final RStudioAPIServerOperations server, EventBus eventBus, final GlobalDisplay globalDisplay, final Satellite satellite, final SatelliteManager satelliteManager, final DependencyManager dependencyManager) { eventBus.addHandler(AskSecretEvent.TYPE, new AskSecretEvent.Handler() { private boolean handleAskSecret(String targetWindow) { String window = StringUtil.notNull(satellite.getSatelliteName()); if (window.equals(targetWindow)) return true; if (!Satellite.isCurrentWindowSatellite() && !satelliteManager.satelliteWindowExists(targetWindow)) return true; else return false; } @Override public void onAskSecret(final AskSecretEvent e) { if (!handleAskSecret(e.getWindow())) return; asksecretPending_ = true; AskSecretDialog dialog = new AskSecretDialog( e.getTitle(), e.getPrompt(), e.getCanRemember(), e.getHasSecret(), dependencyManager, new ProgressOperationWithInput<AskSecretDialogResult>() { @Override public void execute(final AskSecretDialogResult result, final ProgressIndicator indicator) { asksecretPending_ = false; RSAEncrypt.encrypt_ServerOnly( server, result.getSecret(), new RSAEncrypt.ResponseCallback() { @Override public void onSuccess(String encryptedData) { server.askSecretCompleted( encryptedData, result.getRemember(), result.getHasChanged(), new VoidServerRequestCallback(indicator)); } @Override public void onFailure(ServerError error) { Debug.logError(error); server.askSecretCompleted( null, false, false, new SimpleRequestCallback<Void>()); } }); } }, new Operation() { @Override public void execute() { asksecretPending_ = false; server.askSecretCompleted( null, false, false, new SimpleRequestCallback<Void>()); } } ); dialog.showModal(); } }); Window.addWindowClosingHandler(new ClosingHandler() { @Override public void onWindowClosing(ClosingEvent event) { if (asksecretPending_) { asksecretPending_ = false; server.askSecretCompleted( null, false, false, new SimpleRequestCallback<Void>()); } } }); }