public static void executeExternalProcess( @Nullable final Project myProject, @NotNull final ProcessHandler processHandler, @NotNull final ExecutionMode mode, @NotNull final String presentableCmdline) { final String title = mode.getTitle() != null ? mode.getTitle() : "Please wait..."; assert title != null; final Runnable process; if (mode.cancelable()) { process = createCancelableExecutionProcess(processHandler, mode.shouldCancelFun()); } else { if (mode.getTimeout() <= 0) { process = new Runnable() { public void run() { processHandler.waitFor(); } }; } else { process = createTimelimitedExecutionProcess( processHandler, mode.getTimeout(), presentableCmdline); } } if (mode.withModalProgress()) { ProgressManager.getInstance() .runProcessWithProgressSynchronously( process, title, mode.cancelable(), myProject, mode.getProgressParentComponent()); } else if (mode.inBackGround()) { final Task task = new Task.Backgroundable(myProject, title, mode.cancelable()) { public void run(@NotNull final 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(); } }