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);
}
}
}
Aggregations