Set addSystemAll = new HashSet();
ArrayList removeUser = new ArrayList();
ArrayList removeBinding = new ArrayList();
Binding[] bindings = localChangeManager.getBindings();
for (int i = 0; i < bindings.length; i++) {
final Binding b = bindings[i];
if (b.getParameterizedCommand() == null
&& localMatches(b.getLocale())
&& platformMatches(b.getPlatform())) {
// flat out, a delete marker
removeBinding.add(b);
} else if (cmd.equals(b.getParameterizedCommand())) {
if (b.getType() == Binding.SYSTEM
&& localMatches(b.getLocale())
&& platformMatches(b.getPlatform())) {
// a system binding for this command
addSystemAll.add(b);
} else if (b.getType() == Binding.USER) {
// a user binding for this command
removeUser.add(b);
localChangeManager.removeBinding(b);
}
}
}
if (!addSystemAll.isEmpty()) {
String[] activeSchemeIds = getSchemeIds(getSchemeId());
Binding[] sysArray = (Binding[]) addSystemAll
.toArray(new Binding[addSystemAll.size()]);
for (int k = 0; k < sysArray.length; k++) {
Binding sys = sysArray[k];
boolean deleted = false;
for (Iterator i = removeBinding.iterator(); i.hasNext();) {
Binding del = (Binding) i.next();
if (deletes(del, sys)) {
if (del.getType() == Binding.USER) {
removeUser.add(del);
localChangeManager.removeBinding(del);
} else {
deleted = true;
addSystemAll.remove(sys);