/**
  * Returns the index of child in parent. If <code>parent</code> is <code>null</code> or <code>
  * child</code> is <code>null</code>, returns -1.
  *
  * @param parent a note in the tree, obtained from this data source
  * @param child the node we are interested in
  * @return the index of the child in the parent, or -1 if either <code>child</code> or <code>
  *     parent</code> are <code>null</code>
  */
 public int getIndexOfChild(Object parent, Object child) {
   if (parent instanceof CatalogDirectory && child instanceof Catalog) {
     CatalogDirectory catDir = (CatalogDirectory) parent;
     Catalog cat = (Catalog) child;
     return catDir.indexOf(cat);
   }
   return -1;
 }
  // Return a tree model event for an operation of the given catalog
  private TreeModelEvent _getTreeModelEvent(Catalog cat) {
    Object source = this;
    CatalogDirectory catDir = cat.getParent();

    Object[] path = null;
    int[] childIndices = null;
    Object[] children = null;
    if (catDir == null) {
      // must be the tree root
      path = new Catalog[1];
      path[0] = cat;
      childIndices = new int[] {0};
    } else {
      path = getPath(catDir);
      childIndices = new int[] {catDir.indexOf(cat)};
    }
    children = new Object[] {cat};

    return new TreeModelEvent(source, path, childIndices, children);
  }