views:

323

answers:

2

If I have a Java source file open in Eclipse I want to be able to click on a resource bundle key to open the resource bundle at the associated line for editing. For example if I had a bundle Bundle_en.properties:

key1=Value One
key2=Value Two

And a source file:

ResourceBundle bundle = ResourceBundle.getBundle("Bundle", Locale.ENGLISH);
String value = bundle.getString("key1");

I would like to be able to ctrl-click on that "key1" in the source file and have the properties file open up with key1 highlighted. In a real world scenario I would have a dozen properties files each containing hundreds of keys accessed from 20 different classes. Any pointers appreciated.

Thank you!

A: 
VonC
+1  A: 

I'm surprised you can't just CTRL+click the variable in the getString method.

I tested this in Eclipse 3.4.1

1) create a class containing:

private static final String FOO = "bar";

2) right click FOO and select Source -> Externalize Strings

3) select the defaults and you'll end up with a messages.properties file and a Messages class that contains the ResourceBundle referencing code linking FOO to the value in messages.properties.

Once it's created FOO will look like:

static final String FOO=Messages.getString("Utils.0"); //$NON-NLS-1$

When I CTRL+click on "Utils.0" it takes me directly to the property in the resource bundle.

Kevin Williams
I don't know how/why this would be different from hand-written ResourceBundle accessing code.
Kevin Williams