Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 157159

Summary: [KeyBindings] Once a shortcut for an ActionDelegate is disabled, it never works again
Product: [Eclipse Project] Platform Reporter: Gerhard Schaber <gerhard.schaber>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Gerhard Schaber CLA 2006-09-13 08:27:35 EDT
When a disabled ActionDelegate is executed by using the corresponding shortcut, the shortcut does not work any more, even when the ActionDelegate is enabled sometime.

The following method is 
public class MyActionDelegate implements IWorkbenchWindowActionDelegate {
  public void selectionChanged(IAction action, ISelection selection) {
     boolean currentState = false;
     ...
     action.setEnabled(currentState);
  }
  ...
}

action is an instance of CommandLegacyActionWrapper (created by ActionDelegateHandlerProxy), if the command is executed by using a shortcut.

If currentState is false sometime when invoking the command, then the CommandLegacyActionWrapper is set disabled and for subsequent uses of the shortcut, Eclipse stops processing the command in Command.executeWithChecks in line 453 (Eclipse 3.2 final):

// Perform the execution, if there is a handler.
if ((handler != null) && (handler.isHandled())) {
  if (!isEnabled()) {
    final NotEnabledException exception = new NotEnabledException(

The state is never updated, no selectionChanged is called subsequently for the MyActionDelegate instance.

The behavior can be reproduced with CDT.
- Assign shortcut Alt-Shift-Z to Refactor/Undo
- Press Alt-Shift-Z if command is disabled
- Rename a piece of code using Refactor/Rename...
- Press Alt-Shift-Z again.

Although Refactor/Rename... is enabled, it will not be executed. If you never press the shortcut when the command is disabled, the shortcuts works fine, ever.
Comment 1 Gerhard Schaber CLA 2006-09-13 08:29:00 EDT
*** Bug 157156 has been marked as a duplicate of this bug. ***
Comment 2 Paul Webster CLA 2006-09-13 11:46:09 EDT
This is another symptom of bug 151612, where the command legacy wrapper is not hooked up correctly.

PW


*** This bug has been marked as a duplicate of 151612 ***