如何在PackageExplorer中仅为目录创建弹出菜单项 [英] How create popup menu item in PackageExplorer only for directories
问题描述
< menuContribution
locationURI =popup:org.eclipse.jdt.ui。 PackageExplorer>
< command
commandId =pl.com.tt.wide.lms.core.commands.sampleCommand
id =pl.com.tt.wide.lms.core.menus .sampleCommand
mnemonic =S>
< visibleWhen>
< with variable =activeMenuSelection>
< iterate
ifEmpty =false>
< adapt type =org.eclipse.core.resources.IResource>
< test property =org.eclipse.core.resources.typevalue =org.eclipse.core.resources.FOLDER/>
< / adapt>
< / iterate>
< / with>
< / visibleWhen>
< / command>
< / menuContribution>
这不工作。你有什么建议如何完成这个?
感谢任何帮助。
Package Explorer不仅使用类型 org .eclipse.core.resources
,但也使用 org.ecliplse.jdt.core
的类型。看看 IPackageFragment
, IPackageFragmentRoot
和
code> IJavaProject 。在或
语句中使用这些可能会产生你想要的。
这对我有用: / p>
< visibleWhen>
< with variable =activeMenuSelection>
< iterate ifEmpty =false>
<或>
< adapt type =org.eclipse.jdt.core.IJavaProject>
< / adapt>
< adapt type =org.eclipse.jdt.core.IPackageFragmentRoot>
< / adapt>
< adapt type =org.eclipse.jdt.core.IPackageFragment>
< / adapt>
< /或>
< / iterate>
< / with>
< / visibleWhen>
I am writing Eclispe (Kepler) plugin. Main goal of this plugin is to add in PackageExplorer popup menu "Open In Explorer" item. This item should be visible for directories,packages etc. but no for files. I've tried this:
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command
commandId="pl.com.tt.wide.lms.core.commands.sampleCommand"
id="pl.com.tt.wide.lms.core.menus.sampleCommand"
mnemonic="S">
<visibleWhen>
<with variable="activeMenuSelection">
<iterate
ifEmpty="false">
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.type" value="org.eclipse.core.resources.FOLDER"/>
</adapt>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
This is not working. Do you have any suggestions how to accomplish this? Thanks for any help.
The Package Explorer does not only use types of org.eclipse.core.resources
but uses the types of org.ecliplse.jdt.core
, too.
Have a look at IPackageFragment
, IPackageFragmentRoot
and IJavaProject
. Using these in an or
statement will probably produce, what you want.
This is what worked for me:
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false">
<or>
<adapt type="org.eclipse.jdt.core.IJavaProject">
</adapt>
<adapt type="org.eclipse.jdt.core.IPackageFragmentRoot">
</adapt>
<adapt type="org.eclipse.jdt.core.IPackageFragment">
</adapt>
</or>
</iterate>
</with>
</visibleWhen>
这篇关于如何在PackageExplorer中仅为目录创建弹出菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!