Plug-in Development Environment (PDE) in Eclipse
|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|
1.1 There are three ways to create a Java 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.
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 build.properties and contains the details of the plug-in build. Below is a more detailed description of each tab.
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:
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.
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.
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.