map.put(url, name);
}
}
// Remove any unchecked catalog dirs from the main catalog list
final AstroCatConfig config = AstroCatConfig.getConfigFile();
for (Catalog cat : new ArrayList<Catalog>(config.getCatalogs())) {
if (cat instanceof VoCatalogDirectory) {
VoCatalogDirectory catDir = (VoCatalogDirectory) cat;
if (map.get(catDir.getURL().toString()) == null) {
config.removeCatalog(cat);
}
}
}
// Add any checked catalog dirs (this can take some time, so use background threads)
new SwingWorker() {
public Object construct() {
try {
for (String urlStr : map.keySet()) {
String name = map.get(urlStr);
URL url = new URL(urlStr);
CatalogDirectory dir = _findDir(config.getCatalogs(), url);
if (dir != null) {
dir.setName(name);
} else {
config.addCatalog(VoCatalogDirectory.getCatalogList(name, url));
}
}
return null;
} catch (Exception e) {
return e;
}
}
@Override
public void finished() {
Object o = getValue();
if (o instanceof Exception) {
DialogUtil.error((Exception) o);
} else {
setVisible(false);
config.save();
_fireChangeEvent();
}
}
}.start();
}