Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » ResourceBundle located in another Plugin without Classes
ResourceBundle located in another Plugin without Classes [message #323812] Wed, 09 January 2008 05:56 Go to next message
Eclipse UserFriend
Hey

I got 2 Plugins here. One offering an extension point(Plugin A) and
another one just having an extension to that point and delivering some
files including a properties file(Plugin B). Plugin A uses a properties
file for its GUI Strings and i want to allow Plugin B to overwrite some of
those. therefore i need to fetch a The resourcebundle form Plugin B.
Fetching the other files is fairly simple but getting the resourcebundle
is giving me headaches since the only way i found to instantiate a
resourcebundle is via "Resourcebundle.getBundle()" which needs a
classloader supplied to load ResourceBundles form Plugins different to the
current one ( i could locate the properties file with somehting like
FileLocator.find(), but the resulting URL doesnt help me any further in
that case). The problem with that is that Plugin B doesnt have any classes
at the moment and will never have any ( at least not as it is planned to
be) so obtaining a classloader for that Plugin is somehow impossible?!.

Somebody got an idea how to proceed here?

Philipp
Re: ResourceBundle located in another Plugin without Classes [message #323822 is a reply to message #323812] Wed, 09 January 2008 10:16 Go to previous messageGo to next message
Eclipse UserFriend
You can use Platform.getBundle("id") or BundleContext#getBundles() to
bet the Bundle for plugin B, and then Bundle#getEntry(*) to get a URL.

From there you can use the URL or get an InputStream from it.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: ResourceBundle located in another Plugin without Classes [message #323827 is a reply to message #323822] Wed, 09 January 2008 11:01 Go to previous messageGo to next message
Eclipse UserFriend
I think you misunderstood what i want. I dont want to read the properties
file itself directly but get the Resourcebundle representing it so eclipse
takes care of the possible translations of it and offers the easy
Resourcebundle.getstring(key) acces to the values. If i went for using the
Url and an Inputstream i would first have to parse the file myself + take
care of the nl stuff which both are things i do not want to do when using
properties files.

greetings Philipp
Re: ResourceBundle located in another Plugin without Classes [message #323833 is a reply to message #323827] Wed, 09 January 2008 12:25 Go to previous messageGo to next message
Eclipse UserFriend
What about providing the extra resource in a fragment plugin (hosted off
of Plugin A)? That is how eclipse distributes different resource
bundles/language packs, by providing them in fragments off of the host
plugin.

That way you don't have to worry about finding their classloader,
they're available through the host plugin class loader.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: ResourceBundle located in another Plugin without Classes [message #323834 is a reply to message #323827] Wed, 09 January 2008 12:24 Go to previous messageGo to next message
Eclipse UserFriend
Okay sorry for beeing to dumb to read some APIs ... The class
PropertyResourceBundle kindly accepted the stream :). Thx for your time
anyways.

bye Philipp
Re: ResourceBundle located in another Plugin without Classes [message #323837 is a reply to message #323834] Wed, 09 January 2008 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Philipp,

But doesn't the question remain: how do you find the stream for the
correct properties file with respect to the local?


Philipp Simon wrote:
> Okay sorry for beeing to dumb to read some APIs ... The class
> PropertyResourceBundle kindly accepted the stream :). Thx for your
> time anyways.
>
> bye Philipp
>
Re: ResourceBundle located in another Plugin without Classes [message #323849 is a reply to message #323837] Thu, 10 January 2008 05:25 Go to previous messageGo to next message
Eclipse UserFriend
As far as we went in this thread yes but you can use the filelocator
class to find the correct one.

Bundle b = Platform.getBundle(inputObject.getContributor().getName());


URL rbUrl = FileLocator.find(b,
new Path("$nl$/propfiles/firstPropfile.properties")
,null);

PropertyResourceBundle prb = new
PropertyResourceBundle(rbUrl.openStream());

InputObject is an IConfigurationElement and the path is a plugin
relative one (meaning i got a plugin project and it contains a folder
propfiles) with the $nl$/ added to tell the fileLocator to look for
locale specific files.


Ed Merks wrote:
> Philipp,
>
> But doesn't the question remain: how do you find the stream for the
> correct properties file with respect to the local?
>
>
> Philipp Simon wrote:
>> Okay sorry for beeing to dumb to read some APIs ... The class
>> PropertyResourceBundle kindly accepted the stream :). Thx for your
>> time anyways.
>>
>> bye Philipp
>>
Re: ResourceBundle located in another Plugin without Classes [message #323852 is a reply to message #323849] Thu, 10 January 2008 07:05 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Philipp,

Cool. I didn't know about that. Thanks for sharing that tidbit.


Philipp Simon wrote:
> As far as we went in this thread yes but you can use the filelocator
> class to find the correct one.
>
> Bundle b = Platform.getBundle(inputObject.getContributor().getName());
>
>
> URL rbUrl = FileLocator.find(b,
> new Path("$nl$/propfiles/firstPropfile.properties")
> ,null);
>
> PropertyResourceBundle prb = new
> PropertyResourceBundle(rbUrl.openStream());
>
> InputObject is an IConfigurationElement and the path is a plugin
> relative one (meaning i got a plugin project and it contains a folder
> propfiles) with the $nl$/ added to tell the fileLocator to look for
> locale specific files.
>
>
> Ed Merks wrote:
>> Philipp,
>>
>> But doesn't the question remain: how do you find the stream for the
>> correct properties file with respect to the local?
>>
>>
>> Philipp Simon wrote:
>>> Okay sorry for beeing to dumb to read some APIs ... The class
>>> PropertyResourceBundle kindly accepted the stream :). Thx for your
>>> time anyways.
>>>
>>> bye Philipp
>>>
Previous Topic:Border problem of CCombo in the FormEditor.
Next Topic:How to make dynamic object contributions at runtime
Goto Forum:
  


Current Time: Tue Jul 15 08:22:19 EDT 2025

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

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

Back to the top