What are the possible reasons for a Filter in the common navigator not to work? - eclipse-plugin

I did everything like #prashanth said in Filtering contents in Eclipse Common Navigator Framework view but my filter doesn't seem to hide anything, I can see all files.
I also tried to follow everystep of this tutorial, and read the doc : https://help.eclipse.org/photon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fcnf.htm
I went to the filter menu and made sure the other filter were working and mine was activated. I tried to refresh the tree..
I have absolutely no clue where to look. Do you have an idea that I can explore ? or could you have a look at my code and tell me if you see something wrong ?
my plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?><plugin>
<extension
point="org.eclipse.ui.commands">
<category
description="A plugin for managing the configuration files of the Software Product Line framework"
id="SPL.commands.category"
name="SPL - Software Product Line">
</category>
<command
categoryId="SPL.commands.category"
defaultHandler="spl.handlers.ListConfigHandler"
id="SPL.commandListConfig"
name="lister les configurations">
</command>
<command
categoryId="SPL.commands.category"
id="SPL.commandCreateConfig"
name="Créer une configuration">
</command>
<command
id="SPL.JavaFileCommand"
name="Java File Command">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="spl.handlers.JavaFileHandler"
commandId="SPL.JavaFileHandler">
</handler>
<handler
class="spl.handlers.ListConfigHandler"
commandId="SPL.ListConfigHandler">
</handler>
<handler
class="spl.handlers.CreateConfigHandler"
commandId="SPL.commandCreateConfig">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="SPL.commands.splCommand"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=help">
<menu
id="SPL.menus.sampleMenu"
label="SPL Menu"
mnemonic="L">
<menu
label="insérer #Variability">
<command
commandId="SPL.commandListConfig"
label="lister les configurations"
style="push">
</command>
<command
commandId="SPL.commandCreateConfig"
label="Créer une configuration"
style="push">
</command>
</menu>
<menu
label="insérer #Bridge"
mnemonic="b">
</menu>
</menu>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any">
<menu
id="SPL.menus.sampleMenu"
label="SPL Menu"
mnemonic="L">
<menu
label="insérer #Variability">
<command
commandId="SPL.commandListConfig"
label="lister les configurations"
style="push">
</command>
<command
commandId="SPL.commandCreateConfig"
label="Créer une configuration"
style="push">
</command>
</menu>
<menu
label="insérer #Bridge"
mnemonic="b">
</menu>
</menu>
</menuContribution>
</extension>
<extension
id="SPLPerspective"
name="SPL Perspective"
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="SPL.perspective4">
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.views">
<category
id="SPL"
name="SPL">
</category>
<view
category="SPL"
class="spl.views.VariabilityExplorer"
id="SPL.VariabilityExplorer"
name="Point of Variability Explorer"
restorable="true">
</view>
<view
category="SPL"
class="spl.views.configurationFileExplorer"
id="spl-development-plugins.configurationFileExplorer"
name="Configuration File Explorer"
restorable="true">
</view>
<view
category="SPL"
class="org.eclipse.ui.navigator.CommonNavigator"
id="spl-development-plugins.VariabilityNavigator"
name="VariabilityNavigator"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.help.contexts">
<contexts
file="contexts.xml">
</contexts>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
class="spl.perspectives.PerspectiveFactory4"
id="SPL.perspective4"
name="SPL">
</perspective>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="spl.editors.PropertiesEditor"
default="true"
extensions=".properties"
id="spl-development-plugins.splEditorProperties"
name="SPL Properties Editor">
</editor>
</extension>
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
viewerId="spl-development-plugins.VariabilityNavigator">
<includes>
<contentExtension
pattern="org.eclipse.ui.navigator.resourceContent">
</contentExtension>
<contentExtension
pattern="org.eclipse.ui.navigator.resources.*">
</contentExtension>
<contentExtension
pattern="org.eclipse.ui.navigator.resources.filters.*">
</contentExtension>
<contentExtension
pattern="spl-development-plugins.VariabilityContent">
</contentExtension>
</includes>
</viewerContentBinding>
<viewerActionBinding
viewerId="spl-development-plugins.VariabilityNavigator">
<includes>
<actionExtension
pattern="org.eclipse.ui.navigator.resources.*">
</actionExtension>
</includes>
</viewerActionBinding>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
id="spl-development-plugins.VariabilityContent"
name="Variability File Contents"
contentProvider="VariabilityContentProvider"
labelProvider="VariabilityLabelProvider"
activeByDefault="true"
icon="icons/sample.png"
priority="normal">
<triggerPoints>
<or>
<and>
<instanceof
value="org.eclipse.core.resources.IResource">
</instanceof>
<test
forcePluginActivation="true"
property="org.eclipse.core.resources.extension"
value="java">
</test>
</and>
<instanceof
value="spl.navigator.VariabilitiesTreeData">
</instanceof>
</or>
</triggerPoints>
<possibleChildren>
<or>
<instanceof
value="spl.navigator.VariabilitiesTreeData">
</instanceof>
</or>
</possibleChildren>
</navigatorContent>
<commonFilter
activeByDefault="true"
class="spl.filter.VariabilityFilter"
description="hide all files that are not java and whom doesn&apos;t includes #Variability"
id="spl-development-plugins.commonFilterVariability"
name="Variability files">
</commonFilter>
</extension>
My filter : I know the code doesn't match with the class name, it is for testing purposes only. I got the code from here https://github.com/maxeler/eclipse/blob/master/eclipse.jdt.ui/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/JavaFileFilter.java which BTW offer other filters whom I tried with the same result :
public class VariabilityFilter extends ViewerFilter {
public VariabilityFilter() {
}
/*
* Filters out all compilation units and class files elements.
*/
#Override
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof ITypeRoot)
return false;
if (element instanceof IPackageFragment)
try {
return ((IPackageFragment)element).getNonJavaResources().length > 0;
} catch (JavaModelException ex) {
return true;
}
return true;
}
}
Note: VariabilityNavigator is an empty class extending CommonNavigator and VariabilitiesTreeData is an empty class.

