I want to contribute a context menu only when the following 2 conditions are met:
1.- If selected file has .txt extension 2.- If parent project of the selected file has an specific facet
I can do this by separate using the following conditions using the org.eclipse.ui.menus
extension point, i.e: for the project facet:
<with variable="activeMenuSelection">
<iterate operator="and" ifEmpty="false">
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jst.code.quality" forcePluginActivation="true" />
</adapt>
</iterate>
</with>
And for the file extension:
<with variable="activeMenuSelection">
<iterate operator="and" ifEmpty="false">
<adapt type="org.eclipse.core.resources.IFile">
<test property="org.eclipse.core.resources.extension" value="txt" forcePluginActivation="true" />
</adapt>
</iterate>
</with>
But I have problems to combine this two conditions since the activeMenuSelection
variable will only contain the file and I can't use it to test the project facet, is there a variable I can use to access the active project in the same condition?
答案 0 :(得分:1)
The org.eclipse.wst.common.project.facet.core.projectFacet
test will work on any IResource
so it will work on an IFile
as well as an IProject
. So you can combine the tests.