In order to add new menu menuContribution entry is used.
locationURI property determines where menu will be added.
Examplary locationURI:
→ popup:org.eclipse.ui.popup.any?after=additions
→ toolbar:org.eclipse.ui.views.ContentOutline?after=additions
→ popup:org.eclipse.jdt.ui.PackageExplorer?before=additions
→ menu:sourceMenuId?before=sourceBegin
→ popup:sourcePopupMenuId?before=sourceBegin
→ menu:sourceMenuId?after=sourceBegin
→ popup:sourcePopupMenuId?after=sourceBegin
→ menu:org.eclipse.ui.main.menu?after=sourceMenuId
Where in that cases sourceMenuId and sourcePopupMenuId are menus registered with org.eclipse.ui.actionSets extension point.
Typically menuContribution entries contain command entries.
Command entries can define visibleWhen and properties.
Example:
<menucontribution locationURI="menu:sourceMenuId?before=sourceBegin"> <command commandId="org.eclipse.php.ui.edit.text.add.description" id="AddDescription" mnemonic="%command.mnemonic" style="push"> <visiblewhen checkEnabled="false"> <reference definitionId="org.eclipse.php.ui.phpContentType.definition" /> </visibleWhen> </command> </menuContribution>VisibleWhen among others allow to specify reference property which references to definition regristered with org.eclipse.core.expressions.definitions extension point.
Example:
<extension point="org.eclipse.core.expressions.definitions"> <definition id="org.eclipse.php.ui.phpContentType.definition"> <with variable="activeContexts"> <iterate operator="or"> <equals value="org.eclipse.php.core.phpsource" /> </iterate> </with> </definition> </extension>Other option can be specifying with property.
Example:
<visiblewhen> <with variable="selection"> <iterate> <or> <instanceof value="o.e.editors.OutlineContentProvider$Sources"> </instanceof> <instanceof value="o.e.editors.OutlineContentProvider$Targets"> </instanceof> </or> </iterate> </with> </visibleWhen>or:
<with variable="selection"> <iterate> <instanceof value="c.c.model.VisualizableBlock"> </instanceof> </iterate> </with>