Table of Contents

Resource Converter

Resources defined in the property files are loaded with _ResourceConverter_. See how to define resources in bundle.

Resources Object

Resources are defined in a .property file. By default loaded as String. If the resource if set as `type value`, it is read through a resource converter. The type and value are separated by the first space. The resource definition must be surrounded with `.

The most common resource object is the Icon.

When GroIMP read the _Icon_ description of the registry item, it first load the String: `icon value`. Then, look into all of its ResourceConverter to find if one is capable of converting this value into the correct java object.

Create a new ResourceConverter

The ResourceConverter are defined in the PLUGIN class of a plugin.

In a plugin.xml file the PLUGIN class is defined in the first <plugin> tag , e.g.

<plugin
  id="de.grogra.pf"
  version="2.1.1"
  class="de.grogra.pf.ui.UI"
  xmlns="http://grogra.de/registry">

In that example, the class is de.grogra.pf.ui.UI. That class MUST extends Plugin and implements ResourceConverter. Then, the class MUST add itself to the converter list on startup, and define the converter methods: canHandleConversion, and convert.

For the example of the UI class, (which is the converter for _icon_ resources_):

public final class UI extends Plugin implements ResourceConverter{
 
	public static final I18NBundle I18N = I18NBundle.getInstance (UI.class);
	@Override
	public void startup ()
	{
		super.startup ();
		I18NBundle.addResourceConverter (this);
	}
	public boolean canHandleConversion (String name)
	{
		return "icon".equals (name);
	}
 
 
	public Object convert (String name, String argument, I18NBundle bundle)
	{
		if ("icon".equals (name))
		{
		...
		}
	}
...