Community
Participate
Working Groups
Hi, i have problem with enablement of toolbar icons. I created menu and toolbar with one command behind and one handler. Menu and command have defined visibleWhen condition. It looks like following: <menuContribution locationURI="toolbar:biz.wss.rcp.fxmanager.toolbar"> <command commandId="biz.wss.rcp.fxmanager.apply" disabledIcon="icons/sample.gif" icon="icons/apply.gif" id="biz.wss.rcp.fxmanager.menu.apply" style="push"> <visibleWhen> <with variable="activeContexts"> <iterate operator="or"> <equals value="biz.wss.rcp.fxmanager.FXDealEntryEditor"/> </iterate> </with> </visibleWhen> </command> </menuContribution> <menuContribution locationURI="menu:biz.wss.rcp.fxmanager.menu.command"> <command commandId="biz.wss.rcp.fxmanager.apply" id="biz.wss.rcp.fxmanager.menu.apply" label="Apply"> <visibleWhen> <with variable="activeContexts"> <iterate operator="or"> <equals value="biz.wss.rcp.fxmanager.FXDealEntryEditor"/> </iterate> </with> </visibleWhen> </command> </menuContribution> <handler commandId="biz.wss.rcp.fxmanager.apply" class="biz.wss.rcp.rcpmanager.core.handler.GenericHandler"> </handler> <command id="biz.wss.rcp.fxmanager.apply" name="Apply"> </command> Enablement logic is implemented in biz.wss.rcp.rcpmanager.core.handler.GenericHandler::isEnabled(). I have some controls in editor and when i move from one to other i am trying to push Ecplise update enablement state of menus/toolbars. I created listener and when i move to other control inside editor. My first idea was this listener will change selection (ISelection) on active part, but it didnt work. Selection provider was properly set and 4 listeners from platform was registered. But state of widgets remained same. I did another attempt and listener tried to set/unset some fake context. Then menu enablement started to work but toolbars remained untouched. All widgets are properly enabled only when you open another editor, switch to it and back... Thanks in advance Tomas Krecmer
*** Bug 180206 has been marked as a duplicate of this bug. ***
What version of eclipse are you running? Also, if your handler uses programmatic enablement your icons should be enabled until some user action causes them to load. PW
I am using 3.3M6. I expect if menu with same command behind is enabled properly then toolbar icon should be enabled as well. When i click to toolbar icon i get org.eclipse.core.commands.NotEnabledException. Tomas
(In reply to comment #3) > I am using 3.3M6. I expect if menu with same command behind is enabled properly > then toolbar icon should be enabled as well. When i click to toolbar icon i get > org.eclipse.core.commands.NotEnabledException. If you click on the toolbar button and then the menu item, the menu item works? What if you click on the menu item first? PW
Is you generic handler firing HandlerEvents? PW
"If you click on the toolbar button and then the menu item, the menu item works? What if you click on the menu item first? PW" I am not able to click to menu item as it is properly disabled. "Is you generic handler firing HandlerEvents?" No, i do not fire any events from my handler. It is inherited from AbstractHandler. It implements isEnabled() method. When i switch to other editor and back it is enabled properly. Seems like some notification to toolbars is missing.
(In reply to comment #6) > "Is you generic handler firing HandlerEvents?" > > No, i do not fire any events from my handler. It is inherited from > AbstractHandler. It implements isEnabled() method. > If you override isEnabled() you must fire a handler event. See the class doc for AbstractHandler and the javadoc for HandlerEvent. PW
I tried to fire HandlerEvent when status of my application changed and it started to work. Anyway i am not sure how to fire HandlerEvent properly. I can make in my implementation of handler fireHandlerChanged() public, but i am not able to get list of all registered handlers. I am able to get list of Commands and its handlers via CommandService, but i get HandlerProxy instead of my implementation.
I see another problem. Handlers created via plugin.xml are singletons through whole workbench. If you have more workbench windows opened with the same editor and you want to change enablement you will fire HandlerEvent on your handler. It will properly change enablement in active editor but also in other inactive...
(In reply to comment #8) > I tried to fire HandlerEvent when status of my application changed and it > started to work. Anyway i am not sure how to fire HandlerEvent properly. I can > make in my implementation of handler fireHandlerChanged() public, but i am not > able to get list of all registered handlers. Your handler should be listening to events from your model, and update its enablement state as appropriate (and then fire the HandlerEvent). Before it is instantiated, you can use the enabledWhen clause to build an declarative enablement condition that will be managed for you. We use org.eclipse.ui.internal.AbstractEnabledHandler and when our listeners detect a change we care about, we just call setEnabled(*) PW
If your handler enablement state depends on the active editor you should keep track of it. At least for now it will show the odd state in the inactive window (we're working on that under another bug). But it can't effect anything. PW
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.