Friday, December 4, 2015

Eclipse Plugin Tutorial: Eclipse 3.x Plugin Development for Beginners


This tutorial is based on Eclipse Mars and Java 1.7.

Before I became an Eclipse Plugin developer, I used to wonder if it is possible to extend the Eclipse IDE to add an MP3 player so I can easily switch music without leaving the IDE. It turned out that it is possible because the Eclipse IDE is made out of several reusable software components called plugins. This means that you can write your own plugin to contribute a new functionality to the Eclipse IDE (like an MP3 player, pretty cool huh?).

For this tutorial, I will show you how to create a basic “Hello World” plugin using Eclipse 3.x framework which is the traditional way of creating Eclipse plugins. With the release of Eclipse version 4.x (E4), you can already create plugins based on a model and it also supports dependency injection and CSS styling. I will write a separate tutorial for E4 plugin development. So, let’s start!


Tutorial Outline:

Prerequisites
Create Hello World Plugin
Run the plugin

Prerequisites

You need to install Eclipse for RCP and RAP Developers.

Create Hello World Plugin

Create a new plugin by selecting File -> New -> Plug-in Project

In the New Plug-in Project dialog, specify the project (plugin) name and click Next

New Plugin Project Dialog


Accept the default values and click Next


Specify plugin project properties

Select the Hello World Command template and click Next


Select Hello World plugin template

Accept the default values and click Finish


Sample command properties

The plugin configuration editor is automatically opened. This is the file that you will normally edit to configure your plugin (e.g. add a new menu or toolbar item). If it is not yet opened, you can open it by double-clicking either the plugin.xml or the MANIFEST.MF file.


Plugin configuration editor

Run the plugin

There are two ways to run your plugin:

  1. In the Overview tab of the plugin configuration editor, click the Launch an Eclipse Application link.
  2. Right-click on the plugin project, select Run As -> Eclipse Application.
Both of these options will launch a separate Eclipse application with your plugin in it.

The new menu and toolbar items are already part of the Eclipse application. Clicking the sample menu and toolbar items will show the Hello World message dialog.

Hello World Plugin

On next tutorial, I will show you how to manually add new menu and toolbar items to an Eclipse 3.x plugin.

No comments:

Post a Comment