Search in sources :

Example 1 with ConflictModel

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);
}
Also used : KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) Binding(org.eclipse.jface.bindings.Binding) KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) BindingElement(org.eclipse.ui.internal.keys.model.BindingElement) ConflictModel(org.eclipse.ui.internal.keys.model.ConflictModel) Collection(java.util.Collection) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Aggregations

Collection (java.util.Collection)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 Binding (org.eclipse.jface.bindings.Binding)1 KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)1 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)1 BindingElement (org.eclipse.ui.internal.keys.model.BindingElement)1 ConflictModel (org.eclipse.ui.internal.keys.model.ConflictModel)1