CIOC
CIOC

Reputation: 1427

Enable plugin only on certain folder (Eclipse RCP)

I created a simple Eclipse plugin, to launch a wizard and create some files, everything is working, I also added an option lo launch the wizard from the New > Mi Wizard menu, but now I want to display this option only when I right click an specific folder in a project, this is what I have so far:

This is my 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>

And this is how I'm adding the wizard to the New menu:

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

The option in the New menu is displayed correctly, but it is displayed when I right click all folders, is there a way to display the option only when I right click a certain folder, specifically the WebContent folder?

Upvotes: 0

Views: 129

Answers (1)

greg-449
greg-449

Reputation: 111142

You can use the org.eclipse.core.resources.name property tester to test the resource 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>

Upvotes: 1

Related Questions