Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Multiple command handler enablement states.
Multiple command handler enablement states. [message #1718418] Wed, 23 December 2015 08:54 Go to next message
Eclipse UserFriend
I have a command which is part of a view's toolbar. This view is a multi-view so there can be more than one instance of the view open in a workbench. I am trying to get it to work so that the button will be enabled or disabled per view depending on some variable within the view instance. EG: One view could have the command enabled while another has it disabled. It seems to me that command handlers have a global enabled state and so whatever state the active view has is what all of the views will have. It seems the only solution is to use actions instead of commands and programmatically enable/disable the action based on the view's state.

I have been searching for a straight forward solution to this and have seen Paul Webster mention that they were aware of this limitation of commands and have been investigation solutions for eclipse 4. Here is one such post: https://www.eclipse.org/forums/index.php?t=msg&th=153298&goto=483186&#msg_483186 .

Is there a solution for this situation using commands and handlers?

Thanks.
Re: Multiple command handler enablement states. [message #1718428 is a reply to message #1718418] Wed, 23 December 2015 10:00 Go to previous message
Eclipse UserFriend
I'm not sure what you mean with the view instance, but IIRC I solved a similar scenario using context variables that are put into the part context. And the @Execute method gets the value injected, typically as a @Named injection. The only thing I'm currently unsure is about triggering the update. The menu and toolbar items are updated on triggering some update event. And I'm not sure if this is automatically triggered on changing the active view or if you need to register a listener that triggers the event on such a change.
Previous Topic:Setting focus to another part programmatically
Next Topic:Same dynamic context menu in different parts
Goto Forum:
  


Current Time: Wed Jul 02 20:20:39 EDT 2025

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

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

Back to the top