void () { final MyProgressIndicator progress = new MyProgressIndicator(); progress.setModalityProgress(null); final String title = getProgressText(); if (title != null) { myTitleLabel.setText(title); } showCard(PROGRESS_PANEL); myProgressIndicator = progress; if (ApplicationManager.getApplication().isUnitTestMode()) { Result result = ProgressManager.getInstance().runProcess(this::calculate, progress); onFinished(result, false); return; } UiNotifyConnector.doWhenFirstShown(myPanel, () -> new SwingWorker<Result>() { @Override public Result construct() { LOG.debug("Start calculation in " + AbstractStepWithProgress.this + " using worker " + toString()); final Ref<Result> result = Ref.create(null); try { ProgressManager.getInstance().runProcess(() -> result.set(calculate()), progress); LOG.debug("Finish calculation in " + AbstractStepWithProgress.this + " using worker " + toString()); } catch (ProcessCanceledException e) { LOG.debug("Calculation in " + AbstractStepWithProgress.this + " was cancelled"); } return result.get(); } @Override public void finished() { LOG.debug("Schedule showing results for " + AbstractStepWithProgress.this + " using worker " + toString()); myProgressIndicator = null; ApplicationManager.getApplication().invokeLater(() -> { LOG.debug("Show results for " + AbstractStepWithProgress.this); final Result result = get(); onFinished(result, progress.isCanceled()); showCard(RESULTS_PANEL); }); } }.start()); }