Contributing popup menu item only for selected project nature [message #325146] |
Mon, 11 February 2008 07:49 |
Eclipse User |
|
|
|
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 #325346 is a reply to message #325154] |
Fri, 15 February 2008 06:45 |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02744 seconds