This article will introduce the principle of linkhelper implementation, and combine two concrete examples to illustrate how to extend Linkhelper to implement the Navigator-Editor Association for common resource files and specific business models.
Link with Editor is a very small, but surprisingly useful, feature of the http://www.aliyun.com/zixun/aggregation/13428.html >eclipse built-in feature. This switch button (Toggle button) appears in the upper-right corner of various navigator views (such as Resource Explorer, Package Explorer, etc.). When clicked, the Navigator view can be expanded according to the currently open file, and is quickly associated with the node.
Figure 1. Example of the Link with Editor feature in Java Package Explorer
Link with Editor is introduced with the Eclipse CNF (Common Navigator Framework) framework in Eclipse 3.2, designed to help Third-party plug-ins to easily extend Link with Editor functionality on the Common navigator.
Let's start by creating an eclipse-built plug-in example to see how Project Explorer's Link with Editor functionality is implemented in the Eclipse source code: for example, which extension point is extended and which hooks (hook) methods are implemented. Finally, based on this example, the business model layer is introduced and the function is perfected.
Software Environment requirements
Eclipse 3.4+ jdk1.5+
Introduction of Linkhelper Principle
First, use the plug-in template built in Eclipse to create the first example, as follows:
new> Plug-in developement> Plug-in project> Next, complete with project name "Eclipse.linkwitheditor.sample" > Next> Selection " Custom Plug-in Wizard "> next> Select" Template.commonNavigator.name "> Next> Finish.
Figure 2. Create a new Eclipse built in CNF plug-in project
This example of a simple CNF application is created.
Open the Plugin.xml Extensions page, first extend the org.eclipse.ui.views extension point to define the Navigator view in this example, the ID is com.example.test.
Note that the implementation class here is Org.eclipse.ui.navigator.CommonNavigator and inherits from Viewpart, which is part of the implementation within the Eclipse CNF system. When you create a navigator view for a particular model, you typically specify it as the implementation of the view, or inherit this class to implement the functionality.
Next, expand the org.eclipse.ui.navigator.viewer extension point to define which actions and what extensions are supported on this navigator view. Vieweractionbinding and viewercontentbinding all need to specify Com.example.test as the view ID. Vieweractionbinging is not the focus of this article, skip here.
Four content definition points (contentextension) are specified in Viewercontentbinding, as shown in Figure 3:
Figure 3. Navigator.viewer definition in Plugin.xml