The Extensions page is used to browse and edit plug-in extensions. Extensions are the central mechanism for contributing behavior to the platform. Unless your plug-in is a simple Java API library made available to other plug-ins, new behavior is contributed as an extension.
Plug-ins contribute to the extension points defined by those plug-ins that they require. Your extension syntax must match the extension point definition in order to be processed correctly. The total list of eligible extension points is computed by PDE by traversing all the visible plug-ins (both workspace and external).
The generic extension wizard provided by PDE will simply scan the extension points. If an extension schema is provided (see Extension Point Schema), then the wizard will extract grammar and extension point meta data from the schema.
In addition to the generic wizard, a number of extension templates are available. These are the same templates that can be used to generate initial content of the plug-in project. Their presence here allows you to stage the extension creation. You can create a plug-in with a simple view, then add an editor or a wizard later.
To illustrate the operation of the Extensions page, we will add a 'Hello, PDE world' action to our plug-in. We will be contributing to the org.eclipse.ui.actionSets extension point. This example assumes you are already familiar with the extension point.
We will start by pressing the Add... button to select the extension wizard:
The Schema-based Extension wizard is the default since it handles extensions in the most generic ways. It will scan the plug-ins and offer all the extension points found, with or without schemas. Those with schemas will allow PDE to offer better assistance. If an extension point schema is missing, PDE will let you add elements and attributes to the extension, but it will not be able to verify if they are valid for the selected extension point.
When you press Next, a list of extension points will be offered. Select org.eclipse.ui.actionSets and press Finish.
The wizard will add the new extension to the list of extensions. Since this extension has a schema associated with it, we can further edit our extension definition. We select the newly added extension and choose New->actionSet from the popup menu. This XML element has been defined as the only valid element that can show up in the extension definition.
For all required attributes, PDE will create default values. We can change the default name of the action set to "Sample Action Set" by selecting the element and changing the label property in the Properties view. The new name will show up in the extension list.
We now need to define a menu and an action for the action set. If we select the action set and popup the menu in the "Extension Element Children" section, the "New" menu will offer two choices: menu and action. These choices are based on the schema information for the action sets extension. First, we create the menu.
We can create the action in a similar way:
The last thing we need to set is the action's Java class. The extension point definition specifies that an action must implement IWorkbenchWindowActionDelegate. PDE can offer assistance since it knows this information from the schema:
Before you press Finish, the dialog should look like this:
When you finish, the new class will be generated based on the required interface (with a stub implementation for each abstract method). In addition, the name of the new class will be set for the class property value. The wizard will also open the new Java class for editing by default. You can locate the "run" method and add the following statement:
System.out.println("Hello, PDE world!");
Save the new source code and close the Java editor. Then return to the Extensions page of the manifest editor and save.
We will continue with this example when we run the plug-in.