I am developing a context menu for an Eclipse plugin. I need to show the context popup menu only if the user selects a single file. Currently, I am able to show the context menu for multi selection of folders in the Project Explorer. The requirement is to disable or hide the context menu for multi selection of Folders. I cannot use the legacy context popup menu "" as it has been deprecated in Eclipse.
I've provided a snippet of my plugin.xml.
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<category name="My Category" id="mycategory.id" />
<command name="Drop it here" categoryId="mycategory.id" id="myCmd1" />
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="myCmd1" class="com.toyer.FirstHandler" />
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.ui.popup.any">
<command commandId="myCmd1" icon="icons/pino16.png">
<visibleWhen>
<with variable="activeMenuSelection">
<iterate ifEmpty="false">
<adapt type="org.eclipse.core.resources.IProject" />
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>
Please help me to solve this issue.
Use count
to limit the selection to 1
Something like:
<with variable="selection">
<count value="1"/>
<iterate>
<adapt type="org.eclipse.core.resources.IFile"/>
</iterate>
</with>