Developing Eclipse Plug-ins, Page 3
Here, you've overridden the getText(Object) method to return the element's (an instance of IViewDescriptor) label as the text to show in the table. To make it more visually appealing, you also overrode the getImage(Object) method to return each view's associated icon image to accompany its label. This, however, is a little more complex. When you study JFace (the viewer framework used here) and SWT (its underlying widget toolkit), you will discover that images (org.eclipse.swt.graphics.Image) are operating system resources that need to be managed by the application. IViewDescriptor, however, only returns an ImageDescriptor rather than the Image itself. An image descriptor may be used to create an Image instance, but this must subsequently be disposed of when no longer in use. For that reason, you track all Image instances that you create in a descriptor-to-image map, and dispose them when the label provider itself is disposed (in other words, no longer needed by the viewer).
To see the final outcome, relaunch the run-time workbench (Ctrl+F11).
Packaging and Distributing Finished Plug-ins
This kind of distribution and installation is called unmanaged—you leave the user with the responsibility of finding and installing any updates to your plug-in, should you release any in the future. A more structured approach is to group your plug-ins into features. A feature is a set of plug-ins that are installed and managed together. In addition to grouping the plug-ins, features contain information that allows the Eclipse Update Manager to locate any published updates and discover any new related features. Such updates are typically published in a special Web directory called an Update Site. PDE provides wizards and editors to support the development of features as well as update sites.
If you develop entire applications rather than just plug-ins (or features) that need an existing Eclipse-based product to install into, you would use the Product Configuration editor, together with the Eclipse Product export wizard, to package your application as a standalone Eclipse product. However, this is an advanced topic that deserves at least one article of its own.
Eclipse is a great tool and rich-client application platform not only for the free components it provides, but also for the openness of its own implementation. In Eclipse, all functionality is encapsulated in plug-ins, which "plug into" one another using well-defined extension points. Its Plug-in Development Environment provides powerful tools and wizards to help you get started developing your own plug-ins. More importantly, PDE will support your development throughout the entire cycle, including distribution and post-production maintenance.
In this article, you developed a simple visual plug-in to demonstrate the required steps and tools provided by Eclipse. In the next installment, you will take a closer look at the core components and frameworks used to build Eclipse applications.
- Eclipse Help (click Help -> Help Contents in the main menu), also available online at http://help.eclipse.org/help31. See the PDE Guide section for information on PDE tools, and the Platform Plug-in Developer Guide for documentation on Eclipse architecture, API, and extension points.
- Many good books, such as the Java Developer's Guide to Eclipse, Building Commercial-Quality Plug-ins, and Contributing to Eclipse.
- The example plug-in developed in this article is available here. To import it into your clean, new workspace as a project, click File -> Import; then choose the Existing Projects into Workspace wizard, and specify the path to your downloaded archive file.
Page 3 of 3