Home » Eclipse Projects » Plugin Development Environment (PDE) » Programmatically add an extension to a plug-in
Programmatically add an extension to a plug-in [message #509677] |
Sun, 24 January 2010 11:28  |
Eclipse User |
|
|
|
Hi,
I need to programmatically add an extension to a plug-in project. This is part of the code I am using:
IPluginModelBase model = PluginRegistry.findModel(project);
IPluginExtension extension = createExtension(model, info.getExtensionPointId(),true);
IPluginElement element = model.getPluginFactory().createElement(extension);
element.setName(info.getName());
The element.setName() call is throwing an exception because the model is not editable. How do I create an editable model or is there a better way to add an extension?
Thanks,
Steve
|
|
| | | | |
Re: Programmatically add an extension to a plug-in [message #510083 is a reply to message #510066] |
Tue, 26 January 2010 09:02   |
Eclipse User |
|
|
|
Great, thanks Steffen.
Steffen Zschaler wrote on Tue, 26 January 2010 07:55 | Hi,
That's what I've been doing in some project that generated plugin
projects. As long as you have the plugin manifest builder associated
with that plugin project, saving plugin.xml seems to lead to
recompilation and correct reconfiguration of the project's metadata.
Steffen
On 26/01/2010 09:09, Louis Rose wrote:
> Hi Steve,
>
> That'd be great, thanks. I'm tempted to simply generate a plugin.xml
> file, as we will always be generating a new project from scratch. If
> this would be helpful for you, I can share the code?
>
> Cheers,
> Louis.
|
|
|
| |
Re: Programmatically add an extension to a plug-in [message #510336 is a reply to message #510103] |
Wed, 27 January 2010 05:09   |
Eclipse User |
|
|
|
Hi Steve,
But you could parse the plugin.xml, extend the AST and print it back as
an XML file, couldn't you?
I'm assuming that we are talking about a project open in the workspace
here, rather than a plugin deployed into the system?
Steffen
On 26/01/2010 14:42, Steve wrote:
> Louis,
> Thanks, but my case is a bit different. I need to update an existing
> plug-in project. I am able to get the model and add the extension if
> it that extension does not already exist. But, if I try to add an
> element (IPluginElement) to an existing extension I get the read-only
> exception.
> Thanks,
> Steve
|
|
| |
Re: Programmatically add an extension to a plug-in [message #513535 is a reply to message #513206] |
Wed, 10 February 2010 09:14   |
Eclipse User |
|
|
|
I am adding some key bindings to an existing plug-in project in the workspace, not plug-ins deployed in the system. We have a Toolkit that enables a user to create plug-in projects. There are cases where you change something in your plug-in project and our Toolkit automatically updates yourplugin-in projects plugin.xml. I was able to get this working by using a WorkspacePluginModel. This model can be edited. But, when you create this model you do not get the extensions. I had to get the extensions using the model returned from a call to PluginRegistry.findModel(project). I then added all of those extensions to my WorkspacePluginModel model. Now, another gotcha was that if I tried to edit any extension returned by the call to PluginRegistry.findModel() I received a read-only exception. For any extension I needed to edit, I had to create a new extension, based on the original extension, and add that extension to my model. Because this is a new extension I was able to edit it. Finally, after making all of my changes, I saved my model. I tried using a straight XML approach, but ran in to some problems with that. This approach seems to work fine.
Thanks,
Steve
|
|
| | | |
Re: Programmatically add an extension to a plug-in [message #604383 is a reply to message #510066] |
Tue, 26 January 2010 09:02   |
Eclipse User |
|
|
|
Great, thanks Steffen.
Steffen Zschaler wrote on Tue, 26 January 2010 07:55
> Hi,
>
> That's what I've been doing in some project that generated plugin
> projects. As long as you have the plugin manifest builder associated
> with that plugin project, saving plugin.xml seems to lead to
> recompilation and correct reconfiguration of the project's metadata.
>
> Steffen
>
> On 26/01/2010 09:09, Louis Rose wrote:
> > Hi Steve,
> >
> > That'd be great, thanks. I'm tempted to simply generate a plugin.xml
> > file, as we will always be generating a new project from scratch. If
> > this would be helpful for you, I can share the code?
> >
> > Cheers,
> > Louis.
|
|
| |
Re: Programmatically add an extension to a plug-in [message #604403 is a reply to message #604387] |
Wed, 27 January 2010 05:09   |
Eclipse User |
|
|
|
Hi Steve,
But you could parse the plugin.xml, extend the AST and print it back as
an XML file, couldn't you?
I'm assuming that we are talking about a project open in the workspace
here, rather than a plugin deployed into the system?
Steffen
On 26/01/2010 14:42, Steve wrote:
> Louis,
> Thanks, but my case is a bit different. I need to update an existing
> plug-in project. I am able to get the model and add the extension if
> it that extension does not already exist. But, if I try to add an
> element (IPluginElement) to an existing extension I get the read-only
> exception.
> Thanks,
> Steve
|
|
| |
Re: Programmatically add an extension to a plug-in [message #604578 is a reply to message #604544] |
Wed, 10 February 2010 09:14  |
Eclipse User |
|
|
|
I am adding some key bindings to an existing plug-in project in the workspace, not plug-ins deployed in the system. We have a Toolkit that enables a user to create plug-in projects. There are cases where you change something in your plug-in project and our Toolkit automatically updates yourplugin-in projects plugin.xml. I was able to get this working by using a WorkspacePluginModel. This model can be edited. But, when you create this model you do not get the extensions. I had to get the extensions using the model returned from a call to PluginRegistry.findModel(project). I then added all of those extensions to my WorkspacePluginModel model. Now, another gotcha was that if I tried to edit any extension returned by the call to PluginRegistry.findModel() I received a read-only exception. For any extension I needed to edit, I had to create a new extension, based on the original extension, and add that extension to my model. Because this is a new extension I was able to edit it. Finally, after making all of my changes, I saved my model. I tried using a straight XML approach, but ran in to some problems with that. This approach seems to work fine.
Thanks,
Steve
|
|
|
Goto Forum:
Current Time: Mon Jul 14 05:49:34 EDT 2025
Powered by FUDForum. Page generated in 0.32054 seconds
|