The plug-in class

So far, we've been looking at the different extensions that are provided by the contributions plug-in. Let's look at the general definition of the contributions plug-in.

Plug-in definition

The readme tool plug-in is defined in the MANIFEST.MF file.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %contributions.Activator.name
Bundle-SymbolicName: org.eclipse.ui.examples.contributions; singleton:=true
Bundle-Version: 3.3.100.qualifier
Bundle-Activator: org.eclipse.ui.examples.contributions.Activator
Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
 org.eclipse.core.runtime,
 org.eclipse.core.expressions;bundle-version="[3.3.0,4.0.0)"
Bundle-Vendor: %contributions.Activator.providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-ActivationPolicy: lazy

The plug-in definition includes the Bundle-Name, Bundle-SymbolicName (plug-in id), Bundle-Version, and Bundle-Vendor of the plug-in. We saw most of these parameters before in our hello world plug-in. The contribution plug-in also defines a specialized plug-in class, org.eclipse.ui.examples.contributions.Activator.

The Require-Bundle element informs the platform of the contribution plug-in's dependencies. The workbench UI plug-ins are listed as required plug-ins, along with the various core and expression plug-ins.

AbstractUIPlugin

The Activator class represents the contribution plug-in and manages the life cycle of the plug-in.  As we saw in the Hello World example, you don't have to specify a plug-in class.  The platform will provide one for you.  In this case, our plug-in needs to initialize UI related data when it starts up.  The platform class AbstractUIPlugin provides a structure for managing UI resources and is extended by Activator.

AbstractUIPlugin uses the generic startup and shutdown methods to manage images, dialog settings, and a preference store during the lifetime of the plug-in.