Related

Unable to create class CompatibilityView

i'am new in Eclipse RCP. I try to build an RCP project on base of E4 with the default project explorer. I found this two tutorials: dirksmetric.wordpress.com/2012/08/01/tutorial-eclipse-rcp-e4-with-3-x-views-like-project-explorer-properties-etc/ vogella.com/tutorials/Eclipse4MigrationGuide/article.html
After all i have an window with parts but the project explorer is not loaded. This is the stackstrace from log.
!ENTRY org.eclipse.e4.ui.workbench 4 0 2017-07-14 12:11:32.706
!MESSAGE Unable to create class 'org.eclipse.ui.internal.e4.compatibility.CompatibilityView' from bundle '86'
!STACK 0
org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in org.eclipse.ui.internal.e4.compatibility.CompatibilityView
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:408)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:105)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:74)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:56)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:666)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$1.run(PartRenderingEngine.java:551)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:535)
at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:70)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:666)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:772)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$0(PartRenderingEngine.java:743)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:737)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:721)
at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1289)
at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.lambda$0(LazyStackRenderer.java:68)
at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:5439)
this ist my plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="product_spside"
point="org.eclipse.core.runtime.products"> <!-- org.eclipse.core.runtime.applications -->
<product application="org.eclipse.e4.ui.workbench.swt.E4Application" name="SPS IDE">
<!-- org.eclipse.e4.ui.workbench.swt.E4Application -->
<property name="appName" value="SPS IDE"> </property>
<property name="applicationXMI" value="spside.rcp/Application.e4xmi"> </property>
</product>
<!-- <application>
<run
class="spside.rcp.Application">
</run>
</application>-->
</extension>
<!-- <extension point="org.eclipse.ui.perspectives">
<perspective
name="RCP Perspective"
class="spside.rcp.Perspective"
id="spside.rcp.perspective">
</perspective>
</extension>-->
</plugin>
I try all tipps from google but i have no idea what to do.
thanks for help!
I made a new RCP project from scratch like in this tutorial and it worked. After this, I realized that my pom.xml of the original project looks different to the new one.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="spside.rcp.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="Perspective"
class="spside.rcp.Perspective"
id="spside.rcp.perspective">
</perspective>
</extension>
<extension
point="org.eclipse.ui.views">
<view
name="View"
inject="true"
class="spside.rcp.View"
id="spside.rcp.view">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="*">
<view
standalone="true"
minimized="false"
relative="org.eclipse.ui.editorss"
relationship="left"
id="spside.rcp.view">
</view>
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
label="File">
<command
commandId="org.eclipse.ui.file.exit"
label="Exit">
</command>
</menu>
</menuContribution>
</extension>
<extension id="product_test" point="org.eclipse.core.runtime.products">
<product application="spside.rcp.application" name="My Product">
<property name="appName" value="SPS IDE"> </property>
<property name="applicationXMI" value="spside.rcp/Application.e4xmi"> </property>
</product>
</extension>
</plugin>
I think the main problem was that I didn't initialize the 3.x Components in the first extension. The next problem was that the second extension point must target to the same id: id="spside.rcp.perspective" as in the Application.e4xmi.

