addedObject.setCommunityName(communityName);
  public void treeNodesInserted(TreeModelEvent e) {    Object[] addedNodes = e.getChildren();    // first, take remove action    for (int i = 0; i < addedNodes.length; i++)      removeNode((DefaultMutableTreeNode)addedNodes[i]);    // get parent of added nodes    DefaultMutableTreeNode node =      (DefaultMutableTreeNode)e.getTreePath().getLastPathComponent();    if (node.isRoot())      return; // don't do anything if adding to root    // find community this node belongs in and add info on the new entity    CommunityTreeObject cto = null;    while (node != null) {      cto = (CommunityTreeObject)node.getUserObject();      if (cto.isCommunity())        break;      node = (DefaultMutableTreeNode)node.getParent();    }    if (cto == null) {      if(log.isErrorEnabled()) {        log.error("Attempted to insert node that is not in a community: " +                  node);      }      return;    }    String communityName = cto.toString();    for (int i = 0; i < addedNodes.length; i++) {      node = (DefaultMutableTreeNode)addedNodes[i];      CommunityTreeObject addedObject =         (CommunityTreeObject)node.getUserObject();      if (!addedObject.isHost()) { // don't add info about hosts to database        String entityName = addedObject.toString();        CommunityDBUtils.insertEntityInfo(communityName, entityName,                                           "MemberType", addedObject.getType());        CommunityDBUtils.insertEntityInfo(communityName, entityName,                                          "Role", "Member");      }      addNode(node, communityName);    }  }