Commands - checkEnabled=true strange behaviour [message #331889] |
Fri, 26 September 2008 16:11 |
Damien Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hello all,
First, sorry for my English.
I have a problem using the "checkEnabled=true" attribute on a command.
Here is my conf :
- Eclipse 3.4.1
- 1 command (extension of org.eclipse.ui.commands) with only its id and
name defined
- 1 handler pointing to this commandId and to a custom implementation with
an <activeWhen> definition.
- 1 popup definition (for a context menu) featuring the command, with
"checkEnabled=true" attribute set.
When I launch my app and then right click on the view to open my popup
menu, the command is visible as expected only the first time, every
subsequents right clicks have no effect and don't show the command.
Could someone explain me what is happening ?
In my real app, I have some commands with multiple handlers and when there
is no active handler for a command I don't want that the command is
visible (even grayed) in the popup menu.
I've readed in bug 177740 that this is implemented.
Thanks in advance for any help.
Damien
Here is the plugin.xml (interesting part):
<extension
point="org.eclipse.ui.commands">
<command
id="test"
name="test">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="testplugin.NOPHandler"
commandId="test">
<activeWhen> <!-- also tried with enabledWhen, no effect -->
<with
variable="activeMenuSelection">
<count
value="+">
</count>
</with>
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:test?after=additions">
<command
commandId="test"
icon="icons/alt_window_16.gif"
id="test"
style="push">
<visibleWhen
checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
</extension>
Here is the way I register the menu:
final MenuManager menuMgr = new MenuManager(null, "test");
menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
final Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
this.getSite().registerContextMenu("test", menuMgr, viewer);
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03712 seconds