| Summary: | org.eclipse.core.commands.Command ICommandListener listener does not work | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Mekk Elek <mchallss> | ||||
| Component: | UI | Assignee: | Platform-UI-Inbox <Platform-UI-Inbox> | ||||
| Status: | CLOSED INVALID | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | mchallss | ||||
| Version: | 4.1 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 198611 [details]
Eclipse project to reproduce the fault
Sorry. I think the help page mislead me be it: Method detail of org.eclipse.core.commands.Command: "addCommandListener public final void addCommandListener(ICommandListener commandListener) Adds a listener to this command that will be notified when this command's state changes." Where state is obviously NOT the attached state, but the internal state of the Command object. Hence the bug is not a bug at all, but user error :>, so I'm closing it. |
Build Identifier: 20110218-0911 I have a command and a RegistryToggleState state atteched to it. I subscribe for command state changes from code using: public final void addCommandListener(final ICommandListener commandListener); When a state change occurs in the State object, I get no notification at all. When I track down with debugger why, I can see that the event ends up in org.eclipse.ui.internal.handlers.HandlerProxy's method: public void handleStateChange(State state, Object oldValue); But this method, even though the "handler" variable is my command listener, will not call my function, because it is implementing the ICommandListener interface and not IStateListener, which this method expects: if (handler instanceof IStateListener) { ((IStateListener) handler).handleStateChange(state, oldValue); } Note that ICommandListener and IStateListener are unrelated interfaces. I would expect that if I call addCommandListener(), I should get back notifications, no matter what. I have attached a snapshot of my complete eclipse project, which should be enough to check the fault. Reproducible: Always Steps to Reproduce: 1. Open the attched eclipse project. 2. When you start the project, you will see a file system view with some buttons on the toolbar. Press the "Show directories on top" button (it has this text as a tooltip). 3. Now the fsview.views.FSView :: public void commandChanged(CommandEvent commandEvent) should be fired, but this does not happen. 4. You can put a breakpoint to fsview.handlers.ToggleCommandHandler :: public Object execute(ExecutionEvent event) method and take step by step and you will reach org.eclipse.ui.internal.handlers.HandlerProxy.