private CheckedTreeNode insertNewTool(final CheckedTreeNode groupNode, final Tool toolCopy) {
   CheckedTreeNode toolNode = new CheckedTreeNode(toolCopy);
   toolNode.setChecked(toolCopy.isEnabled());
   ((ToolsGroup) groupNode.getUserObject()).addElement(toolCopy);
   groupNode.add(toolNode);
   nodeWasInserted(toolNode);
   return toolNode;
 }
 @Override
 protected void onNodeStateChanged(CheckedTreeNode node) {
   final List<DetectedFrameworkDescription> checked =
       Arrays.asList(getCheckedNodes(DetectedFrameworkDescription.class, null));
   final List<DetectedFrameworkDescription> disabled =
       FrameworkDetectionUtil.getDisabledDescriptions(
           checked, Collections.<DetectedFrameworkDescription>emptyList());
   for (DetectedFrameworkDescription description : disabled) {
     final DefaultMutableTreeNode treeNode = TreeUtil.findNodeWithObject(getRoot(), description);
     if (treeNode instanceof CheckedTreeNode) {
       ((CheckedTreeNode) treeNode).setChecked(false);
     }
   }
 }
 private void rebuildTree() {
   final TreeStateSnapshot treeStateSnapshot = new TreeStateSnapshot(this);
   myRootNode.removeAllChildren();
   myDescriptorToNodeMap.clear();
   myDescriptorToNodeMap.put((TreeDescriptor) myRootNode.getUserObject(), myRootNode);
   // build tree
   for (final Breakpoint breakpoint : myBreakpoints) {
     CheckedTreeNode node = createNode(new BreakpointDescriptor(breakpoint));
     node.setChecked(breakpoint.ENABLED);
     addNode(node);
   }
   // remove all package nodes with one child
   final int count = myRootNode.getChildCount();
   final List<CheckedTreeNode> children = new ArrayList<CheckedTreeNode>();
   for (int idx = 0; idx < count; idx++) {
     CheckedTreeNode child = (CheckedTreeNode) myRootNode.getChildAt(idx);
     if (!(child.getUserObject() instanceof PackageDescriptor)) {
       children.add(child);
       continue;
     }
     while (child.getUserObject() instanceof PackageDescriptor && child.getChildCount() <= 1) {
       child = (CheckedTreeNode) child.getChildAt(0);
     }
     if (!(child.getUserObject() instanceof PackageDescriptor)) {
       child = (CheckedTreeNode) child.getParent();
     }
     for (CheckedTreeNode childToRemove = (CheckedTreeNode) child.getParent();
         !childToRemove.equals(myRootNode);
         childToRemove = (CheckedTreeNode) childToRemove.getParent()) {
       myDescriptorToNodeMap.remove(childToRemove.getUserObject());
     }
     children.add(child);
   }
   for (final CheckedTreeNode aChildren : children) {
     aChildren.removeFromParent();
   }
   myRootNode.removeAllChildren();
   for (final CheckedTreeNode child : children) {
     myRootNode.add(child);
   }
   sortChildren(myRootNode);
   ((DefaultTreeModel) getModel()).nodeStructureChanged(myRootNode);
   treeStateSnapshot.restore(this);
   expandPath(new TreePath(myRootNode));
 }
 /**
  * Update the tree according to the list of loaded roots
  *
  * @param roots the list of roots to add to the tree
  * @param uncheckedCommits the map from vcs root to commit identifiers that should be
  *     uncheckedCommits
  */
 private void updateTree(List<Root> roots, Map<VirtualFile, Set<String>> uncheckedCommits) {
   myTreeRoot.removeAllChildren();
   if (roots == null) {
     roots = Collections.emptyList();
   }
   for (Root r : roots) {
     CheckedTreeNode rootNode = new CheckedTreeNode(r);
     Status status = new Status();
     status.root = r;
     rootNode.add(new DefaultMutableTreeNode(status, false));
     Set<String> unchecked =
         uncheckedCommits != null && uncheckedCommits.containsKey(r.root)
             ? uncheckedCommits.get(r.root)
             : Collections.<String>emptySet();
     for (Commit c : r.commits) {
       CheckedTreeNode child = new CheckedTreeNode(c);
       rootNode.add(child);
       child.setChecked(r.remoteName != null && !unchecked.contains(c.commitId()));
     }
     myTreeRoot.add(rootNode);
   }
 }
 private static void changeNodeState(final CheckedTreeNode node, final boolean checked) {
   if (node.isChecked() != checked) {
     node.setChecked(checked);
   }
 }