Community
Participate
Working Groups
Build Identifier: I'm attempting to define new commands, hook up bindings for them and add expressions for enablement that are dynamic - all programmatically. When I attempt to add the bindings, that part is failing. It looks up application.getCommands() and doesn't find the programmatically defined command in BindingService.createMKeyBinding, line 679. It looks like the programmatcially defined commands got to a different set than the Here's the basic code I'm running to set this up. (Am I doing things wrong?) // Define our commandElement model as an Eclipse command String commandId = "com.example.command." + commandElement.getDisplayName(); Command c = cs.getCommand(commandId); if (!c.isDefined()) { c.define(commandElement.getDisplayName(), commandElement.getDisplayName(), cat); Expression expression = new Expression() { @Override public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { IWorkbenchPart workbenchPart = (IWorkbenchPart) context.getVariable(ISources.ACTIVE_PART_NAME); if (workbenchPart instanceof IEditorPart) { // do more checking return EvaluationResult.TRUE; } return EvaluationResult.FALSE; } }; } KeySequence[] keySequences = commandElement.getKeySequences(); if (!ArrayUtil.isEmpty(keySequences)) { if (bindingService instanceof BindingService) { final BindingService theBindingService = (BindingService) bindingService; // Add to the set for (KeySequence keySequence : keySequences) { KeyBinding binding = new KeyBinding(keySequence, new ParameterizedCommand(c, null), "org.eclipse.ui.defaultAcceleratorConfiguration", "myContext", null, null, null, Binding.USER); theBindingService.addBinding(binding); } } } Reproducible: Always
*** This bug has been marked as a duplicate of bug 407749 ***