// Write the simple preference key to the UI preference store.
writeActiveScheme(activeScheme);
// Build the XML block for writing the bindings and active scheme.
final XMLMemento xmlMemento = XMLMemento
.createWriteRoot(EXTENSION_COMMANDS);
if (activeScheme != null) {
writeActiveSchemeToPreferences(xmlMemento, activeScheme);
}
if (bindings != null) {
final int bindingsLength = bindings.length;
for (int i = 0; i < bindingsLength; i++) {
final Binding binding = bindings[i];
if (binding.getType() == Binding.USER) {
writeBindingToPreferences(xmlMemento, binding);
}
}
}
// Write the XML block to the workbench preference store.
final IPreferenceStore preferenceStore = WorkbenchPlugin.getDefault()
.getPreferenceStore();
final Writer writer = new StringWriter();
try {
xmlMemento.save(writer);
preferenceStore.setValue(EXTENSION_COMMANDS, writer.toString());
} finally {
writer.close();
}
}