use of org.eclipse.ui.internal.keys.model.ConflictModel in project translationstudio8 by heartsome.
the class BindingModel2 method remove.
/**
* Removes the <code>bindingElement</code> binding.
* @param bindingElement
*/
public void remove(BindingElement bindingElement) {
if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) {
return;
}
KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject();
if (keyBinding.getType() == Binding.USER) {
bindingManager.removeBinding(keyBinding);
} else {
KeySequence keySequence = keyBinding.getKeySequence();
// Add the delete binding
bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding.getContextId(), null, null, null, Binding.USER));
// Unbind any conflicts affected by the delete binding
ConflictModel conflictModel = controller.getConflictModel();
conflictModel.updateConflictsFor(bindingElement);
Collection conflictsList = conflictModel.getConflicts();
if (conflictsList != null) {
Object[] conflicts = conflictsList.toArray();
for (int i = 0; i < conflicts.length; i++) {
BindingElement be = (BindingElement) conflicts[i];
if (be == bindingElement) {
continue;
}
Object modelObject = be.getModelObject();
if (modelObject instanceof Binding) {
Binding binding = (Binding) modelObject;
if (binding.getType() != Binding.SYSTEM) {
continue;
}
ParameterizedCommand pCommand = binding.getParameterizedCommand();
be.fill(pCommand);
commandToElement.put(pCommand, be);
}
}
}
}
ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand();
bindingElement.fill(parameterizedCommand);
commandToElement.put(parameterizedCommand, bindingElement);
controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement);
}
Aggregations