Introduction: Menus are a prerequisite for a variety of software and development platforms, and Eclipse is no exception, providing a rich menu, including the main menu, the View/Editor menu (Viewpart/editor menu), and the context menu. In Eclipse, almost all of the Workbench part provides a user-friendly menu that greatly facilitates user action. So how to extend Eclipse's menu capabilities and implement menus that are specific to our own plug-ins is an important skill that plug-in developers must master, and Eclipse provides a rich extension point for developers to use. This article will begin by introducing the menus in Eclipse and then detailing how to extend them, and finally, as an example, guide the reader to an in-depth understanding of Eclipse's menu features.
Introduction
With its rich menu capabilities, Eclipse provides a good user experience for developers. Overall, the Eclipse menu categories include the View/editor menu, the main menu, the View/Editor menu (Viewpart/editorpart menu), and the context menu. Plug-in developers can provide users with a good experience by applying these menus flexibly. Because the View and editor menu features are similar, this article focuses on the View menu (View drop down menu and its toolbar menu), in addition to the main menu and context menu.
As shown in Figure 1, the menu for the Project Explorer view includes a view Drop-down menu and a toolbar menu (a collapsed tree node). Typically, the menus that appear on the View toolbar appear in the Drop-down menu of the view, which means that the more commonly used view menus are placed on the view's toolbar.
Figure 1. Menu for Project Explorer view
As shown in Figure 2, the context menu in Project Explorer view appears only when we right-click. Typically, a higher-frequency menu item appears in the menu. Context menu has a strong flexibility, it can be as we click on the object, pop-up menu will change accordingly.
Figure 2. Context menu in Project Explorer view