Plug-in Development Environment (PDE) in Eclipse

Laurie Williams, Dright Ho, Sarah Smith
Department of Computer Science
North Carolina State University

Back to Software Engineering Tutorials

0.0 Outline
1.0 Creating a Plug-in Project
2.0 Using the plugin.xml File
3.0 Creating an Extension to Eclipse
4.0 Running the Plug-in as a Runtime Workbench
5.0 Exporting Project as a Plug-in
6.0 Resources

1.0 Creating a Plug-in Project

1.1 There are three ways to create a Java project:

1.1.1 Select File > New > Project,

1.1.2 Select the arrow of the button in the upper left of the toolbar. Select Project, or

1.1.3 Right click on the Package Explorer view in the Java Perspective, and select Project.

1.2 Select Plug-in Project and click Next.

1.3 Give the project a name. Under the project setting section check Create a Java project, and specify the source and bin folders. Press Next.

1.4 Change the plug-in content information like the plug-in id, version, name, provider, and library. Make sure the Generate the Java class that controls the plug-in's life cycle is checked. This creates a plug-in class that controls the plug-in. Press Next.

1.5 If you would like sample plug-in resources to be created, check the Create a plug-in using one of these templates box. You can select to create a multi-page editor, editor, popup menu, property page, view, or a perspective extension. However, you can create any of these sample plug-ins at any time after your plug-in project is created, and this is covered in section 2. If you wish to just start with a blank plug-in select Finish, otherwise choose the sample plug-in you wish to create an press Next. Follow the instructions of the sample plug-in you wish to create. The defaults provided for you should be sufficient, but you may wish to rename classes, etc.

1.6 After you press Finish you will be switched to the plug-in development perspective in Eclipse, and the plugin.xml file will be displayed in the editor.

Top | Contents

2.0 Using the plugin.xml File

The plugin.xml file is the center of a plug-in. The information stored in this file tells Eclipse when and where to use the new views, perspectives, wizards, dialogs, etc. that you created in your plug-in. plugin.xml is a multipage editor. The first six pages of the editor (Overview, Dependencies, Runtime, Extensions, Extension Points, and Build) are provided to guide the user into creating the resources they want with a UI instead of directly editing the xml itself. The tab labeled plugin.xml contains the actual xml code that runs your plug-in. It is better to go through the UI tabs provided for you instead of editing the actual xml code. The last tab is called and contains the details of the plug-in build. Below is a more detailed description of each tab.

  • Overview: This tab provides general plug-in information and details. There are links to modify the plug-in content, how to run and test the plug-in, and how to deploy the plug-in.
  • Dependencies: This tab lists the Eclipse plug-ins that your plug-in depends on in order to run. As a default you will have org.eclipse.ui and org.eclipse.core.runtime since these two Eclipse plug-ins are the minimum required to run a plug-in of Eclipse (they are the core Eclipse code). You can modify the properties and analyze the dependencies (for example see if there are dependency cycles, so that you can minimize your plug-in dependencies).
  • Runtime: This tab provided runtime information about your plug-in, in particular the libraries required to be on the path when the plug-in is run. Therefore any libraries that you require (like SQL libraries) should be listed under the Runtime tab so that they can be found when your plug-in is deployed.
  • Extensions: This tab provides a list of extensions to Eclipse that you plug-in creates. Some examples of extensions are a new perspective, view, wizard, dialog, etc. If you wish to add and extension, this is the place it needs to be done.
  • Extension Points: This tab provides the functionality of extending current functionality of Eclipse features. For example, if you wish to add a button, action, or view to a perspective that already exists in Eclipse you would extend that perspective through its extension point.
  • Build: This tab sets up the file and determines what is included in your deployed plug-in. At a minimum the plugin.xml file must be included as well as the jar file of your plug-in class files. You can also choose to include other information likes tests, documentation, source code, etc. Make sure that your libraries are included!
  • plugin.xml: This tab contains the xml code of your plug-in. Be careful editing this file!
  • This tab contains the text version of your build properties that Eclipse uses to build your project. Edit your build properties through the Build tab and not through this tab.
Top | Contents

3.0 Creating an Extension to Eclipse

