public void ensureVisible(Project project) {
   if (project == null) {
     return;
   }
   ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
   if (toolWindowManager != null) {
     ToolWindow toolWindow = toolWindowManager.getToolWindow(COMMIT_LOGS_TOOLWINDOW_ID);
     if (toolWindow != null) {
       toolWindow.activate(null);
     }
   }
 }
 private void initialize() {
   if (!_isInitialized) {
     _isInitialized = true;
     _isDisposed = false;
     ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(_project);
     ToolWindow toolWindow =
         toolWindowManager.registerToolWindow(
             COMMIT_LOGS_TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM);
     toolWindow.setIcon(COMMIT_LOGS_SMALL_ICON);
     _contentManager = toolWindow.getContentManager();
     toolWindow.installWatcher(_contentManager);
     //      _contentManager =
     // PeerFactory.getInstance().getContentFactory().createContentManager(true, _project);
     _contentManager.addContentManagerListener(
         new ContentManagerAdapter() {
           @Override
           public void contentRemoved(ContentManagerEvent event) {
             JComponent component = event.getContent().getComponent();
             JComponent removedComponent =
                 (component instanceof CommitLogWindowComponent)
                     ? ((CommitLogWindowComponent) component).getComponent()
                     : component;
             //                    if (removedComponent == myErrorsView) {
             //                        myErrorsView.dispose();
             //                        myErrorsView = null;
             //                    } else
             for (Iterator iterator = _commitLogs.iterator(); iterator.hasNext(); ) {
               Editor editor = (Editor) iterator.next();
               if (removedComponent == editor.getComponent()) {
                 EditorFactory.getInstance().releaseEditor(editor);
                 iterator.remove();
               }
             }
           }
         });
     //      final JComponent component = _contentManager.getComponent();
   }
 }
  /** @return can be null if user cancelled operation */
  @Nullable
  public static AntBuildMessageView openBuildMessageView(
      Project project, AntBuildFileBase buildFile, String[] targets) {
    final VirtualFile antFile = buildFile.getVirtualFile();
    if (!LOG.assertTrue(antFile != null)) {
      return null;
    }

    // check if there are running instances of the same build file

    MessageView ijMessageView = MessageView.SERVICE.getInstance(project);
    Content[] contents = ijMessageView.getContentManager().getContents();
    for (Content content : contents) {
      if (content.isPinned()) {
        continue;
      }
      AntBuildMessageView buildMessageView = content.getUserData(KEY);
      if (buildMessageView == null) {
        continue;
      }

      if (!antFile.equals(buildMessageView.getBuildFile().getVirtualFile())) {
        continue;
      }

      if (buildMessageView.isStopped()) {
        ijMessageView.getContentManager().removeContent(content, true);
        continue;
      }

      int result =
          Messages.showYesNoCancelDialog(
              AntBundle.message("ant.is.active.terminate.confirmation.text"),
              AntBundle.message("starting.ant.build.dialog.title"),
              Messages.getQuestionIcon());

      switch (result) {
        case 0: // yes
          buildMessageView.stopProcess();
          ijMessageView.getContentManager().removeContent(content, true);
          continue;
        case 1: // no
          continue;
        default: // cancel
          return null;
      }
    }

    final AntBuildMessageView messageView = new AntBuildMessageView(project, buildFile, targets);
    String contentName = buildFile.getPresentableName();
    contentName = BUILD_CONTENT_NAME + " (" + contentName + ")";

    final Content content =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(messageView.getComponent(), contentName, true);
    content.putUserData(KEY, messageView);
    ijMessageView.getContentManager().addContent(content);
    ijMessageView.getContentManager().setSelectedContent(content);
    content.setDisposer(
        new Disposable() {
          @Override
          public void dispose() {
            Disposer.dispose(messageView.myAlarm);
          }
        });
    new CloseListener(content, ijMessageView.getContentManager(), project);
    // Do not inline next two variabled. Seeking for NPE.
    ToolWindow messageToolWindow =
        ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
    messageToolWindow.activate(null, false);
    return messageView;
  }