*/
private Map categorizeTocs(List tocs, List tocOrder) {
Map categorized = new HashMap();
Iterator iter = tocs.iterator();
while (iter.hasNext()) {
ITocContribution toc = (ITocContribution)iter.next();
String categoryId;
try {
categoryId = toc.getCategoryId();
}
catch (Throwable t) {
// log and skip
String msg = "Error retrieving categoryId from " + ITocContribution.class.getName() + ": " + toc.getClass().getName(); //$NON-NLS-1$ //$NON-NLS-2$
HelpPlugin.logError(msg, t);
continue;
}
if (categoryId != null) {
// it has a category, add it to the appropriate TocCategory
TocCategory category = (TocCategory)categorized.get(categoryId);
if (category == null) {
// create categories as needed
category = new TocCategory(categoryId);
categorized.put(categoryId, category);
tocOrder.add(categoryId);
}
category.add(toc);
}
else {
// doesn't have a category; insert the TOC directly
String id;
try {
id = toc.getId();
}
catch (Throwable t) {
// log and skip
String msg = "Error retrieving id from " + ITocContribution.class.getName() + ": " + toc.getClass().getName(); //$NON-NLS-1$ //$NON-NLS-2$
HelpPlugin.logError(msg, t);
continue;
}
categorized.put(id, toc);
tocOrder.add(id);