Chapter 2. Setting Up Eclipse for Plug-In Development

Developing plug-ins is a little different than developing vanilla Java applications. First, you need to be able to refer to Eclipse's own internal structure to extend that structure. Second, you will spend much of your early hours as an Eclipse contributor reading source code, so you need access to all the source.

One way to solve these problems is to load the entire source (around one million lines of code) into the workspace. Managing this huge amount of source can expand the memory footprint of Eclipse. However, we will typically only read existing code and not modify or compile it. Fortunately, PDE offers a quick and space-efficient way to set up a workspace where existing plug-ins cannot be modified, but can be browsed. The trick is to represent existing plug-ins as binary projects. Binary projects cannot be modified, but are fully searchable for references and declarations.

The distinction is between working with and working on. A project you are working with can be represented as a binary project, saving space. A project you are working on must be represented as source.

Setting Up a Workspace

Here is how to set up a workspace with binary projects for all the plug-ins shipped with Eclipse:

  1. If you don't want to pollute your existing workspace, start Eclipse with an empty workspace (use -data new_workspace_location on the command line).

  2. Switch to the Java perspective by selecting Window > Open Perspective > Java.

  3. Choose File > Import... > External Plug-ins and Fragments. Accept the defaults on the next page. On the third page click Select All to import all plug-ins from your host workspace.

  4. Click Finish. The plug-ins will be imported into binary projects, their build class paths initialized, as shown in Figure 2.1.

    Setting Up a Workspace

Browsing and Searching Source

You can now browse and search the full Eclipse source. Choose Navigate > Open Type… and type in *. You should see thousands of classes. You will have around 60 Eclipse plug-in projects in your workspace.

If you do not want to see these binary projects, hide the binary projects in the Package Explorer by turning on a filter for binary projects. Select Filters from the Package Explorer view pull-down menu, as shown in Figure 2.2 and select Binary plug-in and feature projects in the subsequent dialog, as shown in Figure 2.3.

Browsing and Searching Source
Browsing and Searching Source

If you started Eclipse in a clean workspace, the Package Explorer will be empty after you invoke the filter because you haven't created any source plug-in projects yet.

One thing to keep in mind when you install a new version of EclipseDo not forget to reimport the plug-ins that come with this build. To do so, click the Existing Binary Projects button on the import wizard's plug-in selection page. This will replace your existing binary projects with the code for the new versions.

Now Eclipse is ready to say “hello” to the world.

Forward Pointers

  • Workspace set up with binary projects but linked contents—If you have a large number of plug-ins and you don't want to create a copy of all plug-ins in your workspace, you can uncheck the Copy plug-in contents into the workspace location check box when you import the plug-ins. In this case, PDE creates the plug-in projects in your workspace, but it “links” their contents instead of making a copy.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset