Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By : Alex Blewitt
Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By: Alex Blewitt

Overview of this book

Eclipse is used by everyone from indie devs to NASA engineers. Its popularity is underpinned by its impressive plug-in ecosystem, which allows it to be extended to meet the needs of whoever is using it. This book shows you how to take full advantage of the Eclipse IDE by building your own useful plug-ins from start to finish. Taking you through the complete process of plug-in development, from packaging to automated testing and deployment, this book is a direct route to quicker, cleaner Java development. It may be for beginners, but we're confident that you'll develop new skills quickly. Pretty soon you'll feel like an expert, in complete control of your IDE. Don't let Eclipse define you - extend it with the plug-ins you need today for smarter, happier, and more effective development.
Table of Contents (24 chapters)
Eclipse Plug-in Development Beginner's Guide Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – adding the view menu


The next step is to add the view menu, which is the drop-down menu shown by the triangle in the top-right of the original view. Adding this takes the same pattern as before, but the drop-down menu requires an additional tag to be shown as a view menu.

  1. Add a method createViewMenu in the SampleView class. Add a call to the createPartControl method so that it is called when the view is created.

  2. In the createViewMenu method, create an instance of MMenu using MMenuFactory.INSTANCE.createMenu().

  3. Add the menu to the part using part.getMenus().add(menu).

  4. To configure the menu as a view menu, add a tag ViewMenu using menu.getTags().add("ViewMenu").

  5. As with toolbar items, a menu item can either be handled or direct. A direct menu item is associated directly with a handler implementation class. Create a direct menu item with MMenuFactory.INSTANCE.createDirectMenuItem() and store it in a local field one. Set the tooltip and label appropriately, and use the same icon...