My thoughts and ideas about software development in the Java and C++ realm
Thursday, February 4, 2010
Use ID on the extension element or as an attribute?
I wonder whats the best approach to give an extension a unique ID.
There are two ways to do that:
Use the ID already present on each extension element
Create an "id" attribute in a child-element of the extension
I am currently working on a "CopyTo" extension for the Eclipse Workbench, that allows to quickly copy Java classes or method bodies to your favorite pastebin site and puts the URL of the created entry into the clipboard. For some pastebin providers there is post-processing needed that one should be able to plug-in via extensions.
So I have the "eclipseutils.ui.copyto" Extension Point that should provide the following:
Allow to specify a response handler
Allow to describe parameter configurations, that the user can edit prior the request is sent
Should I have 2 EPs for that: "eclipseutils.ui.copyto.responseHandlers" and "eclipseutils.ui.copyto.paramInfos"? Or one "eclipseutils.ui.copyto.extensions" with sub-elements "responseHandlers" and "paramInfos"?
Each "CopyTo" is contributed via menuContribution that uses the "eclipseutils.ui.copyto" command. One of the command parameters is "id" which is used to look up extensions provided for that menuContribution. I guess the quickest way to fetch an extension for a specific "id" is to ask the IExtensionRegistry for an IExtension with a specific ID. That would mean you have to set the ID on the extension itself. Otherwise I would have to query all IConfigurationElements and parse it for the "id" attribute.
How you design your extensions also depends if others should be able to contribute to them later. The product splashscreen is a good example of late bindings. You describe the splashscreen somewhere and later reference it in a binding with a specific product.