Hi,
>Unfortunately, AbstractAction, a default implementation of the Action
>interface, doesn't provide setter methods for icon, text, etc, but provides
>a set of constructors to set initial values. TO remain compatible your
>probably don't want to extends AbstractAction and build your own either.
The Action interface has the putValue() method.
According to swing API documentation this method can set:
ACCELERATOR_KEY The key used for storing a KeyStroke to be used as the
accelerator for the action.
ACTION_COMMAND_KEY The key used to determine the command string for the
ActionEvent that will be created when an Action is going to be notified as the
result of residing in a Keymap associated with a JComponent.
DEFAULT Useful constants that can be used as the storage-retrieval key when
setting or getting one of this object's properties (text or icon).
LONG_DESCRIPTION The key used for storing a longer description for the action,
could be used for context-sensitive help.
MNEMONIC_KEY The key used for storing an int key code to be used as the
mnemonic for the action.
NAME The key used for storing the name for the action, used for a menu or
button.
SHORT_DESCRIPTION The key used for storing a short description for the action,
used for tooltip text.
SMALL_ICON The key used for storing a small icon for the action, used for
toolbar buttons.
We have currently the action interface that would work as is, I can't see any
need to add anything to it.
So the Java/XUL intercation does get more tightly bound as it is now.
I'm wondering if it can work like this:
Suppose we have a hashtable of actions
1. When render detects action tag, it instantiates the given object that extends
the AbstractAction.
The name of this class is given in actionClass attribute.
2. The render takes the attributes of this action and binds them to the action,
something like this:
action.putValue(Action.NAME, name);
(probably we need some kind of ActionPropertyConverter to add to handle the
action properties)
3. The render sets the action to the hashtable
actions.put(element.getAttributeValue("id"), action);
4. When the render detects attribute "use" (or maybe preferably "useAction") it
looks up the actions hashtable and binds the action to control by calling:
control.setAction(action);
This will make the swixml little bit more complicated but it would make ja Java
code much simpler.
Why I want to use those Action's like this?
Now when we have separated the action and the control the same action can be
activated from various controls.
Additionally the action can be set disabled state, and by using the built in
property change notification mechanism the status change in action reflects in
every place the action bound. I.e. I can disable the action in one palce and
this is reflected to every control that is bound to this action.
Have you thought this way?
//Jarmo
P.S. Is there a way to refer a inner class in some other other class. Something
like this:
(suppose ActionListeners is a Singleton)
"ActionListeners.OpenAction" refers to construct
Action action = ActionListeners.getInstance().new OpenAction();