Skip to main content



      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] Wed, 22 July 2009 20:07 Go to next message
Eclipse UserFriend
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 10:33 Go to previous message
Eclipse UserFriend
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: Thu May 01 12:35:06 EDT 2025

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

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

Back to the top