Search in sources :

Example 6 with KeyBinding

use of org.eclipse.jface.bindings.keys.KeyBinding in project translationstudio8 by heartsome.

the class BindingModel2 method restoreBinding.

/**
	 * Restores the currently selected binding.
	 * @param contextModel
	 */
public void restoreBinding(ContextModel contextModel) {
    BindingElement element = (BindingElement) getSelectedElement();
    if (element == null) {
        return;
    }
    restoreBinding(element);
    refresh(contextModel);
    Object obj = element.getModelObject();
    ParameterizedCommand cmd = null;
    if (obj instanceof ParameterizedCommand) {
        cmd = (ParameterizedCommand) obj;
    } else if (obj instanceof KeyBinding) {
        cmd = ((KeyBinding) obj).getParameterizedCommand();
    }
    boolean done = false;
    Iterator i = bindingElements.iterator();
    // Reselects the command
    while (i.hasNext() && !done) {
        BindingElement be = (BindingElement) i.next();
        obj = be.getModelObject();
        ParameterizedCommand pcmd = null;
        if (obj instanceof ParameterizedCommand) {
            pcmd = (ParameterizedCommand) obj;
        } else if (obj instanceof KeyBinding) {
            pcmd = ((KeyBinding) obj).getParameterizedCommand();
        }
        if (cmd.equals(pcmd)) {
            done = true;
            setSelectedElement(be);
        }
    }
}
Also used : KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) BindingElement(org.eclipse.ui.internal.keys.model.BindingElement) Iterator(java.util.Iterator) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Aggregations

KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)6 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)5 BindingElement (org.eclipse.ui.internal.keys.model.BindingElement)5 Binding (org.eclipse.jface.bindings.Binding)4 Iterator (java.util.Iterator)3 Collection (java.util.Collection)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 TriggerSequence (org.eclipse.jface.bindings.TriggerSequence)1 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)1 ConflictModel (org.eclipse.ui.internal.keys.model.ConflictModel)1 ModelElement (org.eclipse.ui.internal.keys.model.ModelElement)1