コード例 #1
0
  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;
  }
コード例 #2
0
 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;
 }