8.1.2 The Action Manager - Reference Documentation
Authors: Andres Almiray
Version: 1.2.0
8.1.2 The Action Manager
Controller actions may automatically be wrapped and exposed as toolkit specific actions in a group's builder; this greatly simplifies how actions can be configured based on i18n concerns.At the heart of this feature lies theGriffonControllerActionManager
. This component is responsible for instantiating, configuring and keeping references to all actions per controller. It will automatically harvest all action candidates from a Controller once it has been instantiated. Each action has all of its properties configured following this strategy:
- match <controller.class.name>.action.<action.name>.<key>
- match application.action.<action.name>.<key>
<action.name>
should be properly capitalized. In other words, you can configure action properties specifically per Controller or application wide. Available keys areKey | Default value |
---|---|
name | GriffonNameUtils.getNaturalName() applied to the action's name - 'Action' suffix (if it exists) |
accelerator | undefined |
short_description | undefined |
long_description | undefined |
mnemonic | undefined |
small_icon | undefined; should point to an URL in the classpath |
large_icon | undefined; should point to an URL in the classpath |
enabled | undefined; boolean value |
selected | undefined; boolean value |
Example
The following Controller defines four actions, the first two as closure properties while the others as methods. Two actions have an 'Action' suffix in their names.package sample import java.awt.event.ActionEvent class SampleController { def newAction = { … } def open = { … } void close(ActionEvent evt) { … } void deleteAction(ActionEvent evt) { … } }
new
and delete
use the 'Action' suffix in order to avoid compilation errors given that they make use of reserved keywords. It's all the same to the GriffonControllerActionManager
as it will generate the following variables in the group's builder: newAction
, openAction
, closeAction
and deleteAction
. ActionManager expects the following keys to be available in the application's i18n resources (i.e. griffon-app/i18n/messages.properties
)sample.SampleController.action.New.name = New sample.SampleController.action.Open.name = Open sample.SampleController.action.Close.name = Close sample.SampleController.action.Delete.name = Delete # additional keys per action elided
griffon-app/i18n/messages_es.properties
with the following keysapplication.action.Close.name = Cerrar