void (@Nullable ProgressIndicator indicator) { if (myProject == null) return; // should we also wait for non-project process like MavenIndicesManager activities? if (indicator instanceof ProgressIndicatorEx) { myProject.getService(MavenProgressTracker.class).add(indicator); ((ProgressIndicatorEx)indicator).addStateDelegate(new AbstractProgressIndicatorExBase() { @Override public void start() { myProject.getService(MavenProgressTracker.class).add(indicator); } @Override public void stop() { myProject.getService(MavenProgressTracker.class).remove(indicator); } @Override public void cancel() { try { myProject.getService(MavenProgressTracker.class).remove(indicator); } catch (AlreadyDisposedException ignore) { } } }); } }