public interface ILcdAction extends ActionListener, Serializable, ILcdPropertyChangeSource
An ILcdAction
has a set of key-value pairs associated.
These key-value pairs can be used to build up dynamically a set of
properties of the action.
An ILcdAction
can be associated to zero or more Invokers.
An ILcdAction
is listenable by PropertyChangeListeners (from java.beans).
(refer to existing pattern?)
The class also provides constants that can be used as the storage-retrieval key when setting or getting one of this object's properties (text or icon).
Modifier and Type | Field and Description |
---|---|
static String |
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).
|
static String |
LONG_DESCRIPTION
Constant key for LongDescription property.
|
static String |
NAME
Constant key for Name property.
|
static String |
SELECTED_KEY
The key used for storing a
Boolean that corresponds
to the selected state. |
static String |
SHORT_DESCRIPTION
Constant key for ShortDescription property.
|
static String |
SHOW_ACTION_NAME
Defines if the action would preferably show or hide its action name to the end user.
|
static String |
SMALL_ICON
Constant key for SmallIcon property.
|
static String |
VISIBLE
Constant key for the Visible property.
|
Modifier and Type | Method and Description |
---|---|
Object |
getValue(String key)
Returns one of this object's properties
using the associated key.
|
boolean |
isEnabled() |
void |
putValue(String key,
Object value)
Sets one of this objects properties.
|
void |
setEnabled(boolean b)
Sets/tests the enabled state of the
ILcdAction . |
actionPerformed
addPropertyChangeListener, removePropertyChangeListener
static final String DEFAULT
static final String NAME
String
.static final String SHORT_DESCRIPTION
String
.static final String LONG_DESCRIPTION
String
.static final String SMALL_ICON
ILcdIcon
.static final String VISIBLE
Constant key for the Visible property. Its associated value should be of type Boolean
.
Note that this key is not automatically recognized by Swing. For example, when creating a visual representation
for an ILcdAction
changing the associated value of this key will not affect the Swing component:
ILcdAction action = ...
JButton button = new JButton( new TLcdSWAction( action ) );
action.putValue( ILcdAction.VISIBLE, false );//by default this will not change
//the visibility of button
In Lucy, the ALcyActionBar
and its extension do respect this property and adjust the visibility
of the component representing the ILcdAction
. A possible use-case for this property is to
create context-sensitive pop-up menu items.
static final String SHOW_ACTION_NAME
Defines if the action would preferably show or hide its action name to the end user. The
value is of type Boolean
.
Note that this key is not automatically recognized by Swing. For example, when creating a visual
representation for an ILcdAction
changing the associated value of this key will
not affect the Swing component (see also VISIBLE
).
In Lucy, the TLcyToolBar
respects this property. This allows for some actions
to show both their icon and text on a tool bar, and for others to only show their icon.
TLcyMenuBar
for example ignores this property, and always displays the action
name and icon.
The default value depends on the particular tool bar implementation.
TLcyToolBar
by default hides all action names, so only displays the icons.
static final String SELECTED_KEY
Boolean
that corresponds
to the selected state. This is typically used for components with a meaningful selection state,
such as a toggle button.
This property differs from the others in that it is both read
by the component and set by the component.
For example, TLcdGXYSetControllerAction
automatically updates the value based on whether its controller is active or not.
When developing toggle actions in Lucy, use ALcyActiveSettable instead of ILcdAction.Object getValue(String key)
PropertyChangeEvent
will be sent
to listeners.void putValue(String key, Object value)
key
- one of NAME, SHORT_DESCRIPTION, LONG_DESCRIPTION, SMALL_ICON.value
- the value to be used for this action
to display it textually using the name, short description or long description or
to display it graphically using the icon.
Values for NAME, SHORT_DESCRIPTION and LONG_DESCRIPTION should be String objects,
values for SMALL_ICON should be ILcdIcon implementations.void setEnabled(boolean b)
ILcdAction
. When enabled,
any component associated with this object is active and
able to fire this object's actionPerformed
method.boolean isEnabled()