RCP 客户端中自定义启动器的方法级别子菜单

问题描述

我在 Eclipse 中编写了一个自定义启动器,我可以通过类级别的“运行方式”和“调试方式”访问它。我有一个How do I use "org.eclipse.debug.ui.launchShortcuts"? 中描述的类似的配置。不幸的是,我无法在方法级别的包资源管理器中看到子菜单(例如,用于启动客户启动器以执行单个 JUnit 测试的子菜单)。我该怎么做?

解决方法

JUnit 使用 contextualLaunch 基于所选元素是 org.eclipse.jdt.core.IJavaElement 而不仅仅是资源。你也需要这样做。

这是 JUnit 使用的:

<contextualLaunch>
     <enablement>
         <with variable="selection">
             <count value="1"/>
              <iterate>
                <adapt type="org.eclipse.jdt.core.IJavaElement">
                    <and>
                        <test property="org.eclipse.jdt.core.isInJavaProject"/>
                        <or>
                        <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="junit.framework.Test"/>
                        <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="org.junit.platform.commons.annotation.Testable"/>
                        </or>
                        <test property="org.eclipse.jdt.junit.canLaunchAsJUnit" forcePluginActivation="true"/>
                    </and>
                </adapt>
             </iterate>
         </with>
    </enablement>
</contextualLaunch>

某些 <test 元素特定于 JUnit,因此您需要使用不同的元素。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...