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 void insertNewTool(final Tool newTool, boolean setSelection) {
   CheckedTreeNode groupNode = findGroupNode(newTool.getGroup());
   if (groupNode == null) {
     groupNode = insertNewGroup(new ToolsGroup(newTool.getGroup()));
     nodeWasInserted(groupNode);
   }
   CheckedTreeNode tool = insertNewTool(groupNode, newTool);
   if (setSelection) {
     TreePath treePath = new TreePath(tool.getPath());
     myTree.expandPath(treePath);
     myTree.getSelectionModel().setSelectionPath(treePath);
   }
   myIsModified = true;
 }