Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Commands - checkEnabled=true strange behaviour
Commands - checkEnabled=true strange behaviour [message #331889] Fri, 26 September 2008 16:11 Go to next message
Damien is currently offline DamienFriend
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);
Re: Commands - checkEnabled=true strange behaviour [message #332005 is a reply to message #331889] Wed, 01 October 2008 13:34 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You don't call menuMgr.setRemoveAllWhenShown(true) ... you can use that
as a work-around, but this seems to be a bug to me.

Please open a bug at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI

Include your description, and if you can capture your example in a test
plugin (start by using the sample view template, and then add/modify it)
and attach it that would help us track this down.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Commands - checkEnabled=true strange behaviour [message #332080 is a reply to message #332005] Thu, 02 October 2008 08:58 Go to previous message
Damien is currently offline DamienFriend
Messages: 3
Registered: July 2009
Junior Member
Thanks for the response.

I've oppened a bug (id=249445) with a sample plugin attached.

As you mentionned, if I call menuMgr.setRemoveAllWhenShown(true)... then
the command is visible on every click. But that's true only in the sample
plugin.

In my real RCP app, if I call menuMgr.setRemoveAllWhenShown(true), then
the command is never visible. In next days, I will try to make a plugin
that reproduce this behavior and attach it to the opened bug.

Damien
Previous Topic:JDBC connection issue with Socks proxy defined in the "Network Connections" Preferences
Next Topic:Toolbar buttons with Eclipse Look
Goto Forum:
  


Current Time: Sat Dec 21 16:49:28 GMT 2024

Powered by FUDForum. Page generated in 0.03310 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top