User Tools

Site Tools


01_user_documentation:11_plugin:02_resources:01_bundle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
01_user_documentation:11_plugin:02_resources:01_bundle [2025/12/12 13:33] – removed - external edit (Unknown date) 127.0.0.101_user_documentation:11_plugin:02_resources:01_bundle [2025/12/12 15:32] (current) – [Other object resources] groimp
Line 1: Line 1:
 +===== Resources Bundle =====
  
 +GroIMP uses a bundle approach to link resources and Registry items.
 +
 +==== String resources ====
 +
 +Most resources used in GroIMP defined in property files are String. 
 +
 +The two main examples are:
 +  * Name of registry item, usually the name are defined at the plugin level (in //plugin.properties//). E.g. for the menu item _open_ it is defined like:
 +
 +>/ui/commands/open.Name = &Open...
 +
 +  * Messages to be displayed in GroIMP. Usually these messages are defined at a package level (in _Resources.properties_). E.g. the message dialog of closing a unsaved project has the following properties:
 +
 +<code>
 +project.savequestion.title = Save Project
 +project.savequestion.msg = The project {0} has been modified. Save changes?
 +</code>
 +
 +The _project.savequestion.msg_ can be accesed with:
 +
 +<code java>
 +public static final I18NBundle I18N = I18NBundle.getInstance (UI.class);
 +String VAR = "PROJECT NAME";
 +UI.I18N.msg ("project.savequestion.msg", VAR)
 +</code>
 +
 +in this example, the _Resources.property_ file is at the root of the UI.class file, thus it can be accessed with _I18NBundle.getInstance (UI.class)_. In your plugin, you can access your _Resources.property_ by using one class of your package as long as both the .class and .property files are on the same level.
 +
 +The VAR _PROJECT NAME_ is injected in the property message under {0}. The message can include any numer of parameters used like: _I18N.msg (PROPERTY_NAME, VAR1, VAR2, ...)_.
 +
 +==== Other object resources ====
 +
 +GroIMP bundle also works with other object resources, such as Icon or Image.
 +
 +In that case, the definition of the resource change slightly. For instance the registry command that define _undo for text_ has the properties:
 +
 +<code>
 +text.undo.Name = Undo
 +text.undo.ShortDescription = Undo
 +text.undo.Icon = \`icon actions/undo\`
 +<code>
 +
 +An _Icon_ is defined with _\`icon actions/undo\`_. First the \` symbol at the begining and end of the resource is used to define a non String resource. Then, the property is defined in two part separated by the first space:
 +  - the first part, _icon_ in this example, defines the type of resources. 
 +  - the second part, _actions/undo_ defines its value. 
 +
 +GroIMP uses ResourcesConverter objects to load the given resource into the correct java object. 
 +See [[01_user_documentation:11_plugin:02_resources:02_converter|how to create a new Resource converter]].