RunContentDescriptor () { RunProfile profile = myEnvironment.getRunProfile(); if (ApplicationManager.getApplication().isUnitTestMode()) { return new RunContentDescriptor(profile, myExecutionResult, myUi); } ExecutionConsole console = myExecutionResult.getExecutionConsole(); RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi); AnAction[] consoleActionsToMerge; AnAction[] additionalActionsToMerge; Content consoleContent = null; if (console != null) { if (console instanceof ExecutionConsoleEx) { ((ExecutionConsoleEx)console).buildUi(myUi); } else { consoleContent = buildConsoleUiDefault(myUi, console); } initLogConsoles(profile, contentDescriptor, console); } if (consoleContent != null && myUi.getContentManager().getContentCount() == 1 && console instanceof TerminalExecutionConsole) { // TerminalExecutionConsole provides too few toolbar actions. Such console toolbar doesn't look good, but occupy // valuable space. // Let's show terminal console actions right in the main toolbar iff console content is the only one. // Otherwise (with multiple contents), it's unclear what content will be affected by a console action from // the main toolbar. consoleActionsToMerge = ((TerminalExecutionConsole)console).createConsoleActions(); // clear console toolbar actions to remove the console toolbar consoleContent.setActions(new DefaultActionGroup(), ActionPlaces.RUNNER_TOOLBAR, console.getComponent()); additionalActionsToMerge = AnAction.EMPTY_ARRAY; } else if (consoleContent != null && myUi.getContentManager().getContentCount() == 1 && console instanceof RunContentActionsContributor contributor) { consoleActionsToMerge = contributor.getActions(); additionalActionsToMerge = contributor.getAdditionalActions(); contributor.hideOriginalActions(); } else { consoleActionsToMerge = AnAction.EMPTY_ARRAY; additionalActionsToMerge = AnAction.EMPTY_ARRAY; } AnAction[] restartActions = contentDescriptor.getRestartActions(); initToolbars(restartActions, consoleActionsToMerge, additionalActionsToMerge); CustomActionsListener.subscribe(this, () -> { DefaultActionGroup updatedToolbar = createActionToolbar(restartActions, consoleActionsToMerge, additionalActionsToMerge); toolbar.removeAll(); toolbar.addAll(updatedToolbar.getChildren(null)); }); if (profile instanceof RunConfigurationBase) { if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) { ((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile, myProject, myEnvironment.getExecutor(), contentDescriptor, myUi), this); } } return contentDescriptor; }