Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to get an IEditableModel for a plugin in the workspace?
How to get an IEditableModel for a plugin in the workspace? [message #291035] Tue, 06 September 2005 15:40 Go to next message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Hi all,

I've inherited some PDE-related code that used to work in 3.0, but no longer
works in 3.1.

Basically, it programmatically adds extensions to a given project in the
workspace, triggered by user actions.

The key bit of code that no longer works is:

PluginModelManager pmm = PDECore.getDefault().getModelManager();
IPluginModelBase[] plugins = pmm.getAllPlugins();

The plugin models were then used to create new extensions in the user's
workspace.

This code now has two problems in 3.1:

- getAllPlugins() actually returns models for the set of *installed* plugins,
*minus* the workspace plugins.

- The models returned are IPluginModel's (really BundlePluginModel's), which
don't do IEditableModel, and hence do not support the save() method. They
provide save(PrintWriter), but I suspect that might interfere with caching,
notifications, or other stuff going on under the hood.

I surmise that the PluginModelManager was not the right fellow to talk to, but
that a WorkspaceModelManager would be more friendly to my cause (in part since
WorkspacePluginModel implements IEditableModel).

Unfortunately, WorkspaceModelManager provides no way to get at anything other
than IFeatureModel's, which won't help, unless the plugin I want to manipulate
happens to live inside a feature.

I know I'm treading on internal stuff here, so if there's API I should be
using instead, please point me at it!

Thanks...

--
Robert M. Fuhrer rfuhrer@watson.ibm.com
IBM T.J. Watson Research Center PGP public key available on request
Re: How to get an IEditableModel for a plugin in the workspace? [message #291042 is a reply to message #291035] Tue, 06 September 2005 16:57 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Robert M. Fuhrer wrote:
> [... snip ...]
> This code now has two problems in 3.1:
>
> - getAllPlugins() actually returns models for the set of *installed* plugins,
> *minus* the workspace plugins.
>
> - The models returned are IPluginModel's (really BundlePluginModel's), which
> don't do IEditableModel, and hence do not support the save() method. They
> provide save(PrintWriter), but I suspect that might interfere with caching,
> notifications, or other stuff going on under the hood.
>

So I'm not familiar with the PDE code, but as a workaround for the
second issue you can use a StringWriter to get your changes in memory,
and then use IFile#setContents(...) to set the contents and replace them
within eclipse's notification mechanism.

Later,
PW


Re: How to get an IEditableModel for a plugin in the workspace? [message #291044 is a reply to message #291042] Tue, 06 September 2005 17:44 Go to previous message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
Sure, that would work, assuming that the caching mechanisms are registered
as listeners on the underlying resources, but the problem is that I don't
know whether that's the case... nor whether I should rely on that continuing
to be the case in the future...

In article <dfkhqg$ja0$1@news.eclipse.org>, pwebster@ca.ibm.com says...
> Robert M. Fuhrer wrote:
> > [... snip ...]
> > This code now has two problems in 3.1:
> >
> > - getAllPlugins() actually returns models for the set of *installed* plugins,
> > *minus* the workspace plugins.
> >
> > - The models returned are IPluginModel's (really BundlePluginModel's), which
> > don't do IEditableModel, and hence do not support the save() method. They
> > provide save(PrintWriter), but I suspect that might interfere with caching,
> > notifications, or other stuff going on under the hood.
> >
>
> So I'm not familiar with the PDE code, but as a workaround for the
> second issue you can use a StringWriter to get your changes in memory,
> and then use IFile#setContents(...) to set the contents and replace them
> within eclipse's notification mechanism.

--
Robert M. Fuhrer rfuhrer@watson.ibm.com
IBM T.J. Watson Research Center PGP public key available on request
Previous Topic:XSLT & ANT
Next Topic:Getting jface ApplicationWindow menu and status bar height
Goto Forum:
  


Current Time: Fri Apr 26 05:21:42 GMT 2024

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

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

Back to the top