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 = createToolEditorDialog(ToolsBundle.message("tools.edit.title"));
        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 CheckedTreeNode insertNewGroup(final ToolsGroup<Tool> groupCopy) {
    CheckedTreeNode root = getTreeRoot();
    CheckedTreeNode groupNode = new CheckedTreeNode(groupCopy);
    root.add(groupNode);
    for (Tool tool : groupCopy.getElements()) {
      insertNewTool(groupNode, tool);
    }

    return groupNode;
  }