Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Showing actions in PopupMenu only in special cases
Showing actions in PopupMenu only in special cases [message #631491] Thu, 07 October 2010 13:07 Go to next message
Eclipse UserFriend
Hi,

I want to add some entries to the context menu on the IResources that are shown in the Package Explorer.

Therefore I used the extension point "org.eclipse.ui.popupMenus". The first subelement is of the type objectContribution.
The difficult part is now that some entries should be shown only in special cases. Therefor I need to check the state the selected file and with checking the state I mean, that I need to read out a configuration file and to determine if the IResources was enabled for that Action.

How can I reach this goal?
Thank you.
Re: Showing actions in PopupMenu only in special cases [message #631597 is a reply to message #631491] Fri, 08 October 2010 02:50 Go to previous messageGo to next message
Eclipse UserFriend
On 07.10.2010 19:07, Adrian wrote:
> Hi,
>
> I want to add some entries to the context menu on the IResources that
> are shown in the Package Explorer.
> Therefore I used the extension point "org.eclipse.ui.popupMenus". The
> first subelement is of the type objectContribution.
> The difficult part is now that some entries should be shown only in
> special cases. Therefor I need to check the state the selected file and
> with checking the state I mean, that I need to read out a configuration
> file and to determine if the IResources was enabled for that Action.
>
> How can I reach this goal?

You can implement an IActionFilter for your specific IResources and
use the filter attribute in your objectContribution. To make this work,
you will probably need to make these resources adaptable to the specific
filter, e.g. via an IAdapterFactory using the
org.eclipse.core.runtime.adapters extension point.

HTH & Greetings from Bremen,

Daniel Krügler
Re: Showing actions in PopupMenu only in special cases [message #631657 is a reply to message #631491] Fri, 08 October 2010 07:43 Go to previous messageGo to next message
Eclipse UserFriend
You can also use org.eclipse.ui.menus/menuContributions and
commands/handlers. The visibleWhen for a command element is much more
flexible than what comes with objectContributions.

See my .sig

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Showing actions in PopupMenu only in special cases [message #631680 is a reply to message #631657] Fri, 08 October 2010 09:01 Go to previous message
Eclipse UserFriend
Thank you Daniel Krügler and Paul Webster.
I used now a menuContributor and "org.eclipse.core.expressions.propertyTesters". That was the best solution for my need.

Your hints brought me directly to a good solution.
Cheers Adrian and greetings from Stuttgart.

[Updated on: Fri, 08 October 2010 09:03] by Moderator

Previous Topic:How to get the item shown by the property view
Next Topic:Open View via Context Menu
Goto Forum:
  


Current Time: Tue Jul 08 14:03:53 EDT 2025

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

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

Back to the top