Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to implement handler for command in main menu and context menu
How to implement handler for command in main menu and context menu [message #830402] Tue, 27 March 2012 15:24 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

I have a command and I would like to contribute it to the main menu and also to my editor's context menu.

The command should be enabled when some selection occurs.

The problem is that the editor part provide selection variable while the context menu provide activeMenuSelection variable.

How should I create the appropriate handler(s?) and its activeWhen and enableWhen for that command?

[Updated on: Tue, 27 March 2012 15:25]

Report message to a moderator

Re: How to implement handler for command in main menu and context menu [message #830940 is a reply to message #830402] Wed, 28 March 2012 08:53 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Or more specifically, how to deal with this situation:

  • There is a command with a default handler.
  • The default handler use the active selection from the active workbench window to work with.
  • You would like to add this command to the main menu when is your editor active.
  • You would like to add this command to your editor's context menu.


Do I need to contribute 2 handlers for this?
The first one with activeWhen and enableWhen with selection variable check and the second one with
activeWhen and enableWhen with activeMenuSelection variable check?

It could works if my editor provide different selection and context menu selection, but what if they are equals?
Which handler will be activated?
Re: Re: How to implement handler for command in main menu and context menu [message #845845 is a reply to message #830940] Sun, 15 April 2012 13:24 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Jan,

no, you use two extensions on org.eclipse.ui.menus and assign the COMMAND to
the context menu and the toolbar of the editor.

(btw, the toolbar of the editor will be shown in the main toolbar area).

You do not need to specify any activation expression on the handler because
there is only one handler for the command right?

Best regards,

Wim

> Or more specifically, how to deal with this situation:
>
> There is a command with a default handler.
> The default handler use the active selection from the active workbench
window to work with.
> You would like to add this command to the main menu when is your editor
active.
> You would like to add this command to your editor's context menu.
>
>
> Do I need to contribute 2 handlers for this?
> The first one with activeWhen and enableWhen with selection variable check
and the second one with
> activeWhen and enableWhen with activeMenuSelection variable check?
>
> It could works if my editor provide different selection and context menu
selection, but what if they are equals?
> Which handler will be activated?
Previous Topic:Error from Eclipse Product based on Features
Next Topic:Register to be system mail handler?
Goto Forum:
  


Current Time: Tue Apr 16 09:17:41 GMT 2024

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

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

Back to the top