Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to find a plugin's install directory now that getDescriptor is deprecated?
How to find a plugin's install directory now that getDescriptor is deprecated? [message #252977] Wed, 16 June 2004 06:53 Go to next message
Eclipse UserFriend
Originally posted by: paul.wells.modelistic.com

Hi,

I'm porting a plugin from Eclipse 2.1.3 to Eclipse Platform Version: 3.0.0
Build id: 200405211200, wading through the now deprecated method calls.

I'm having difficulty with this one:

MyPlugin.getInstance().getDescriptor().getInstallURL()

- getDescriptor() is now deprecated, but there's no alternative route
suggested by the documentation.

The reason I need the install URL is because there are other configuration
files shipped with the plugin which need to be read. These files all sit
in a directory (standardProfiles) off the plugin's install directory, and
a loaded after doing a directory listing.

Using some code adapted from AbstractUIPlugin.imageDescriptorFromPlugin:

Bundle bundle = Platform.getBundle(PLUGIN_ID);
if (!BundleUtility.isReady(bundle))
return null;
URL fullPathString = BundleUtility.find(bundle, "standardProfiles");
if (fullPathString == null)
return null;

... I always find that the URL is "/standardProfiles" which is no help.

What's the proper way to locate a directory off the plugin's install
directory?
Re: How to find a plugin's install directory now that getDescriptor is deprecated? [message #252999 is a reply to message #252977] Wed, 16 June 2004 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gariazzo.prosilog.com

Paul Wells wrote:
> Hi,
>
> I'm porting a plugin from Eclipse 2.1.3 to Eclipse Platform Version: 3.0.0
> Build id: 200405211200, wading through the now deprecated method calls.
>
> I'm having difficulty with this one:
>
> MyPlugin.getInstance().getDescriptor().getInstallURL()
>
> - getDescriptor() is now deprecated, but there's no alternative route
> suggested by the documentation.
>
> The reason I need the install URL is because there are other configuration
> files shipped with the plugin which need to be read. These files all sit
> in a directory (standardProfiles) off the plugin's install directory, and
> a loaded after doing a directory listing.
>
> Using some code adapted from AbstractUIPlugin.imageDescriptorFromPlugin:
>
> Bundle bundle = Platform.getBundle(PLUGIN_ID);
> if (!BundleUtility.isReady(bundle))
> return null;
> URL fullPathString = BundleUtility.find(bundle, "standardProfiles");
> if (fullPathString == null)
> return null;
>
> .. I always find that the URL is "/standardProfiles" which is no help.
>
> What's the proper way to locate a directory off the plugin's install
> directory?
>

Have a look at Platform.asLocalURL to get a full path to the directory.
All Bundle related functions give pathes relative to the platform or the
plugin itself.
Re: How to find a plugin's install directory now that getDescriptor is deprecate [message #253013 is a reply to message #252977] Wed, 16 June 2004 08:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pieter.west.NOSPAM.nl

Paul Wells wrote:
> What's the proper way to locate a directory off the plugin's install
> directory?
>
This is how I do it:
final URL url = Platform.find(Platform.getBundle(YourPlugin.PLUGIN_ID),new
Path("/"));
Re: How to find a plugin's install directory now that getDescriptor is deprecated? [message #253190 is a reply to message #252999] Wed, 16 June 2004 14:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

Please do not use asLocalURL unless you really need it. It will make a
local physical copy of the file if it is not a local file.

>>
>> Bundle bundle = Platform.getBundle(PLUGIN_ID);
>> if (!BundleUtility.isReady(bundle))
>> return null;
>> URL fullPathString = BundleUtility.find(bundle, "standardProfiles");
>> if (fullPathString == null)
>> return null;
>>
>> .. I always find that the URL is "/standardProfiles" which is no help.
>>

The best way to find it is to use Platform.find(bundle, new

Path("standardProfiles")).

That way it will look in fragments too.

This will return a strange looking url that has a protocol of bundle:,
but this is ok. This url will work if you intend to use it as a url.

The better way to get your configuration files is to use

Platform.find(bundle, new Path("standardProfiles/yourconfigfile"))

for each config file, and that way you will get a URL directly to the
config file itself. Then to get the contents of the config file you
would simply do openStream() against the URL. That way it will work no
matter where the file is. (You see in the future files in the plugins
may actually be on another system, or the entire plugin may be zipped up
into a jar, the bundle: protocol handles this).


--
Thanks, Rich Kulp

Re: How to find a plugin's install directory now that getDescriptor is deprecate [message #253241 is a reply to message #252999] Wed, 16 June 2004 16:15 Go to previous message
Eclipse UserFriend
Originally posted by: paul.wells.modelistic.com

Guillaume Gariazzo wrote:

> Paul Wells wrote:
> > Hi,
> >
> > I'm porting a plugin from Eclipse 2.1.3 to Eclipse Platform Version: 3.0.0
> > Build id: 200405211200, wading through the now deprecated method calls.
> >
> > I'm having difficulty with this one:
> >
> > MyPlugin.getInstance().getDescriptor().getInstallURL()
> >

> Have a look at Platform.asLocalURL to get a full path to the directory.
> All Bundle related functions give pathes relative to the platform or the
> plugin itself.

Guillaume,

That works. Thanks for your help.

Paul
Previous Topic:Syntax highlighting / Code Completion in JSPs (3.0 RC2)
Next Topic:Key Binding for Run As > Application
Goto Forum:
  


Current Time: Sat Apr 20 02:54:00 GMT 2024

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

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

Back to the top