Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
staudta is currently offline staudta
Messages: 17
Registered: August 2010
Junior Member
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
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
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
Paul Webster is currently offline Paul Webster
Messages: 6850
Registered: July 2009
Location: Ottawa
Senior Member

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
staudta is currently offline staudta
Messages: 17
Registered: August 2010
Junior Member
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]

Report message to a moderator

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


Current Time: Sat Apr 19 13:14:49 EDT 2014

Powered by FUDForum. Page generated in 0.01785 seconds