public int addTab(
     String s,
     JComponent component,
     boolean selectTab,
     boolean replaceContent,
     boolean lockable,
     boolean addDefaultToolbar,
     ActionGroup toolbarActions,
     String helpId) {
   int existing = getComponentNumNamed(s);
   ContentManager contentManager = getContentManager();
   if (existing != -1) {
     Content existingContent = contentManager.getContent(existing);
     if (!replaceContent) {
       contentManager.setSelectedContent(existingContent);
       return existing;
     }
     //            if (!existingContent.isPinned()) {
     //                getContentManager().removeContent(existingContent);
     //                existingContent.release();
     //            }
   }
   CommitLogWindowComponent newComponent =
       new CommitLogWindowComponent(
           component, addDefaultToolbar, toolbarActions, contentManager, helpId);
   Content content =
       ContentFactory.SERVICE
           .getInstance()
           .createContent(newComponent.getShownComponent(), s, lockable);
   newComponent.setContent(content);
   contentManager.addContent(content);
   return getComponentAt(contentManager.getContentCount() - 1, selectTab);
 }
Exemple #2
0
  public void initToolWindow(ToolWindow toolWindow) {
    // Create panels

    Content allTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(null, IdeBundle.message("title.project"), false);
    myAllTodos =
        new TodoPanel(myProject, myAllPanelSettings, false, allTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            AllTodosTreeBuilder builder = new AllTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    allTodosContent.setComponent(myAllTodos);
    Disposer.register(this, myAllTodos);

    Content currentFileTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(null, IdeBundle.message("title.todo.current.file"), false);
    myCurrentFileTodos =
        new CurrentFileTodosPanel(myProject, myCurrentPanelSettings, currentFileTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            CurrentFileTodosTreeBuilder builder =
                new CurrentFileTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    Disposer.register(this, myCurrentFileTodos);
    currentFileTodosContent.setComponent(myCurrentFileTodos);

    myChangeListTodosContent =
        ContentFactory.SERVICE
            .getInstance()
            .createContent(
                null,
                IdeBundle.message(
                    "changelist.todo.title",
                    ChangeListManager.getInstance(myProject).getDefaultChangeList().getName()),
                false);
    myChangeListTodos =
        new ChangeListTodosPanel(myProject, myCurrentPanelSettings, myChangeListTodosContent) {
          protected TodoTreeBuilder createTreeBuilder(
              JTree tree, DefaultTreeModel treeModel, Project project) {
            ChangeListTodosTreeBuilder builder =
                new ChangeListTodosTreeBuilder(tree, treeModel, project);
            builder.init();
            return builder;
          }
        };
    Disposer.register(this, myChangeListTodos);
    myChangeListTodosContent.setComponent(myChangeListTodos);

    myContentManager = toolWindow.getContentManager();

    myContentManager.addContent(allTodosContent);
    myContentManager.addContent(currentFileTodosContent);
    if (myVCSManager.getAllActiveVcss().length > 0) {
      myVcsListener.myIsVisible = true;
      myContentManager.addContent(myChangeListTodosContent);
    }

    Content content = myContentManager.getContent(mySelectedIndex);
    content = content == null ? allTodosContent : content;
    myContentManager.setSelectedContent(content);
  }