adding and removing popup menu items for java file
I wanted to add one item in the popup when I right click all java file which is in the package explorer. I gave the object class as org.eclipse.core.resources.IFile and nameFilter is *.java. But it开发者_如何学Go does not work for me.But If I give some other extensions as namefilter like *.abc, then it works for me. How do I add popupmenu items into java files?Wont eclipse support the popumenu item for adding into java files? And also I need to remove some of the existing popumenu items for the java files.How can I do that?
Please help me in this.
Thanks Bhanu
Use commands, not actions. The code below should work.
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command
commandId="my id"
label="my command label"
style="push">
<visibleWhen>
<with variable="activeMenuSelection">
<iterate
ifEmpty="false">
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java" />
</adapt>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
However, if you must contribute an action, here's how to do it.
As for removing items from a menu, this question has been posted and answered several times on SO already, for example here.
精彩评论