Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Can I use a command parameter in its handler's enabledWhen?
Can I use a command parameter in its handler's enabledWhen? [message #483539] Tue, 01 September 2009 23:57 Go to next message
Craig Foote is currently offline Craig Foote
Messages: 195
Registered: July 2009
Senior Member
I have a command declared with a parameter and several menu contributions
and a handler extension referencing that command. I'd like to show the
menu contributions based on selection type type and enable them
independently based on a combination of the selection's state and the
parameter value. I have visibleWhen clauses on the menu contributions
checking the selection type. Now I want to determine enablement of the
handler.

Am I correct in thinking the enablement of each menu item is determined
by the (common) handler's enabledWhen clause being checked for each menu
item upon drawing the menu? If so can I use "with selection" to examine
its state and use a "with" or "resolve" to somehow check the parameter
associated with each menu item? I would appreciate any help in how to
test the command parameter each menu item is associated with.

Thanks,
Craig Foote
Re: Can I use a command parameter in its handler's enabledWhen? [message #483732 is a reply to message #483539] Wed, 02 September 2009 18:29 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

in 3.x, a command is a global object and its the one that has the enabled state. Parameters (like the view id on showView) are passed in during an execute call, but are not available otherwise.

Because of the command design and the use of the global application context, a command is enabled or disabled for the entire application. i.e. if you disabled the showView command, all of the menu items under Window>Show View would be disabled.

In 4.0 we're investigating the notion of context sensitive queries (asking isActive, isEnabled, and isVisible from a specific view, for example) but that is such a change that it is not being considered in 3.x.

PW


Re: Can I use a command parameter in its handler's enabledWhen? [message #483780 is a reply to message #483732] Wed, 02 September 2009 22:59 Go to previous message
Craig Foote is currently offline Craig Foote
Messages: 195
Registered: July 2009
Senior Member
Ok Paul, thanks for the reply.

Craig

On Wed, 02 Sep 2009 14:29:49 -0400, Paul Webster wrote:

> in 3.x, a command is a global object and its the one that has the
> enabled state. Parameters (like the view id on showView) are passed in
> during an execute call, but are not available otherwise.
>
> Because of the command design and the use of the global application
> context, a command is enabled or disabled for the entire application.
> i.e. if you disabled the showView command, all of the menu items under
> Window>Show View would be disabled.
>
> In 4.0 we're investigating the notion of context sensitive queries
> (asking isActive, isEnabled, and isVisible from a specific view, for
> example) but that is such a change that it is not being considered in
> 3.x.
>
> PW
Previous Topic:Workbench save and restore dilama
Next Topic:Linking to external resources
Goto Forum:
  


Current Time: Mon Sep 22 16:21:28 GMT 2014

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

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