views:

155

answers:

3
+1  Q: 

Eclipse plugin

I want to write an eclipse plugin to show the actual value of the message code. The values are to be loaded from the given resource bundle. Only classes of the resource bundle will be available. So I require to load the resource bundle class which is declared in the current file. These class files will be in the classes folder or in a jar file in the lib folder. Is there any way to load the classes dynamically from the eclipse plugin? Thanks in advance

A: 

Hi,

Have a look at the Bundle class. There is the following method:

public Class loadClass(String name) throws ClassNotFoundException;

To get the bundle from your plugin:

Activator.getDefault().getBundle()

Hope this help

Manu

Manuel Selva
A: 

An Example how to get a externalized string from a message.properties file

private static final String BUNDLE_NAME = "de.stackoverflow.package.messages"; //$NON-NLS-1$

private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

RESOURCE_BUNDLE.getString(key);

Every plugin does have a bundle object where you can load the files of a plugin. The Bundle object should contain every information you want to use.

Markus Lausberg
Thank you for the reply. The bundles are available in the output folder of the current project of the workbench. is it possible to load that bundle with the above statement?
you can load everything which is inside the plugin structure.
Markus Lausberg
Any idea how to load a class which is available only in one of the Java project available in the eclipse workspace
i dont now what you want to do?! When Plugin B depend on Plugin A, All classes form B can load the classes from A. Otherwise you have to put the classloader of the plugin the class is lying into the plgin you want to load the class.
Markus Lausberg
A: 

HI Markus, Thank you for answering my question. I will explain my question further. I have a java project which contains ListResourceBundle objects. The source code is not available.

We used to take the value of a key with the following command. ListResourceBundle ResourceBundle stats = ResourceBundle.getBundle("com.org.MessageBundle");

stats.getString("name");// This is how we take the values

I want to show the actual value of the key, 'name' as a tool tip, on hovering the mouse pointer over it. I a trying to develop an eclipse plugin for that.

The main problem I faces now is, I cannot load the class files of a user project from the eclipse plugin.

Is there any way to do that?

Thanks in advance.