private void removeSelected() {
   CheckedTreeNode node = getSelectedToolNode();
   if (node != null) {
     int result =
         Messages.showYesNoDialog(
             this,
             ToolsBundle.message("tools.delete.confirmation"),
             CommonBundle.getWarningTitle(),
             Messages.getWarningIcon());
     if (result != 0) {
       return;
     }
     myIsModified = true;
     if (node.getUserObject() instanceof Tool) {
       Tool tool = (Tool) node.getUserObject();
       CheckedTreeNode parentNode = (CheckedTreeNode) node.getParent();
       ((ToolsGroup) parentNode.getUserObject()).removeElement(tool);
       removeNodeFromParent(node);
       if (parentNode.getChildCount() == 0) {
         removeNodeFromParent(parentNode);
       }
     } else if (node.getUserObject() instanceof ToolsGroup) {
       removeNodeFromParent(node);
     }
     update();
     myTree.requestFocus();
   }
 }
  private void editSelected() {
    CheckedTreeNode node = getSelectedToolNode();
    if (node != null && node.getUserObject() instanceof Tool) {
      Tool selected = (Tool) node.getUserObject();
      if (selected != null) {
        String oldGroupName = selected.getGroup();
        ToolEditorDialog dlg = new ToolEditorDialog(this);
        dlg.setData(selected, getGroups());
        dlg.show();
        if (dlg.isOK()) {
          selected.copyFrom(dlg.getData());
          String newGroupName = selected.getGroup();
          if (!Comparing.equal(oldGroupName, newGroupName)) {
            CheckedTreeNode oldGroupNode = (CheckedTreeNode) node.getParent();
            removeNodeFromParent(node);
            ((ToolsGroup) oldGroupNode.getUserObject()).removeElement(selected);
            if (oldGroupNode.getChildCount() == 0) {
              removeNodeFromParent(oldGroupNode);
            }

            insertNewTool(selected, true);
          } else {
            (getModel()).nodeChanged(node);
          }
          myIsModified = true;
          update();
        }
      }
    }
  }
  private ToolsGroup[] getGroupList() {
    ArrayList<ToolsGroup> result = new ArrayList<ToolsGroup>();
    MutableTreeNode root = (MutableTreeNode) myTree.getModel().getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
      final CheckedTreeNode node = (CheckedTreeNode) root.getChildAt(i);
      for (int j = 0; j < node.getChildCount(); j++) {
        final CheckedTreeNode toolNode = (CheckedTreeNode) node.getChildAt(j);
        ((Tool) toolNode.getUserObject()).setEnabled(toolNode.isChecked());
      }

      result.add((ToolsGroup) node.getUserObject());
    }

    return result.toArray(new ToolsGroup[result.size()]);
  }