Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Resource path in an extension
Resource path in an extension [message #308114] Wed, 13 September 2006 08:00 Go to next message
Eclipse UserFriend
Hi,

I'm writing a new extension point for my own purpose. In the .exsd file,
I've defined a icon attribute like that:
<attribute name="icon" type="string">
<annotation>
<documentation>

</documentation>
<appInfo>
<meta.attribute kind="resource"/>
</appInfo>
</annotation>
</attribute>

When i read the extenstions registry to get contributors of my extension i
can get the icon path with success:

IExtension[] extensions = extPoint.getExtensions();
for(int i = 0; i < extensions.length; i++ )
{
IExtension extension = extensions[i];
IConfigurationElement[] elements = extension.getConfigurationElements();
for(int j = 0 ; j < elements.length; j++)
{
IConfigurationElement element = elements[j];
String iconPath=element.getAttribute("icon");
}
}

My problem is that iconPath contains the path of the resource but it is
relative to the plugin path where is was defined (ex :
resources/icons/icon.gif)
How can i "translate" this path to an absolute path so i can use it from
anywhere, in a LabelProvider for an example.

Thanks,

Nico.
Re: Resource path in an extension [message #308118 is a reply to message #308114] Wed, 13 September 2006 08:46 Go to previous messageGo to next message
Eclipse UserFriend
You'll need to get the Bundle that contributed the extension, and then
you can use Bundle#getEntry(path)

Later,
PW
Re: Resource path in an extension [message #308133 is a reply to message #308118] Thu, 14 September 2006 03:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

In fact i didn't know how to make the relation between the
IConfigurationElement and the bundle.
Finally i Used
IConfigurationElement.getDeclaringExtension().getNamespaceId entifier() to
get the plugin identifier, then Bundle bdl = Platform.getBundle(id) to get
the correct bundle.

This makes me think of another thing which concerns translatable strings
in extension-points, you know those beginning with %. Is there a way to
have them automatically translated, or must i manually look in plugin
fragments for the correct plugin_$nl.properties file and then look for the
translation ?
Re: Resource path in an extension [message #308134 is a reply to message #308133] Thu, 14 September 2006 03:41 Go to previous messageGo to next message
Eclipse UserFriend
> This makes me think of another thing which concerns translatable strings
> in extension-points, you know those beginning with %. Is there a way to
> have them automatically translated, or must i manually look in plugin
> fragments for the correct plugin_$nl.properties file and then look for the
> translation ?

I should have tried if before asking the questions.... %strings are
automatically translated when reading IConfigurationElement.

Thanks again.
Re: Resource path in an extension [message #308153 is a reply to message #308134] Thu, 14 September 2006 11:21 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Also, you want getContributor() instead of getNamespaceName(). In
general they are the same, but namespace has been expanded to allow
extensions from several different plugins to be in the same "namespace".
While contributor is the plugin/fragment that had the actual extension
in it.

Nico wrote:
>> This makes me think of another thing which concerns translatable
>> strings in extension-points, you know those beginning with %. Is there
>> a way to have them automatically translated, or must i manually look
>> in plugin fragments for the correct plugin_$nl.properties file and
>> then look for the translation ?
>
>
> I should have tried if before asking the questions.... %strings are
> automatically translated when reading IConfigurationElement.
>
> Thanks again.
>
Previous Topic:CheckboxTreeViewer updating checkboxes problem
Next Topic:registering popmenu
Goto Forum:
  


Current Time: Fri May 09 02:16:35 EDT 2025

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

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

Back to the top