Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Programmatically finding references to extension points in the workspace
Programmatically finding references to extension points in the workspace [message #329362] Sat, 21 June 2008 02:03 Go to next message
Michael Barkhouse is currently offline Michael BarkhouseFriend
Messages: 8
Registered: July 2009
Junior Member
I've defined an extension point and it is in a plug-in that's deployed in
my product. The schema defines one primary element which has an id.
Clients will create plug-in projects in their workspace that use the
extension point. I would like to find all usages of my extension point
programmatically and extract the ids from the primary elements. For
example, let's say the user has created ten projects and each project uses
my extension point. I'd like to provide a button that when pressed causes
a dialog to open that contains a list and that list has the ids from the
primary elements of all ten uses of the extension point.

If these plug-ins created by the user were actually deployed (or if a
runtime workbench was started) it would be easy.

Thanks in advance.
Re: Programmatically finding references to extension points in the workspace [message #329363 is a reply to message #329362] Sat, 21 June 2008 04:13 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
http://www.eclipsezone.com/eclipse/forums/t97608.rhtml

--

- Prakash

www.eclipse-tips.com


Michael Barkhouse wrote:
> I've defined an extension point and it is in a plug-in that's deployed
> in my product. The schema defines one primary element which has an id.
> Clients will create plug-in projects in their workspace that use the
> extension point. I would like to find all usages of my extension point
> programmatically and extract the ids from the primary elements. For
> example, let's say the user has created ten projects and each project
> uses my extension point. I'd like to provide a button that when pressed
> causes a dialog to open that contains a list and that list has the ids
> from the primary elements of all ten uses of the extension point.
>
> If these plug-ins created by the user were actually deployed (or if a
> runtime workbench was started) it would be easy.
>
> Thanks in advance.
>
Re: Programmatically finding references to extension points in the workspace [message #329422 is a reply to message #329363] Mon, 23 June 2008 17:35 Go to previous messageGo to next message
Michael Barkhouse is currently offline Michael BarkhouseFriend
Messages: 8
Registered: July 2009
Junior Member
Prakash G.R. wrote:

> http://www.eclipsezone.com/eclipse/forums/t97608.rhtml

Thanks for the reply.

This only works for the deployed plug-ins. I need a list that has both the
deloyed plug-ins and those from the workspace. Getting the plug-ins from
the workspace is the tricky part because they aren't in the registry yet
(I think).

Mike
Re: Programmatically finding references to extension points in the workspace [message #329424 is a reply to message #329362] Mon, 23 June 2008 17:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you are working in a PDE environment (i.e. you want to look at what
users are working on in the workspace) you can always start with
org.eclipse.pde.core.plugin.PluginRegistry. In 3.4 work was done to
back the PDE extension registry model with an IExtensionRegistry (which
can also be used, with some hand waving).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Programmatically finding references to extension points in the workspace [message #329470 is a reply to message #329424] Wed, 25 June 2008 14:03 Go to previous messageGo to next message
Michael Barkhouse is currently offline Michael BarkhouseFriend
Messages: 8
Registered: July 2009
Junior Member
Paul Webster wrote:

> If you are working in a PDE environment (i.e. you want to look at what
> users are working on in the workspace) you can always start with
> org.eclipse.pde.core.plugin.PluginRegistry. In 3.4 work was done to
> back the PDE extension registry model with an IExtensionRegistry (which
> can also be used, with some hand waving).

> PW

I was able to make some progress, but have come to a road block that I'm
not sure how to get around. PluginRegistry seems to be the only way to
access plug-ins in the workspace. I tried looking at examples of
IExtensionRegistry but only saw scenarios where the plug-ins from the
target were used.

I made an incorrect statement in my original post about how my extension
point is structured. It has one top level element and that element
contains multiple elements of another type. It's those child elements that
I need to access and extract attribute data from.

Here's what I've got so far:

IPluginModelBase[] workspacePlugins = PluginRegistry.getWorkspaceModels();

for (int i = 0; i < workspacePlugins.length; i++) {
IPluginExtension[] extensions =
workspacePlugins[i].getExtensions().getExtensions();

for (int j = 0; j < extensions.length; j++) {
IPluginExtension extension = extensions[j];

if ("myExtensionPointId".equals(extension.getPoint())) {
IPluginObject[] children = extension.getChildren();

for (int x = 0; x < children.length; x++) {
IPluginObject child = children[x];

if ("myTopElementName".equals(child.getName())) {
// Get children and extract attribute data.
}
}
}
}
}

The problem I have now is once I have the "top level element" I don't see
a way to access the elements it contains. There is no getChildren() method
on IPluginObject. Using the debugger, I see there is a field called
fChildren, but it is null.

Can anyone help me figure out this last step? Or suggest another approach?

Thanks.

Mike
Re: Programmatically finding references to extension points in the workspace [message #329475 is a reply to message #329470] Wed, 25 June 2008 15:00 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Michael Barkhouse wrote:
>
> Here's what I've got so far:
>
> IPluginModelBase[] workspacePlugins = PluginRegistry.getWorkspaceModels();
>
> for (int i = 0; i < workspacePlugins.length; i++) {
> IPluginExtension[] extensions =
> workspacePlugins[i].getExtensions().getExtensions();
>
> for (int j = 0; j < extensions.length; j++) {
> IPluginExtension extension = extensions[j];
>
> if ("myExtensionPointId".equals(extension.getPoint())) {
> IPluginObject[] children = extension.getChildren();
>
> for (int x = 0; x < children.length; x++) {
> IPluginObject child = children[x];
>
> if ("myTopElementName".equals(child.getName())) {
> // Get children and extract attribute data.
> }
> }
> }
> }
> }
>
> The problem I have now is once I have the "top level element" I don't
> see a way to access the elements it contains. There is no getChildren()
> method on IPluginObject. Using the debugger, I see there is a field
> called fChildren, but it is null.

If they are plugin elements, that IPlugObject should be an
IPluginElement. I was basically able to add code to your inner if:

if (child instanceof IPluginElement) {
System.out.println(((IPluginElement) child)
.getAttribute("id").getValue());
}

Later,
PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Programmatically invoking a cheat sheet
Next Topic:Window Preferences General WebBrowser Use external web browser Parameters ignored?
Goto Forum:
  


Current Time: Sun Dec 22 06:33:01 GMT 2024

Powered by FUDForum. Page generated in 0.03251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top