11.2 Using the Plug-in Development Environment

     

The Eclipse platform is already a conglomeration of over a hundred plug-ins, and they build on each other using extension points . An extension point lets one plug-in build on what another plug-in exports. In this chapter, we're going to use extension points to add new menus , buttons , and so on to Eclipse in a plug-in.

Plug-ins can only make use of classes exported by other plug-ins, which makes extension points especially important. For example, to let a plug-in make use of prebuilt Java code, you can wrap JAR files inside plug-ins and let other plug-ins depend on it. Much support for custom plug-ins is already built into several standard plug-ins that come with Eclipse.


Using the Eclipse Plug-in Development Environment (PDE), you can build plug-ins that will build on the standard extension points available. Here are the types of plug-in projects that the PDE will create for you:


Plug-in projects

A standard plug-in


Fragment projects

An add-on or addition to a plug-in (sometimes used for internationalization)


Feature projects

Projects that contain one or more plug-ins


Update site projects

Web site that can automatically install features

The PDE has a number of built-in Wizards, and we're going to make use of that support in our next example. This example will create a simple plug-in that supports both a menu item and a button in the toolbar. To create the plug-in project, select File New Project. Select Plug-in Development in the left box of the New Project dialog and Plug-in Project in the right box, as shown in Figure 11-2. Then click Next.

Figure 11-2. Creating a plug-in project
figs/ecps_1102.gif

In the next pane, name the project org.eclipsebook.ch11.Ch11_01 , as you see in Figure 11-3, and click Next. This project name will also be the ID of the plug-in when it comes time to use it in Eclipse.

Figure 11-3. Naming the project
figs/ecps_1103.gif

In the next pane, make sure the "Create a Java project" radio button is selected, as you see in Figure 11-4, and click Next.

Figure 11-4. Setting the project type
figs/ecps_1104.gif

The next pane is the Plug-in Code Generators pane, shown in Figure 11-5. We're going to select the built-in "Hello, World" example here, so select the "Hello, World" item in the left box and click Next. (This pane also allows you to create other types of plug-in projects, such as plug-ins with editors, views, and so on.)

Figure 11-5. Creating a Hello, World example
figs/ecps_1105.gif

In the following pane you can configure the plug-in. Enter a provider namewe'll use Eclipse Book and accept the other defaults, which appear in Figure 11-6. Click Finish to create the code for this plug-in (clicking Next here would let you set the text the plug-in displays in its message box, but the default text is fine).

Figure 11-6. Configuring the plug-in
figs/ecps_1106.gif

Clicking Finish opens the plug-in manifest editor, as you see in Figure 11-7, where it's displaying a Welcome page. You can open the editor later yourself by double-clicking plugin.xml in the Package Explorer.

Figure 11-7. The plug-in manifest editor
figs/ecps_1107.gif

The plug-in manifest editor looks simple, but there's a lot going on here. Note, in particular, the tabs at the bottom of the editor:


Welcome

The Welcome page you see in Figure 11-7, describing the plug-in


Overview

Holds summary information for the plug-in, such as name, version, provider name, and so on


Dependencies

Indicates the plug-ins required for this plug-in


Runtime

Indicates the libraries needed to run this plug-in


Extensions

Indicates the extensions points used by the plug-in


Extension Points

Indicates the extension points defined by the plug-in


Source

An XML editor that lets you edit the source code for plugin.xml

The manifest editor lets you edit plugin.xml , either directly by clicking the Source button, or by using the various tabs in the editor. For example, to build on the standard extension points, you can click the Extensions tab and use the Add button to add functionality to your plug-in, as we'll do later in this chapter. When you make changes this way, the PDE edits plugin.xml for you automatically, saving you the trouble of editing raw XML.



Eclipse
Eclipse
ISBN: 0596006411
EAN: 2147483647
Year: 2006
Pages: 114
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net