E ARLY ACCESS PROGRAM CHAPTER
Eclipse in Action: A Guide for Web Developers
by David Gallardo, Ed Burnette and Robert McGovern
Chapter 8
Copyright 2003 Manning Publications
Licensed to bullboss
bullboss@163.com
iii
contents
PART IUSING ECLIPSE
Chapter 1 ■ Overview
Chapter 2 ■ Getting started with the Eclipse Workbench
Chapter 3 ■ The Java development cycle: test, code, repeat
Chapter 4 ■ Working with source code in Eclipse
Chapter 5 ■ Building with Ant
Chapter 6 ■ Source control with CVS
Chapter 7 ■ Creating J2EE applications
PART II EXTENDING ECLIPSE
Chapter 8 ■ Introduction to Eclipse plug-ins
Chapter 9 ■ Working with plug-ins in Eclipse
Appendix A ■ Java perspective menu reference
Appendix B ■ CVS installation procedures
Appendix C ■ Plug-in extension points
Appendix D ■ Introduction to SWT
Appendix E ■ Introduction to JFace
1
8
Introduction
to Eclipse plug-ins
In this chapter…
■
Understanding Eclipse’s plug-in architecture
■
Preparing your Workbench for plug-in
development
■
Using the Plug-in Development Environment
(PDE)
■
Creating simple plug-ins using the built-in
wizards and templates
Licensed to bullboss <bullboss@163.com>
2
CHAPTER 8
Introduction to Eclipse plug-ins
Up to now, you’ve been using Eclipse as it comes out of the box. As you’ll discover
in this chapter, however, the beauty of Eclipse lies in its extensible architecture.
This architecture allows anyone to add features and capabilities the original
designers never dreamed of.
Eclipse’s loosely connected design is perfect for systems that aren’t designed
all at once, but instead are built up from components written for particular needs.
From its earliest roots, Eclipse was designed as an “open extensible
IDE
for any-
thing, and nothing in particular.” The decentralization that plug-ins provide gives
the Eclipse Platform the ability to morph into any application and support any
language. Come with us now as we seek out that man behind the curtain and learn
the secrets of Eclipse plug-ins.
8.1 Plug-ins and extension points
Imagine a giant jigsaw puzzle. A few pieces are already connected for you—these
will form the core around which the rest of the puzzle is built. The boundaries
between the pieces are uniquely cut to fit snugly together. If Eclipse is the puzzle,
then the pieces are plug-ins. A plug-in is the smallest extensible unit in Eclipse. It
can contain code, resources, or both.
The Eclipse Platform consists of nearly 100 plug-ins working together. The
boundaries between these pieces that let plug-ins connect to one another are
called extension points. An extension point is the mechanism by which one plug-in
can add to the functionality of another.
Appendix C lists the extension points provided by the Platform. Each one can
be used to add some new component such as a menu or view to the system, and
is usually associated with a Java class that performs the logic for the component.
Unlike most jigsaw puzzles, though, Eclipse has no corners or straight edges.
It can be extended forever, with each new plug-in defining its own extension points
that other plug-ins can use. Large projects such as WebSphere Studio have hun-
dreds of plug-ins. (Better bring a big table.)
8.1.1 Anatomy of a plug-in
Plug-ins are conceptually simple. If you look at the directory where you installed
Eclipse in chapter 2, you will see a subdirectory called plugins. Inside this direc-
tory you’ll find one directory for every plug-in. The name of each directory is the
same as the name of the plug-in, followed by an underscore and a version num-
ber. For example:
Licensed to bullboss <bullboss@163.com>