Source:
<code>private void createToolControlMenu(final MToolControl toolControl, Control renderedCtrl, boolean hideable) { toolControlMenu = new Menu(renderedCtrl); if (hideable) { MenuItem hideItem = new MenuItem(toolControlMenu, SWT.NONE); hideItem.setText(Messages.ToolBarManagerRenderer_MenuCloseText); hideItem.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { toolControl.getTags().add( IPresentationEngine.HIDDEN_EXPLICITLY); } }); new MenuItem(toolControlMenu, SWT.SEPARATOR); } MenuItem restoreHiddenItems = new MenuItem(toolControlMenu, SWT.NONE); restoreHiddenItems .setText(Messages.ToolBarManagerRenderer_MenuRestoreText); restoreHiddenItems.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { removeHiddenTags(toolControl); } }); this.application.getMenuContributions().stream() .filter(menuModel -> menuModel.getPositionInParent().startsWith("popup:toolbar")) .forEach(menuContribution -> { menuContribution.getChildren().forEach(itemModel -> { if (itemModel instanceof MItem) { final IEclipseContext lclContext = getContext(itemModel); HandledContributionItem itemRenderer = ContextInjectionFactory .make(HandledContributionItem.class, lclContext); itemRenderer.setModel((MItem) itemModel); itemRenderer.fill(toolControlMenu, 0); } }); <START> }); <END> renderedCtrl.setMenu(toolControlMenu); }</code><technical_language>Sorry, code nice additions Java 8 of this is debuggable anymore. snippet exact allows debugging: for (MMenuContribution menuModel : application.getMenuContributions()) { String positionInParent = menuModel.getPositionInParent(); if (positionInParent.startsWith("popup:toolbar")) { //$NON-NLS-1$ for (MMenuElement itemModel : menuModel.getChildren()) { if (itemModel instanceof MItem) { final IEclipseContext lclContext = getContext(itemModel); HandledContributionItem itemRenderer = ContextInjectionFactory .make(HandledContributionItem.class, lclContext); itemRenderer.setModel((MItem) itemModel); itemRenderer.fill(toolControlMenu, 0); } } } }</technical_language>

Target:
private void createToolControlMenu(final MToolControl toolControl, Control renderedCtrl, boolean hideable) { toolControlMenu = new Menu(renderedCtrl); if (hideable) { MenuItem hideItem = new MenuItem(toolControlMenu, SWT.NONE); hideItem.setText(Messages.ToolBarManagerRenderer_MenuCloseText); hideItem.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { toolControl.getTags().add( IPresentationEngine.HIDDEN_EXPLICITLY); } }); new MenuItem(toolControlMenu, SWT.SEPARATOR); } MenuItem restoreHiddenItems = new MenuItem(toolControlMenu, SWT.NONE); restoreHiddenItems .setText(Messages.ToolBarManagerRenderer_MenuRestoreText); restoreHiddenItems.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(org.eclipse.swt.widgets.Event event) { removeHiddenTags(toolControl); } }); for (MMenuContribution menuModel : application.getMenuContributions()) { String positionInParent = menuModel.getPositionInParent(); if (positionInParent.startsWith("popup:toolbar")) { for (MMenuElement itemModel : menuModel.getChildren()) { if (itemModel instanceof MItem) { final IEclipseContext lclContext = getContext(itemModel); HandledContributionItem itemRenderer = ContextInjectionFactory .make(HandledContributionItem.class, lclContext); itemRenderer.setModel((MItem) itemModel); itemRenderer.fill(toolControlMenu, 0); } } } } renderedCtrl.setMenu(toolControlMenu); }