Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How tro obtain the absolute install path of a plugin?
How tro obtain the absolute install path of a plugin? [message #253886] Fri, 18 June 2004 13:52 Go to next message
Eclipse UserFriend
Originally posted by: fabien.mairesse.barco.com

Hello,

I can't obtain the absolute install path of my plugin. I didn't find any
suitable methods in class Platform. I've tried
IPLuginDescriptor::getInstallURL() but the returned URL is :
"/plugin/my_plugin_directory/" (I don't understand this URL because my
plugins are stored in the "plugins/" directory of the platform and the URL
contains "plugin/" (without 's'). So this URL is even not the relative
path of my plugin in the platform?)
What I want to do is accessing directly to a resource stored in my plugin
directory.


thanks in advance
Fabien
Re: How tro obtain the absolute install path of a plugin? [message #253894 is a reply to message #253886] Fri, 18 June 2004 14:07 Go to previous messageGo to next message
Philipp Bouillon is currently offline Philipp BouillonFriend
Messages: 46
Registered: July 2009
Member
Hi,

there is a method in Platform called "resolve" which resolved the URL
retrieved by getInstallURL. A call to ".getFile()" of the retrieved URL
gives you the absolute path on your system---like this:

String resolvedPath = Platform.resolve(<URL retrieved by
PluginDescriptor.getInstallURL()>).getFile();

Note however, that PluginDescriptor is deprecated in 3.0. I am not too
sure about it, but I _think_ the correct way to determine the installation
path of a plug-in in 3.0 is:

private String getResolvedPath(String pluginID) {
Bundle bundle = Platform.getBundle(pluginID);
if (bundle != null) {
URL bundleURL = bundle.getResource("/");
if (bundleURL != null) {
String resolvedPath;
try {
resolvedPath = Platform.resolve(bundleURL).getFile();
return resolvedPath;
} catch (IOException e) {
}
}
}
return null;
}

where "pluginID" is the id of your plug-in as defined in plugin.xml.

Hope that helps,
Philipp

> Hello,

> I can't obtain the absolute install path of my plugin. I didn't find any
> suitable methods in class Platform. I've tried
> IPLuginDescriptor::getInstallURL() but the returned URL is :
> "/plugin/my_plugin_directory/" (I don't understand this URL because my
> plugins are stored in the "plugins/" directory of the platform and the URL
> contains "plugin/" (without 's'). So this URL is even not the relative
> path of my plugin in the platform?)
> What I want to do is accessing directly to a resource stored in my plugin
> directory.


> thanks in advance
> Fabien
Re: How tro obtain the absolute install path of a plugin? [message #253906 is a reply to message #253894] Fri, 18 June 2004 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

But be aware you may not always get a file url. It is possible,
depending on how things are installed, that you could get a URL pointing
into a jar, or even a url that exists on another system.

However, the default is currently a local file. Most installations don't
have the plugins zipped into a jar nor do they install remote.

--
Thanks, Rich Kulp

Re: How tro obtain the absolute install path of a plugin? [message #253931 is a reply to message #253894] Fri, 18 June 2004 15:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paull.NOSPAMcodetelligence.com

I use
getBundle().getEntry("/")

Paul
www.codetelligence.com
"Philipp Bouillon" <Philipp.Bouillon@t-online.de> wrote in message
news:causvq$amt$1@eclipse.org...
> Hi,
>
> there is a method in Platform called "resolve" which resolved the URL
> retrieved by getInstallURL. A call to ".getFile()" of the retrieved URL
> gives you the absolute path on your system---like this:
>
> String resolvedPath = Platform.resolve(<URL retrieved by
> PluginDescriptor.getInstallURL()>).getFile();
>
> Note however, that PluginDescriptor is deprecated in 3.0. I am not too
> sure about it, but I _think_ the correct way to determine the installation
> path of a plug-in in 3.0 is:
>
> private String getResolvedPath(String pluginID) {
> Bundle bundle = Platform.getBundle(pluginID);
> if (bundle != null) {
> URL bundleURL = bundle.getResource("/");
> if (bundleURL != null) {
> String resolvedPath;
> try {
> resolvedPath = Platform.resolve(bundleURL).getFile();
> return resolvedPath;
> } catch (IOException e) {
> }
> }
> }
> return null;
> }
>
> where "pluginID" is the id of your plug-in as defined in plugin.xml.
>
> Hope that helps,
> Philipp
>
> > Hello,
>
> > I can't obtain the absolute install path of my plugin. I didn't find any
> > suitable methods in class Platform. I've tried
> > IPLuginDescriptor::getInstallURL() but the returned URL is :
> > "/plugin/my_plugin_directory/" (I don't understand this URL because my
> > plugins are stored in the "plugins/" directory of the platform and the
URL
> > contains "plugin/" (without 's'). So this URL is even not the relative
> > path of my plugin in the platform?)
> > What I want to do is accessing directly to a resource stored in my
plugin
> > directory.
>
>
> > thanks in advance
> > Fabien
>
>
thank you! [message #253935 is a reply to message #253894] Fri, 18 June 2004 15:23 Go to previous message
Eclipse UserFriend
Originally posted by: fabien.mairesse.barco.com

it works!! Thank you very much Philipp.



Philipp Bouillon wrote:

> Hi,

> there is a method in Platform called "resolve" which resolved the URL
> retrieved by getInstallURL. A call to ".getFile()" of the retrieved URL
> gives you the absolute path on your system---like this:

> String resolvedPath = Platform.resolve(<URL retrieved by
> PluginDescriptor.getInstallURL()>).getFile();

> Note however, that PluginDescriptor is deprecated in 3.0. I am not too
> sure about it, but I _think_ the correct way to determine the installation
> path of a plug-in in 3.0 is:

> private String getResolvedPath(String pluginID) {
> Bundle bundle = Platform.getBundle(pluginID);
> if (bundle != null) {
> URL bundleURL = bundle.getResource("/");
> if (bundleURL != null) {
> String resolvedPath;
> try {
> resolvedPath = Platform.resolve(bundleURL).getFile();
> return resolvedPath;
> } catch (IOException e) {
> }
> }
> }
> return null;
> }

> where "pluginID" is the id of your plug-in as defined in plugin.xml.

> Hope that helps,
> Philipp

> > Hello,

> > I can't obtain the absolute install path of my plugin. I didn't find any
> > suitable methods in class Platform. I've tried
> > IPLuginDescriptor::getInstallURL() but the returned URL is :
> > "/plugin/my_plugin_directory/" (I don't understand this URL because my
> > plugins are stored in the "plugins/" directory of the platform and the URL
> > contains "plugin/" (without 's'). So this URL is even not the relative
> > path of my plugin in the platform?)
> > What I want to do is accessing directly to a resource stored in my plugin
> > directory.


> > thanks in advance
> > Fabien
Previous Topic:PDE - Target Platform (out of sync)
Next Topic:subclassing CloseEditorAction
Goto Forum:
  


Current Time: Wed Jul 17 20:44:12 GMT 2024

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

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

Back to the top