Ejemplo n.º 1
0
  /**
   * 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));
  }
Ejemplo n.º 2
0
  /** Remove the given catalog from the catalog list. */
  public void removeCatalog(Catalog cat) {
    // event needs state before removing from tree
    TreeModelEvent tme = _getTreeModelEvent(cat);

    _catalogs.remove(cat);
    _fireTreeNodesRemoved(tme);
    cat.setParent(null);
    CatalogFactory.unregisterCatalog(cat);
  }
Ejemplo n.º 3
0
 /** 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));
 }
Ejemplo n.º 4
0
 /**
  * Return a list of name servers (Catalogs with serv_type equal to "namesvr") to use to resolve
  * astronomical object names.
  */
 public List getNameServers() {
   return CatalogFactory.getCatalogsByType(Catalog.NAME_SERVER);
 }