if (visible == true) {
Map contextsByName = new HashMap();
for (Iterator iterator = contextService.getDefinedContextIds()
.iterator(); iterator.hasNext();) {
Context context = contextService.getContext((String) iterator
.next());
try {
String name = context.getName();
Collection contexts = (Collection) contextsByName.get(name);
if (contexts == null) {
contexts = new HashSet();
contextsByName.put(name, contexts);
}
contexts.add(context);
} catch (final NotDefinedException e) {
// Do nothing.
}
}
Map commandsByName = new HashMap();
for (Iterator iterator = commandService.getDefinedCommandIds()
.iterator(); iterator.hasNext();) {
Command command = commandService.getCommand((String) iterator
.next());
if (!isActive(command)) {
continue;
}
try {
String name = command.getName();
Collection commands = (Collection) commandsByName.get(name);
if (commands == null) {
commands = new HashSet();
commandsByName.put(name, commands);
}
commands.add(command);
} catch (NotDefinedException eNotDefined) {
// Do nothing
}
}
// moved here to allow us to remove any empty categories
commandIdsByCategoryId = new HashMap();
for (Iterator iterator = commandService.getDefinedCommandIds()
.iterator(); iterator.hasNext();) {
final Command command = commandService
.getCommand((String) iterator.next());
if (!isActive(command)) {
continue;
}
try {
String categoryId = command.getCategory().getId();
Collection commandIds = (Collection) commandIdsByCategoryId
.get(categoryId);
if (commandIds == null) {
commandIds = new HashSet();
commandIdsByCategoryId.put(categoryId, commandIds);
}
commandIds.add(command.getId());
} catch (NotDefinedException eNotDefined) {
// Do nothing
}
}
Map categoriesByName = new HashMap();
for (Iterator iterator = commandService.getDefinedCategoryIds()
.iterator(); iterator.hasNext();) {
Category category = commandService
.getCategory((String) iterator.next());
try {
if (commandIdsByCategoryId.containsKey(category.getId())) {
String name = category.getName();
Collection categories = (Collection) categoriesByName
.get(name);
if (categories == null) {
categories = new HashSet();
categoriesByName.put(name, categories);
}
categories.add(category);
}
} catch (NotDefinedException eNotDefined) {
// Do nothing
}
}
Map schemesByName = new HashMap();
final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
for (int i = 0; i < definedSchemes.length; i++) {
final Scheme scheme = definedSchemes[i];
try {
String name = scheme.getName();
Collection schemes = (Collection) schemesByName.get(name);
if (schemes == null) {
schemes = new HashSet();
schemesByName.put(name, schemes);
}
schemes.add(scheme);
} catch (final NotDefinedException e) {
// Do nothing.
}
}
contextIdsByUniqueName = new HashMap();
contextUniqueNamesById = new HashMap();
for (Iterator iterator = contextsByName.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
Set contexts = (Set) entry.getValue();
Iterator iterator2 = contexts.iterator();
if (contexts.size() == 1) {
Context context = (Context) iterator2.next();
contextIdsByUniqueName.put(name, context.getId());
contextUniqueNamesById.put(context.getId(), name);
} else {
while (iterator2.hasNext()) {
Context context = (Context) iterator2.next();
String uniqueName = MessageFormat.format(
Util.translateString(RESOURCE_BUNDLE,
"uniqueName"), new Object[] { name, //$NON-NLS-1$
context.getId() });
contextIdsByUniqueName.put(uniqueName, context.getId());
contextUniqueNamesById.put(context.getId(), uniqueName);
}
}
}
categoryIdsByUniqueName = new HashMap();