Using extension point schema
Extension points defined by the plug-ins in your workspace are readily available
to your own plug-in and other plug-ins. If an extension point schema has been
defined for it, PDE can provide assistance when creating new extensions.
This assistance includes:
- Providing choices for the New pop-up menu so that only valid child elements
are added
- Providing attribute information for the property sheet so that only valid
attributes are set
- Providing correct attribute property editors that match the attribute types (boolean,
string, and enumeration).
- Providing additional support for special attribute types ("java"
and "resource").
- Using the status line to show the first sentence of the documentation
snippet for attributes when selected in the property sheet.
Example: Using the "Sample Parsers" extension point
Before trying to use the extension point we defined before, we still need to
define the expected interface. Select the com.example.xyz project in the Navigator
and press the "Create a Java interface" tool bar button. Be sure
to set the package name to com.example.xyz and interface name to
IParser before pressing Finish. Edit the interface to look like this:
package com.example.xyz;
public interface IParser {
/**
* Run the parser using the provided mode
*/
public void parse(int mode);
}
We now have the extension point, an XML schema for it, and the required
interface. Be sure to save all of your open editors. Everything is now
ready for our own plug-in or other plug-ins to
contribute to the extension point.
- Open the manifest editor for the com.example.xyz plug-in.
- Switch to the Extensions page and press New->Schema-based Extensions.
- You should have "Sample Parsers" available as a choice. Select
it and press Finish.
- Select the newly added "Sample Parsers" element and popup the New->parser
menu. (We specified that our extension point can accommodate any
number of "parser" elements.)
- Select the new element and go to the Properties view. It should show four
attributes: id, name, class and mode. Note how the status line shows the
short information about attributes as you select them. This information
comes directly from the extension point schema.
- Change the name to "Default Parser". Change the mode to
"manual."
- Select the class attribute. This property cannot be edited
directly. Open the properties dialog.
- Choose to create a new class. Select "XYZ Plugin" as the source
folder, com.example.xyz as the package and DefaultParser as the class name.
Press Finish.
- You should now be in the Java editor for the DefaultParser class. Notice
how it has implemented the right interface (IParser) and already has the stub
implementation of the "parse" method.
As you can see, when you provide a complete XML schema for your extension
point, it will help all your potential users by letting PDE to assist them and
prevent them from making errors.
