Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Multiple command handler enablement states.
Multiple command handler enablement states. [message #1718418] Wed, 23 December 2015 13:54 Go to next message
Michael Hayes is currently offline Michael HayesFriend
Messages: 1
Registered: December 2015
Junior Member
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 15:00 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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: Fri Apr 26 22:53:26 GMT 2024

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

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

Back to the top