Obtain list of ALL nature ids [message #250209] |
Mon, 07 June 2004 18:50 |
Eclipse User |
|
|
|
Originally posted by: karypid.inf.uth.nospam.gr
Hi,
How can I obtain a list of all natures registered with the platform? (i.e.
all hooks to the org.eclipse.core.resources.natures extension point). I
need a list of all of them regardless of whether they are in use by a
project or not...
Thanks!
--
Alexandros Karypidis
|
|
|
Re: Obtain list of ALL nature ids [message #250912 is a reply to message #250209] |
Wed, 09 June 2004 13:19 |
Eclipse User |
|
|
|
Originally posted by: jmitch.ca.NOSPAM.ibm.com
Alexandros Karypidis wrote:
> Hi,
>
> How can I obtain a list of all natures registered with the platform? (i.e.
> all hooks to the org.eclipse.core.resources.natures extension point). I
> need a list of all of them regardless of whether they are in use by a
> project or not...
>
> Thanks!
You can use the Plug-in registry APIs to find plug-ins which contribute
to a certain extension point.
// ID for the extension point of interest
String theExtensionPoint = "org.eclipse.core.resources.natures";
// get access to plug-in registry
IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
// get the extension-point that we're interested in
// so we can find the extensions to it
IExtensionPoint point =
pluginRegistry.getExtensionPoint(theExtensionPoint);
// find all extensions to the extension-point
IExtension[] extensions = point.getExtensions();
// loop through the extensions
for (int i = 0; i < extensions.length; i++)
{
IExtension currentExtension = extensions[i];
// output each extension
System.out.println(currentExtension.getUniqueIdentifier());
}
--
Jeff Mitchell
WebSphere Training and Technical Enablement
|
|
|
Re: Obtain list of ALL nature ids [message #251075 is a reply to message #250912] |
Wed, 09 June 2004 16:08 |
Eclipse User |
|
|
|
Originally posted by: karypid.inf.uth.nospam.gr
Indeed. I had managed to dig it up in the API and have actually created my
first plugin (ooh, the pride of it! :-)) which provides a view with the
following:
- It is a view which shows a tree of all open projects.
- Each project has a list of nature ids registered with it as children.
- You may remove natures from a project using an action in the view.
- You may add a nature to a project by selecting from a list of natures.
Of course, selecting natures which are incompatible will fail, etc.
Is this a really bad idea? I was surprised there wasn't such a thing already
in Eclipse (or is there? argh!). I wrote it because I am writing my own
nature which adds my own builder that processes some files written in a
custom language. It's a convenient way to enable / disable the builder. If
someone finds it useful, I can send you my totally inappropriate newbie
code... :-P
Jeff Mitchell wrote:
> Alexandros Karypidis wrote:
>> How can I obtain a list of all natures registered with the platform?
>> ...
> You can use the Plug-in registry APIs to find plug-ins which contribute
> to a certain extension point.
> ...
--
Alexandros Karypidis
|
|
|
Powered by
FUDForum. Page generated in 0.02942 seconds