|
|
|
|
|
Re: How to remove/replace the default key binding scheme [message #333133 is a reply to message #333098] |
Wed, 26 November 2008 18:11 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
kent gibson![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=kentgibson%40yahoo.com) Messages: 114 Registered: July 2009 |
Senior Member |
|
|
Ok, I have a solution at least for my needs.
The solution below will filter all commands that are not in the category
mycategory, you can define the criteria as you need.
To test do Ctrl+Shift+L you should see only the commands you have not
filtered.
######################
IBindingService bindingService = (IBindingService) PlatformUI
getWorkbench().getAdapter(IBindingService.class);
BindingManager localChangeManager = new BindingManager(
new ContextManager(), new CommandManager());
try {
localChangeManager
.setActiveScheme(bindingService.getActiveScheme());
} catch (final NotDefinedException e) {
throw new Error(
"Error"); //$NON-NLS-1$
}
localChangeManager.setLocale(bindingService.getLocale());
localChangeManager.setPlatform(bindingService.getPlatform()) ;
localChangeManager.setBindings(bindingService.getBindings()) ;
Binding[] bindings = bindingService.getBindings();
for (Binding binding : bindings) {
if (binding.getTriggerSequence().format().equals("Ctrl+Shift+L ")) {
continue;
}
KeyBinding keyBinding = (KeyBinding) binding;
String contextId = binding.getContextId();
String schemeId = binding.getSchemeId();
KeySequence triggerSequence = keyBinding.getKeySequence();
ParameterizedCommand parameterizedCommand = binding
.getParameterizedCommand();
if (parameterizedCommand == null) {
continue;
}
Command command = parameterizedCommand.getCommand();
if (command == null) {
continue;
}
try {
if (!binding
getParameterizedCommand()
getCommand()
getCategory()
getId()
equals(
"mycategory")) {
KeyBinding deleteBinding = new KeyBinding(triggerSequence,
null, schemeId, contextId, null, null, null,
Binding.USER);
localChangeManager.addBinding(deleteBinding);
}
} catch (NotDefinedException e) {
e.printStackTrace();
}
}
try {
bindingService.savePreferences(
localChangeManager.getActiveScheme(), localChangeManager
.getBindings());
} catch (IOException e) {
e.printStackTrace();
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04308 seconds