Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Select command handler based on where it's triggered from?
Select command handler based on where it's triggered from? [message #337039] Thu, 23 July 2009 00:07 Go to next message
Eric Jain is currently offline Eric JainFriend
Messages: 266
Registered: July 2009
Senior Member
Can I assign a different handler to a command, depending on where it was
triggered from (e.g. from a specific toolbar icon vs from a menu item)?

I know how to override handlers when specific parts are in focus:

<handler class="test.FooHandler" commandId="testCommand">
<activeWhen>
<with variable="activePartId">
<equals value="testView"/>
</with>
</activeWhen>
</handler>

...but this approach has some limitations (for example I'd like to
override the org.eclipse.ui.newWizard command when a specific view is in
focus, but the default handler should be used when the command is
triggered via the top-level menu, even if the view is still active).
Re: Select command handler based on where it's triggered from? [message #452927 is a reply to message #337039] Sat, 01 August 2009 14:33 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The short answer is no. The application state determines which handler is active. A command executed from a key, menu, or toolbar should work correctly based on the application context (not the placement of the command).

The only exception is context menus. When you open a context menu, activeMenu is a collection of string context menuIds. It would be possible to execute a different handler from a context menu. But that's about it.

PW


Previous Topic:Best way to listen to context activation/deactivation
Next Topic:How to Add menu contribution when an specific editor is active - using org.eclipse.ui.menus
Goto Forum:
  


Current Time: Fri Apr 19 20:00:28 GMT 2024

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

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

Back to the top