如何在PackageExplorer中仅为目录创建弹出菜单项 [英] How create popup menu item in PackageExplorer only for directories

查看:309
本文介绍了如何在PackageExplorer中仅为目录创建弹出菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写Eclispe(开普勒)插件。此插件的主要目标是在PackageExplorer弹出菜单打开资源管理器项目中添加。目录,软件包等应该可以看到这个项目,但文件不可见。我已经尝试过:

 < 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