01_user_documentation:11_plugin:02_resources:01_bundle
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext 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.1 | 01_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 // | ||
| + | |||
| + | >/ | ||
| + | |||
| + | * 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: | ||
| + | |||
| + | < | ||
| + | project.savequestion.title = Save Project | ||
| + | project.savequestion.msg = The project {0} has been modified. Save changes? | ||
| + | </ | ||
| + | |||
| + | The _project.savequestion.msg_ can be accesed with: | ||
| + | |||
| + | <code java> | ||
| + | public static final I18NBundle I18N = I18NBundle.getInstance (UI.class); | ||
| + | String VAR = " | ||
| + | UI.I18N.msg (" | ||
| + | </ | ||
| + | |||
| + | 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, | ||
| + | |||
| + | ==== 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: | ||
| + | |||
| + | < | ||
| + | text.undo.Name = Undo | ||
| + | text.undo.ShortDescription = Undo | ||
| + | text.undo.Icon = \`icon actions/ | ||
| + | < | ||
| + | |||
| + | An _Icon_ is defined with _\`icon actions/ | ||
| + | - the first part, _icon_ in this example, defines the type of resources. | ||
| + | - the second part, _actions/ | ||
| + | |||
| + | GroIMP uses ResourcesConverter objects to load the given resource into the correct java object. | ||
| + | See [[01_user_documentation: | ||
