use of org.eclipse.jface.bindings.Trigger in project egit by eclipse.
the class UIUtils method getKeystrokeOfBestActiveBindingFor.
/**
* Look up best active binding's keystroke for the given command
*
* @param commandId
* The identifier of the command for which the best active
* binding's keystroke should be retrieved; must not be null.
* @return {@code KeyStroke} for the best active binding for the specified
* commandId or {@code null} if no binding is defined or if the
* binding service returns a {@code TriggerSequence} containing more
* than one {@code Trigger}.
*/
@Nullable
public static KeyStroke getKeystrokeOfBestActiveBindingFor(String commandId) {
IBindingService bindingService = AdapterUtils.adapt(PlatformUI.getWorkbench(), IBindingService.class);
if (bindingService == null) {
return null;
}
TriggerSequence ts = bindingService.getBestActiveBindingFor(commandId);
if (ts == null)
return null;
Trigger[] triggers = ts.getTriggers();
if (triggers.length == 1 && triggers[0] instanceof KeyStroke)
return (KeyStroke) triggers[0];
else
return null;
}
Aggregations