Plug-in Development 101: The Fundamentals

In the beginning, there was creation

The first part of the plug-in development workflow involves creating a plug-in project. In Eclipse, this is easily done by selecting the New >Project... menu option. In the wizard presented, select Plug-in Project as the type of project you want to create.

Figure 2: New Plug-in Project WizardFigure 2: New Plug-in Project Wizard

Just like any other Eclipse project, the wizard asks you to choose a project name. I suggest helloworld. There is also an option to choose a target platform. A target platform in this context simply means whether you will target a version of Eclipse or an OSGi framework like Equinox. In this case, we'll target the 3.3 version of Eclipse to keep things straightforward. The next page of the New Plug-in Project wizard focuses on plug-in content.

Figure 3: Plug-in ContentFigure 3: Plug-in Content

On the plug-in content wizard page, we must complete a form to make our plug-in compliant with Eclipse. The plug-in identifier is a field that represents a unique identifier for your plug-in. No other plug-in can share the same identifier. The plug-in version is composed of four segments (thee integers and a string) respectively named major.minor.service.qualifier (see Resources for the Eclipse Plug-in Versioning guide). The plug-in name simply represents a human-readable name. The plug-in provider field is a human-readable string signifying the author of the plug-in. In simple terms, the execution environment (EE) field represents what minimum JRE your bundle is capable of running on (see Resources).

The wizard gives us an option to generate a plug-in activator. A plug-in activator is simply a class that controls the life cycle of your plug-in (think of it as a start-and-stop method). Customarily, the activator is responsible for setting up things and properly disposing of resources when your plug-in isn't needed anymore. In this case, we desire an activator, a plug-in that makes contributions to the UI, and we're creating a Rich Client Platform (RCP) application (see Resources).

The final step in plug-in creation involves selecting a template (see Figure 4) to base your new plug-in on. When you get more advanced in the creation of plug-ins, this step is usually skipped. However, beginners need to start somewhere, and the Eclipse SDK ships many templates to help you get started. In this case, we select the basic Hello World with a view application.

Figure 4: Plug-in TemplatesFigure 4: Plug-in Templates

Article Type: 
How-to
0
Average: 2.4 (9 votes)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)