Enable/disable menu item in Eclipse plugin
You can add a handler that uses activeWhen and associate it with that menu's command id.
Here is a handler that makes a command active only when the current selection is not empty, and the selection is an item that can be adapted to an object of type Widget:
<extension point="org.eclipse.ui.handlers">
<handler class="com.myproject.handlers.ExportWidgetHandler"
commandId="com.myproject.commands.exportWidget">
<activeWhen>
<with variable="selection">
<iterate ifEmpty="false" operator="and">
<adapt type="com.myproject.objects.Widget"/>
</iterate>
</with>
</activeWhen>
</handler>
</extension>