How can I add popup menu in Project explorer context menu, only for .java files in project. Trying to make some plugin for some tests but I don't know how to get this menu to appear only for .java type of file. I did it for txt file using org.eclipse.core.resources.IFile.
plugin.xml
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
id="org.plugin.generate_test.contribution1"
objectClass="org.eclipse.core.resources.IResources">
<menu
id="org.plugin.generate_test.menu1"
label="Menu 1"
path="additions">
<separator
name="group1">
</separator>
</menu>
<action
class="org.plugin.generate_test.popup.actions.GenerateTest"
enablesFor="1"
id="org.plugin.generate_test.action1"
label="Action 1"
menubarPath="org.plugin.generate_test.menu1/group1">
</action>
</objectContribution>
</extension>
Edit:
Now I see that org.eclipse.ui.popupMenus was deprecated, so now can someone tell me how can I make this using menu contribution. My code:
</menuContribution>
<menuContribution
allPopups="true"
locationURI="menu:org.eclipse.ui.navigator.ProjectExplorer?after=additions">
<menu
id="org.plugin.generate_test.menus.popupTestMenu2"
label="Generate Test"
mnemonic="P2">
<command
commandId="org.plugin.generate_test.command.generateCommand"
id="org.plugin.generate_test.menus.generateCommand"
mnemonic="PC2"
style="push">
</command>
</menu>
</menuContribution>
</extension>
I need to add this command in right click context menu in Project Explorer/Package Explorer only for .java files.