【问题标题】:Enable plugin only on certain folder (Eclipse RCP)仅在特定文件夹上启用插件(Eclipse RCP)
【发布时间】:2015-03-26 11:10:45
【问题描述】:

我创建了一个简单的 Eclipse 插件,用于启动向导并创建一些文件,一切正常,我还添加了一个从 New > Mi Wizard 菜单启动向导的选项,但现在我只想在我右键单击项目中的特定文件夹,这是我目前所拥有的:

这是我的向导:

<extension point="org.eclipse.ui.newWizards">
    <category
        name="My Category"
        id="com.test.myCategory">
    </category>
    <wizard
        name="My Wizard"
        icon="icons/wizard1.gif"
        category="com.test.myCategory"
        class="com.test.myWizard"
        id="com.test.myWizard">
    </wizard>
</extension>

这就是我将向导添加到New 菜单的方式:

<extension point="org.eclipse.ui.navigator.navigatorContent">
    <commonWizard 
        type="new" 
        wizardId="com.test.myWizard"
        menuGroupId="testGroup">
        <enablement>
            <adapt type="org.eclipse.core.resources.IFolder">
                <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="myFacet:1.3" forcePluginActivation="true"/>
            </adapt>
        </enablement>
    </commonWizard>
</extension>

New菜单中的选项显示正确,但是右键所有文件夹时显示,有没有办法只在我右键单击某个文件夹时才显示选项,特别是WebContent文件夹?

【问题讨论】:

    标签: eclipse-plugin eclipse-rcp plugin.xml


    【解决方案1】:

    您可以使用org.eclipse.core.resources.name属性测试器来测试资源名称:

    <adapt type="org.eclipse.core.resources.IFolder">
      <and>
        <test property="org.eclipse.core.resources.name" value="WebContent"/>
        <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="myFacet:1.3" forcePluginActivation="true"/>
      </and>
    </adapt>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多