void (@NotNull Disposable parentDisposable, @NotNull Runnable callback) { if (ApplicationManager.getApplication().isActive()) { callback.run(); } else { Disposable listenerDisposable = Disposer.newDisposable(); Disposer.register(parentDisposable, listenerDisposable); ApplicationManager.getApplication().getMessageBus().connect(listenerDisposable) .subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() { @Override public void applicationActivated(@NotNull IdeFrame ideFrame) { Disposer.dispose(listenerDisposable); callback.run(); } }); } }