Extending eclipse plugin : How to enable and disable menu?

I want enable my 2nd and 7th menu if the process for first menu is complete. I want to enable my 3rd and 7th menu if process for 2nd menu is complete and so on. I have seven menu. At very first only first menu should be active and remaining should be disable and at second time if 1st process is complete then only 1st menu, 2nd menu and 7th menu should be enabled.
I am not getting how should I make changes in my plugin.xml in order to work as I am expecting. Here is my plugin.xml code. Please help me and thank you in advance.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu id = "documentation.handlers.Documentation"
label = "Documentation">
<command id="documentation.handlers.SampleHandler"
commandId="documentation.handlers.SampleHandler">
</command>
<command id="documentation.handlers.SampleHandler1"
commandId="documentation.handlers.SampleHandler1">
</command>
<command id="documentation.handlers.SampleHandler2"
commandId="documentation.handlers.SampleHandler2">
</command>
<command id="documentation.handlers.SampleHandler3"
commandId="documentation.handlers.SampleHandler3">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler4">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler5">
</command>
<command id="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler6">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="documentation.handlers.sampleToolbar">
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler1">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler2">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler3">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler4">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler5">
</command>
<command id="documentation.handlers.sampleCommand"
commandId="documentation.handlers.SampleHandler6">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler"
name="Project Descritpion">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler"
commandId="documentation.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler1"
name="Fact Finding Techniques">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler1"
commandId="documentation.handlers.SampleHandler1">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler2"
name="Feasibility Study">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler2"
commandId="documentation.handlers.SampleHandler2">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler3"
name="Technical Requirement">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler3"
commandId="documentation.handlers.SampleHandler3">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler4"
name="Open Documentation">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler4"
commandId="documentation.handlers.SampleHandler4">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler5"
name="UML Diagrams">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler5"
commandId="documentation.handlers.SampleHandler5">
</handler>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="documentation.handlers.SampleHandler6"
name="Database Development">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers"
id = "documentation.handlers">
<handler
class="documentation.handlers.SampleHandler6"
commandId="documentation.handlers.SampleHandler6">
</handler>
</extension>
</plugin>
You would do this with an enabledWhen expression on the handler for each command. It sounds like you will probably have to use a property tester to define a custom test for the enabled when expression.
Use the org.eclipse.core.expressions.propertyTesters to define a property tester, something like:
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="documentation.propertytester"
type="java.lang.Object"
namespace="documentation"
properties="handler1enabled,handler2enabled,handler3enabled.. and so on ..."
class="documentation.PropertyTester">
</propertyTester>
</extension>
You then code a documention.PropertyTester class to do the property tests.
You can then use it in your enabled when expression like this:
<handler
class="documentation.handlers.SampleHandler5"
commandId="documentation.handlers.SampleHandler5">
<enabledWhen>
<test
property="namespace.handler5enabled">
</test>
</enabledWhen>
</handler>

