* @param commandId the command we want to know about
* @return the 'best' key sequence that will activate the given command
*/
public static KeySequence getCommandKeyBinding(String commandId) {
Assert.isNotNull(commandId);
final IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench()
.getAdapter(IBindingService.class);
TriggerSequence keyBinding = bindingSvc.getBestActiveBindingFor(commandId);
if (keyBinding instanceof KeySequence) {
return (KeySequence) keyBinding;
}
List<Tuple<Binding, ParameterizedCommand>> matches = new ArrayList<Tuple<Binding, ParameterizedCommand>>();
//Ok, it may be that the binding we're looking for is not active, so, let's give a spin on all
//the bindings
Binding[] bindings = bindingSvc.getBindings();
for (Binding binding : bindings) {
ParameterizedCommand command = binding.getParameterizedCommand();
if (command != null) {
if (commandId.equals(command.getId())) {
matches.add(new Tuple<Binding, ParameterizedCommand>(binding, command));