Time for action – creating toolbars

The first step is to add the toolbar icons, which are the informational icons in the top right. In the original implementation, these were direct Action elements inserted into a ToolBar, which is part of the Eclipse 3.x interface. To achieve this with Eclipse 4.x, models using MDirectToolItem will be created and added to an MToolBar.

  1. Create a private method createToolBar in the SampleView class. Add a call to the bottom of the createPartControl method to ensure that it is called at view creation time.
  2. Inside the createToolBar method, create an instance of an MDirectToolItem object using the MMenuFactory.INSTANCE.createDirectToolItem() expression. It may be necessary to follow the quick-fix to add org.eclipse.e4.ui.model.workbench ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.