How to extend the Linkhelper to implement the Navigator's association with the editor

Source: Internet
Author: User
Keywords Extensions editors Linkhelper navigator
Tags .mall aliyun business business models button create eclipse editor

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.