It's useful to be able to add contributions to pop-up menus so that they can be used by different places. Fortunately this can be done fairly easily with the menuContribution
fragment and a combination of enablement tests. However, to implement this in E4, the view must be moved into the fragment.e4xmi
file in order to attach a PopupMenu.
Add the
org.eclipse.ui.services
package as a dependency to theplugin.xml
in the Dependencies tab, if it's not already added.Open the
TimeZoneTableView
class and add the following to the end of thecreatePartControl
method:private void createPartControl(Composite parent, EMenuService menuService) { menuService.registerContextMenu(tableViewer.getControl(), "com.packtpub.e4.clock.ui.popup"); tableViewer.addSelectionChangedListener(event -> { // forward selection Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (selection != null && selectionService...