void (final @Nullable Project myProject, final @NotNull ProcessHandler processHandler, final @NotNull ExecutionMode mode, final @NotNull String presentableCmdline) { if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.debug("Running " + presentableCmdline); processHandler.waitFor(); return; } final String title = mode.getTitle() != null ? mode.getTitle() : ExecutionBundle.message("progress.title.please.wait"); final Runnable process; if (mode.cancelable()) { process = createCancelableExecutionProcess(processHandler, mode.shouldCancelFun()); } else { if (mode.getTimeout() <= 0) { process = () -> processHandler.waitFor(); } else { process = createTimeLimitedExecutionProcess(processHandler, mode, presentableCmdline); } } if (mode.withModalProgress() || !mode.inBackGround() && ApplicationManager.getApplication().isDispatchThread()) { ProgressManager.getInstance().runProcessWithProgressSynchronously(process, title, mode.cancelable(), myProject, mode.getProgressParentComponent()); } else if (mode.inBackGround()) { final Task task = new Task.Backgroundable(myProject, title, mode.cancelable()) { @Override public void run(final @NotNull ProgressIndicator indicator) { process.run(); } }; ProgressManager.getInstance().run(task); } else { final String title2 = mode.getTitle2(); final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null && title2 != null) { indicator.setText2(title2); } process.run(); } }