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();
categoryUniqueNamesById = new HashMap();
for (Iterator iterator = categoriesByName.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
Set categories = (Set) entry.getValue();
Iterator iterator2 = categories.iterator();
if (categories.size() == 1) {
Category category = (Category) iterator2.next();
categoryIdsByUniqueName.put(name, category.getId());
categoryUniqueNamesById.put(category.getId(), name);
} else {
while (iterator2.hasNext()) {
Category category = (Category) iterator2.next();
String uniqueName = MessageFormat.format(
Util.translateString(RESOURCE_BUNDLE,
"uniqueName"), new Object[] { name, //$NON-NLS-1$
category.getId() });
categoryIdsByUniqueName.put(uniqueName, category
.getId());
categoryUniqueNamesById.put(category.getId(),
uniqueName);
}
}
}
schemeIdsByUniqueName = new HashMap();
schemeUniqueNamesById = new HashMap();
for (Iterator iterator = schemesByName.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
Set keyConfigurations = (Set) entry.getValue();
Iterator iterator2 = keyConfigurations.iterator();
if (keyConfigurations.size() == 1) {
Scheme scheme = (Scheme) iterator2.next();
schemeIdsByUniqueName.put(name, scheme.getId());
schemeUniqueNamesById.put(scheme.getId(), name);
} else {
while (iterator2.hasNext()) {
Scheme scheme = (Scheme) iterator2.next();
String uniqueName = MessageFormat.format(
Util.translateString(RESOURCE_BUNDLE,
"uniqueName"), new Object[] { name, //$NON-NLS-1$
scheme.getId() });
schemeIdsByUniqueName.put(uniqueName, scheme.getId());
schemeUniqueNamesById.put(scheme.getId(), uniqueName);
}
}
}
Scheme activeScheme = bindingService.getActiveScheme();
// Make an internal copy of the binding manager, for local changes.
try {
for (int i = 0; i < definedSchemes.length; i++) {
final Scheme scheme = definedSchemes[i];
final Scheme copy = localChangeManager.getScheme(scheme
.getId());
copy.define(scheme.getName(), scheme.getDescription(),
scheme.getParentId());
}
localChangeManager.setActiveScheme(bindingService
.getActiveScheme());
} catch (final NotDefinedException e) {