Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Contributing popup menu item only for selected project nature
Contributing popup menu item only for selected project nature [message #325146] Mon, 11 February 2008 02:49 Go to next message
Eclipse UserFriend
Originally posted by: ptrinchini.quipo.it

I would contribute some commands to the pop-up menu of the project
explorer view; for this purpose I defined the following menu contribution:

<extension
point="org.eclipse.ui.menus">
<menuContribution

locationURI=" popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?aft er=additions ">
<command
commandId="myplugin.command.mycommand"
icon="icons/etool16/mycommand.png"
label="Run mycommand"
mnemonic="M1+P"
tooltip="Do something with this project">
</command>
</menuContribution>
</extension>

this works fine, i.e. the command appears in the popup menu.
However, when I try to add a filter to have the command visible only
when a project with a given nature is selected:

<visibleWhen>
<test property="org.eclipse.core.resources.projectNature"
value="myplugin.natures.mynature">
</test>
</visibleWhen>

the command simply disappears!

This happens also for any other kind of visibleWhen filter; maybe I'm
missing something, but what?

Thanks a lot for your time reading this post

Regards,
Patrizio
Re: Contributing popup menu item only for selected project nature [message #325154 is a reply to message #325146] Mon, 11 February 2008 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Patrizio wrote:
> this works fine, i.e. the command appears in the popup menu.
> However, when I try to add a filter to have the command visible only
> when a project with a given nature is selected:
>
> <visibleWhen>
> <test property="org.eclipse.core.resources.projectNature"
> value="myplugin.natures.mynature">
> </test>
> </visibleWhen>

Try:

<visibleWhen>
<iterate operator="and">
<test property="org.eclipse.core.resources.projectNature"
value="myplugin.natures.mynature">
</test>
</iterate>
</visibleWhen>
[/xml]

Also check out the core expressions link in my sig.

Later,
PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Contributing popup menu item only for selected project nature [message #325346 is a reply to message #325154] Fri, 15 February 2008 01:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ptrinchini.quipo.it

Paul Webster wrote:
> Patrizio wrote:
>> this works fine, i.e. the command appears in the popup menu.
>> However, when I try to add a filter to have the command visible only
>> when a project with a given nature is selected:
>>
>> <visibleWhen>
>> <test property="org.eclipse.core.resources.projectNature"
>> value="myplugin.natures.mynature">
>> </test>
>> </visibleWhen>
>
> Try:
>
> <visibleWhen>
> <iterate operator="and">
> <test property="org.eclipse.core.resources.projectNature"
> value="myplugin.natures.mynature">
> </test>
> </iterate>
> </visibleWhen>
> [/xml]
>
> Also check out the core expressions link in my sig.
>
> Later,
> PW
>
>
Thanks a lot Paul, adding the iterate element solved the problem, Now
I'm able to get my command when a project with the given nature i
selected in the project explorer.
However I get it also when I right click on an empty space in the
project explorer; in this case the selection is empty (null) so the
handler doesn't execute, but it would be nice to hide the command when
the selection is empty.
Is it possible to achieve this with the visibleWhen condition ?

Thanks again for your help

Regards,
Patrizio
Re: Contributing popup menu item only for selected project nature [message #325361 is a reply to message #325346] Fri, 15 February 2008 09:42 Go to previous messageGo to next message
Eclipse UserFriend
It's an attribute on the iterate element, what to return if empty.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Contributing popup menu item only for selected project nature [message #325368 is a reply to message #325361] Fri, 15 February 2008 10:49 Go to previous message
Eclipse UserFriend
Originally posted by: ptrinchini.quipo.it

Paul Webster wrote:
> It's an attribute on the iterate element, what to return if empty.
>
> PW
>
Paoul,

again, many many thanks ! it works perfectly now!!

Regards
Patrizio
Previous Topic:Problem with launching RCP application on eclipse 3.3
Next Topic:actionSet location in toolbar
Goto Forum:
  


Current Time: Sat Aug 02 15:10:17 EDT 2025

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

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

Back to the top