Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 07: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 13:15 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 06: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 14:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 15: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: Fri Apr 26 03:06: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