Introduction
By default GMF declares standard ContributionItems within a DiagramContributionItemProvider. If you do not want some of them there is no way to do this declarative by declaring another DiagramContributionItemProvider with a higher priority. The problem is that GMF always takes the entry with the priority lowest and adds everything that is declared with higher priority. To solve the problem you have to remove the unwanted entries programmatically.
Details
By default a DiagramActionBarContributor is generated by GMF.
To remove entries of the standard ToolBar of an editor you have to declare a custom variant.
Due to this you have to redeclare your generated editor in a custom plugin:
<extension point="org.eclipse.ui.editors">
<editor
id="....ExampleDiagramEditorID"
name="Example Diagramm Editing"
icon="icons/obj16/ExampleDiagramFile.gif"
extensions="example_diagram"
default="true"
class="....ExampleDiagramEditor"
matchingStrategy="....ExampleMatchingStrategy"
contributorClass="....CustomExampleDiagramActionBarContributor">
</editor>
</extension>
Within this custom class you have to override the init method like this:
@Override
public void init(IActionBars bars, IWorkbenchPage page) {
super.init(bars, page);
IToolBarManager toolBarManager = bars.getToolBarManager();
toolBarManager.remove("fontNameContributionItem");
toolBarManager.remove("fontSizeContributionItem");
}
After the call of the init method of the superclass all declared entries are in the toolBarManager of the ActionBar. To remove the unwanted entries you have to get the ToolBarManager and call the remove method with the id of the unwanted ContributionItem.