*/
synchronized void refreshList(final boolean bReload) {
Thread t = new Thread() {
public void run() {
locationMap.clear();
BundleRecord brOld = brSelected != null ? brSelected.getBundleRecord() : null;
setRootText(STR_LOADING);
rootNode = new TopNode(STR_TOPNAME);
treeModel = new DefaultTreeModel(rootNode);
BundleRepositoryService obr = getOBR();
if(obr != null) {
if(bReload) {
obrErr = "";
try {
assertRepoURLs(obr.getRepositoryURLs());
obr.setRepositoryURLs(obr.getRepositoryURLs());
} catch (Exception e) {
obrErr =
"<b>" + e.getClass().getName() + "</b>"+
"<pre>\n" +
e.getMessage() +
"</pre>";
}
}
int count = obr.getBundleRecordCount();
// String (category) -> Set (BundleRecord)
Map categories = new TreeMap(new Comparator() {
public int compare(Object o1, Object o2) {
return o1.toString().compareToIgnoreCase(o2.toString());
}
});
// move all bundle records into a sorted
// category map of sets
for(int i = 0; i < count; i++) {
BundleRecord br = obr.getBundleRecord(i);
String loc = (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);
String category = "other";
if(sortCategory == SORT_CATEGORY) {
category = Util.getAttribute(br,
BundleRecord.BUNDLE_CATEGORY,
"[no category]");
} else if(sortCategory == SORT_VENDOR) {
category = Util.getAttribute(br,
BundleRecord.BUNDLE_VENDOR,
"[no vendor]");
} else if(sortCategory == SORT_STATUS) {
if(isInstalled(br)) {
category = "Installed";
} else {
category = "Not installed";
}
} else if(sortCategory == SORT_NONE) {
category = SORT_NAMES[SORT_NONE];
} else {
int ix = loc.indexOf(":");
if(ix != -1) {
category = loc.substring(0, ix);
if(loc.startsWith("http://")) {
ix = loc.indexOf("/", 8);
if(ix != -1) {
category = loc.substring(0, ix);
}
} else {
ix = loc.indexOf("/", ix + 1);
if(ix != -1) {
category = loc.substring(0, ix);
} else {
ix = loc.indexOf("\\", ix + 1);
if(ix != -1) {
category = loc.substring(0, ix);
}
}
}
}
}
Set set = (Set)categories.get(category);
if(set == null) {
set = new TreeSet(new BRComparator());
categories.put(category, set);
}
set.add(br);
}
int i = 0;
DefaultMutableTreeNode selNode = null;
for(Iterator it = categories.keySet().iterator(); it.hasNext();) {
String category = (String)it.next();
Set set = (Set)categories.get(category);
final DefaultMutableTreeNode categoryNode =
new CategoryNode(category);
for(Iterator it2 = set.iterator(); it2.hasNext();) {
BundleRecord br = (BundleRecord)it2.next();
DefaultMutableTreeNode brNode = new OBRNode(br);
categoryNode.add(brNode);
i++;
String loc = (String)br.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION);
locationMap.put(loc, brNode);
if(brOld != null && loc.equals(brOld.getAttribute(BundleRecord.BUNDLE_UPDATELOCATION))) {
selNode = brNode;