public static Collection<RunContentDescriptor> findRunningConsole( final Project project, @NotNull final NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) { final ExecutionManager executionManager = ExecutionManager.getInstance(project); final RunContentDescriptor selectedContent = executionManager.getContentManager().getSelectedContent(); if (selectedContent != null) { final ToolWindow toolWindow = ExecutionManager.getInstance(project) .getContentManager() .getToolWindowByDescriptor(selectedContent); if (toolWindow != null && toolWindow.isVisible()) { if (descriptorMatcher.fun(selectedContent)) { return Collections.singletonList(selectedContent); } } } final ArrayList<RunContentDescriptor> result = Lists.newArrayList(); final RunContentDescriptor[] runContentDescriptors = ((RunContentManagerImpl) executionManager.getContentManager()).getAllDescriptors(); for (RunContentDescriptor runContentDescriptor : runContentDescriptors) { if (descriptorMatcher.fun(runContentDescriptor)) { result.add(runContentDescriptor); } } return result; }
public static List<RunContentDescriptor> collectConsolesByDisplayName( final Project project, @NotNull NotNullFunction<String, Boolean> titleMatcher) { List<RunContentDescriptor> result = Lists.newArrayList(); final ExecutionManager executionManager = ExecutionManager.getInstance(project); final RunContentDescriptor[] runContentDescriptors = ((RunContentManagerImpl) executionManager.getContentManager()).getAllDescriptors(); for (RunContentDescriptor runContentDescriptor : runContentDescriptors) { if (titleMatcher.fun(runContentDescriptor.getDisplayName())) { result.add(runContentDescriptor); } } return result; }
public static void runConfiguration( @NotNull RunnerAndConfigurationSettings configuration, @NotNull Executor executor) { ExecutionEnvironmentBuilder builder = createEnvironment(executor, configuration); if (builder != null) { ExecutionManager.getInstance(configuration.getConfiguration().getProject()) .restartRunProfile(builder.activeTarget().build()); } }
@Override public void actionPerformed(final AnActionEvent e) { Project project = myEnvironment.getProject(); if (project == null) return; if (myProcessHandler != null) { ExecutionManager.getInstance(project) .restartRunProfile( project, myExecutor, myEnvironment.getExecutionTarget(), myEnvironment.getRunnerAndConfigurationSettings(), myProcessHandler); } else { ExecutionManager.getInstance(project) .restartRunProfile( project, myExecutor, myEnvironment.getExecutionTarget(), myEnvironment.getRunnerAndConfigurationSettings(), myDescriptor); } }
protected void showConsole(Executor defaultExecutor, RunContentDescriptor myDescriptor) { // Show in run toolwindow ExecutionManager.getInstance(myProject) .getContentManager() .showRunContent(defaultExecutor, myDescriptor); // Request focus final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(defaultExecutor.getId()); window.activate( new Runnable() { public void run() { IdeFocusManager.getInstance(myProject) .requestFocus(getLanguageConsole().getCurrentEditor().getContentComponent(), true); } }); }
public static void restart(@NotNull ExecutionEnvironment environment) { if (!ExecutorRegistry.getInstance().isStarting(environment)) { ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment); } }