/**
   * Add the given catalog to the catalog list if it is not already there. If a separate catalog
   * with the same name is in the list, the user is asked if it should be removed.
   */
  public void addCatalog(int index, Catalog cat) {
    // check for duplicates
    int i = _catalogs.indexOf(cat);
    if (i != -1) {
      return;
    }

    // check if it is a catalog with the same name (maybe from a different config file)
    String name = cat.getName();
    Catalog oldCat = getCatalog(name);
    int size = _catalogs.size();
    if (oldCat != null) {
      int ans = DialogUtil.confirm(name + " already exists. Do you want to replace it?");
      if (ans != JOptionPane.YES_OPTION) return;
      removeCatalog(oldCat);
      size--;
    }

    if (index < 0 || index >= size) _catalogs.add(cat);
    else _catalogs.add(index, cat);

    cat.setParent(this);
    CatalogFactory.registerCatalog(cat, isLocal());
    _fireTreeNodesInserted(_getTreeModelEvent(cat));
  }
 /** Set the list of catalogs in this catalog directory. */
 public void setCatalogs(List catalogs) {
   _catalogs = catalogs;
   int n = _catalogs.size();
   for (int i = 0; i < n; i++) {
     Catalog cat = (Catalog) _catalogs.get(i);
     cat.setParent(this);
     CatalogFactory.registerCatalog(cat, isLocal());
   }
   _fireTreeStructureChanged(_getTreeModelEvent(this));
 }