Reputation: 391
I want to add popup item for Java projects in my Eclipse plugin. My plugin.xml contains:
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.jdt.core.IJavaProject"
id="com.contribution1">
<action
label="Action"
class="com.actions.NewAction"
enablesFor="1"
id="com.actions.newAction">
</action>
</objectContribution>
However, the menu item is not shown in the popup. If I use IPackageFragment instead, the menu item shows just fine. Please advise.
Upvotes: 2
Views: 794
Reputation: 325
If you want to display your menu in another explorer (for instance in the Resources perspective's Project explorer), you'll have to change your objectContribution definition as follows:
Set the objectclass property to org.eclipse.core.resources.IProject.
Add a visibility element to filter your menu/actions for projects that DO NOT have the Java nature.
I.e:
<objectContribution
adaptable="true"
objectClass="org.eclipse.core.resources.IProject">
...
<visibility>
<objectState
name="projectNature"
value="org.eclipse.jdt.core.javanature">
</objectState>
</visibility>
</objectContribution>
Upvotes: 0
Reputation: 391
Ok, the problem was that a Java project is considered an IJavaProject in the Java perspective only and the Eclipse instance used to test the plugin starts with the Resources perspective. If I switch to the Java perspective everything works as expected.
Upvotes: 1