void () { FileDocumentManager.getInstance().saveAllDocuments(); // Use user-provided console if exist. Create new otherwise ConsoleView view = (myUserProvidedConsole != null ? myUserProvidedConsole : createConsole()); view.attachToProcess(myProcess); if (myAfterCompletion != null) { myProcess.addProcessListener(new ProcessAdapter() { @Override public void processTerminated(@NotNull ProcessEvent event) { ApplicationManager.getApplication().invokeLater(myAfterCompletion); } }); } myProcess.startNotify(); }