Difference between revisions of "FAQ How do I declare my own extension point?"
|Line 103:||Line 103:|
Revision as of 16:13, 14 March 2006
Declaring an extension point is arguably one of the more difficult and less documented and supported tasks in Eclipse. Most plug-in writers simply copy an extension point schema from others to get an approximation of what they need.
Adding an extension point can be done with some PDE support by following these steps.
- Edit your plugin.xml using the Manifest Editor. Select the
Extension Points tab, and click Add.... </li>
- Now stop for a minute. Think up a good name and an equally
descriptive ID for your extension point. Dont choose too lightly. These two names are part of your plug-in API. The ID is one word without dots; your plug-in ID will be prepended to it. When in doubt, press F1 to get help. </li>
- Choose a name for your schema. This file name is private to you,
so you can choose any name you like. Check the box to edit the schema. Click Finish to launch the PDE Schema Editor to edit the schema. </li>
- Click New Element; in the properties view,
change the name to the extension element you want your clients to fill in. </li>
- Add a new attribute to this element, and call it id. Change
the value of Use to Required. In the Properties view, click the Clone this attribute button in the local toolbar. </li>
- Rename the clone to name. Clone it.
- Rename the second clone to class. Change the kind
to java. </li>
- Choose the interface your contributors need to implement
or the class they need to subclass. Note that it is generally better to provide a superclass, as this allows you greater flexibility in extending the API in the future without breaking existing implementations. Choose a descriptive name that captures the meaning of the collaboration between you and your contributors. </li>
- In the Based On property, enter the name of the interface/class
to create an executable extension from.
Thats it. You now have defined a new extension that others can contribute to. Look around in the editor and add descriptions, documentation, and example code where appropriate.
If you want to customize the extension with more attributes, read Help > Help Contents... > PDE Guide > Extension Point Schema > Extension point schema editor.
This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.