Contribute a menu item to the "Configure" menu item/group in Project Explorer

I'm trying to contribute a menu item to the Configure menu item/group in Project Explorer.
The following snippet adds my menu item to the same level. Adding <menu label="Configure" /> between <menuContribution ...> and <command ...> creates a duplicate Configure menu item.
What am I doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="com.example.convert" label="Convert to XXX Project..." />
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command id="com.example.convert" defaultHandler="com.example.ConvertAction" name="Convert to XXX Project" />
</extension>
</plugin>
Using org.eclipse.ui.menus is the more future-safe way so I prefer that whenever I have a choice.
Set the locationURI to popup:org.eclipse.ui.projectConfigure
If you need to find the locationURI of any menu press Alt+Shift+F2, then open the menu as usual and click where you want to insert.
You should be using org.eclipse.ui.popupMenus extension point and adding an objectContribution.
Here's a simplified snippet in the plugin.xml that we are using inside of AJDT to contribute to the configure menu. You should be able to use something like this for your project.
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"
id="iprojectcontributions">
<menu
label="%org.eclipse.ajdt.ui.tools"
id="org.eclipse.ajdt.ui.project.tools">
<separator
name="group0">
</separator>
</menu>
<visibility>
<and>
<objectState name="nature" value="org.eclipse.jdt.core.javanature"/>
<not>
<objectState name="nature" value="org.eclipse.ajdt.ui.ajnature"/>
</not>
<objectState name="open" value="true"/>
</and>
</visibility>
<action
label="%convertToAJP"
class="org.eclipse.ajdt.internal.ui.actions.AddAJNatureAction"
menubarPath="org.eclipse.ui.projectConfigure/additions"
id="addajnatureaction">
</action>
</objectContribution>
</extension>

popup menu in eclipse plugin development

I want to create plugin in which if user right click on any folder or file, the popup menu will open and there is option to read file.
As I am new to plugin development have done some code. My plugin.xml is following
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="com_.samsung.plugin.second.commands.category">
</category>
<command
name="Sample Command"
categoryId="com_.samsung.plugin.second.commands.category"
id="com_.samsung.plugin.second.commands.sampleCommand">
</command>
<command
defaultHandler="com .samsung.plugin.second.SampleHandler"
id="com .samsung.plugin.second.Sample"
name="name">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com_.samsung.plugin.second.commands.sampleCommand"
class="com_.samsung.plugin.second.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com_.samsung.plugin.second.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="com_.samsung.plugin.second"
label="Read File" style="push">
</command>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command defaultHandler="com_.samsung.plugin.second.handler.SampleHandler"
id="com_.samsung.plugin.second" name="Convert">
</command>
</extension>
</plugin>
and i have a SampleHandler class in com_.samsung.plugin.second.handlers;
but in popup Readfile option is not visible.
please suggest me whats wrong with this.
any help will be appriciated.
Thanks

eclipse-plugins in java perspective

I have developed a plugin in eclipse that adds an option when user right clicks on a file. But it shows up only in java perspective and not any in other. Can anyone please tell me the reason?
Here is my plugin.xml:
<?xml version="1.0"?>
<plugin>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="plugin.showDifferences" label="Show Differences" style="push">
<activeWhen>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java"/>
</adapt>
</iterate>
</activeWhen>
</command>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command defaultHandler="plugin_demo.Differences" id="plugin.showDifferences" name="Differences" />
</extension>
</plugin>
This is because the Java perspective's Package Explorer view is a different beast than the Project Explorer view that appears in the other perspectives. If you want your right-click option to appear in both views, you'll have to add another <menuContribution> that contributes it to the org.eclipse.ui.navigator.ProjectExplorer view. Something like this:
<menuContribution locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<command commandId="plugin.showDifferences" label="Show Differences" style="push">
<activeWhen>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java"/>
</adapt>
</iterate>
</activeWhen>
</command>
</menuContribution>