In order to create an extension to Eclipse you need to decide what you want your new piece of functionality to be. The most common extensions to create are Perspectives, Views, Actions, Wizards, and Editors; however, there are several other options. If you wish to add a new way of looking at a programming task, then you will want to create a perspective. If you want to add a small piece of functionality that should be visible at the top level to a user or that supplements a programming task, then you will want to create a view. An action is used to do a small piece of functionality, and is usually invoked from a button in the toolbar, a menu, or context menu. If you want to create a way to create a new item (like an editor) then you will want to create a wizard. You would create an editor if you have a new way that you want users to modify data.

3.1 After you know how you want to extend Eclipse, you will need to open up the plugin.xml file and go to the Extensions tab. Click the Add button.

3.2 The new Extension wizard will be displayed. This is where you select what you want to extend. The first tab contains the items that you can extend:

  • Perspectives: org.eclipse.ui.perspectives
  • Views: org.eclipse.ui.views
  • Actions: org.eclipse.ui.actionDefinitions, org.eclipse.ui.actionSetPartAssociations, org.eclipse.ui.actionSets, org.eclipse.ui.dropActions, org.eclipse.ui.editorActions, org.eclipse.ui.viewActions
  • Wizards: org.eclipse.ui.exportWizards, org.eclipse.ui.importWizards, org.eclipse.ui.newWizards
  • Editors: org.eclipse.ui.editors

The second tab, Extension Wizards, has wizards that create sample extension for you. This is a good place to go if you have never created a plug-in before. If there is a plus sign on the plug-in icon in the Extension tab, that means there's a wizard that you can use to create a sample. If you just want to choose an extension, press Finish, otherwise, if you are going through a wizard, press Next, and follow the instructions.

It is good form to have each of your extensions exist in a different package. For example, if you have a perspective and a view you would have a edu.ncsu.csc326.project.perspective package and a edu.ncsu.csc326.project.views package. You can then place logic and other code into different packages as necessary.

Top | Contents

4.0 Running the Plug-in as a Runtime Workbench

Running a plug-in application from the Eclipse development environment is very similar to running a regular Java application, JUnit test, and FIT tests. The major difference is that when running a runtime workbench application, a new instance of the Eclipse workbench will be created that will have the plug-in that is under development installed. This way you can test your plug-in without having to export the plug-in after every update.

4.1 To run your plug-in as a runtime workbench select the run button [insert image] from the Eclipse toolbar.

4.2 Select Runtime Workbench from the column on the left and select New.

4.3 Make sure that your project is listed correctly in the run information. You may also select the options that will cause a new instance of the workbench to be created each time it is run, but for the most part you don't need to do that.

4.4 If you have all of your libraries and paths set up properly in your plugin.xml file, then you should not have to change any of the default data that is provided in the Run dialog for you.

4.5 When you hit the Run button, wait for a minute or two for the new Eclipse instance to open. Then you can go and test your program in the Eclipse environment.

Top | Contents

5.0 Exporting Project as a Plug-in

After you have completed your plug-in, you are ready to package it for release to your customer.

5.1 Right click on the plug-in project, and select Export....

5.2 Select Deployable plug-ins and fragments, and click Next.

5.3 Make sure your project is (the only one) selected in the list of Available Plug-ins and Fragments.

5.4 Choose the Deploy as a single Zip file export option. You may also check to include source code in this area as well.

5.5 Choose the destination where you wish to save your plug-in, and click Finish.

The files that are included in you plug-in deployment depend on the files that you have selected in your plugin.xml file. Make sure that you include all libraries that you need for you plug-in are set to be added to your plug-in when it is deployed.

Top | Contents

6.0 Resources

Resources for Eclipse plug-ins can be found on the Eclipse website under technical articles and newsgroups (simple registration required to view).

There are also several of these resources, and others, linked from the Plug-in Development module on OpenSeminar. Also, see The Java Developer's Guide to Eclipse by Shavor, Sherry et al.

Top | Contents

Back to Software Engineering Tutorials
Plug-in Development Environment (PDE) in Eclipse Tutorial ©2003-2004 North Carolina State University, Laurie Williams, Dright Ho, Sarah Smith
Email Sarah Smith with any questions or comments about this tutorial.
Last Updated: