org.openpermis.editor.policy.gui
Class SelectableAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.openpermis.editor.policy.gui.SelectableAction
All Implemented Interfaces:
ActionListener, ItemListener, Serializable, Cloneable, EventListener, Action
Direct Known Subclasses:
ToolTrackerAction

public abstract class SelectableAction
extends AbstractAction
implements ItemListener

Extended swing Action that provides selection support.

Notes:
Selection support is built-in in JSE6, this class is for backward compatibility of JSE5 only.
See Also:
Serialized Form
Since:
0.1.0

Field Summary
private static String SELECTED_KEY
          The property key used to indicate that an action is selected.
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
SelectableAction(String name, Icon icon)
          Defines an Action with the specified name and small icon.
 
Method Summary
abstract  void actionPerformed(ActionEvent e)
           
private static
<T extends AbstractButton>
T
configure(T button, Action action)
          Configures the specified button for use with the given action.
 JCheckBox createCheckBox()
          Convenience factory method to create a check box that is bound to this action.
static JCheckBox createCheckBox(Action action)
          Creates a check box where properties are taken from the Action supplied.
 JCheckBoxMenuItem createCheckBoxMenuItem()
          Convenience factory method to create a check box menu item that is bound to this action.
static JCheckBoxMenuItem createCheckBoxMenuItem(Action action)
          Creates a check box menu item where properties are taken from the Action supplied.
 JToggleButton createToggleButton()
          Convenience factory method to create a toggle button that is bound to this action.
static JToggleButton createToggleButton(Action action)
          Creates a toggle button where properties are taken from the Action supplied.
 boolean isSelected()
          Check if the specified action is selected.
 boolean isSelected(Action action)
          Check if the specified action is selected.
 boolean isSelectionEvent(PropertyChangeEvent event)
          Checks if the event is a selection change event fired by this action.
 void itemStateChanged(ItemEvent e)
          Synchronizes the selection state of this action with the one of the button.
 void setSelected(boolean selected)
          Sets the selection state of this action.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Constant Field Value:
-7232379579443222905L
Since:
0.1.0

SELECTED_KEY

private static final String SELECTED_KEY
The property key used to indicate that an action is selected.

The value of this property is of type Boolean.

Constant Field Value:
"_selected"
Since:
0.1.0
Constructor Detail

SelectableAction

public SelectableAction(String name,
                        Icon icon)
Defines an Action with the specified name and small icon.

Parameters:
name - the description of the action.
icon - the small icon of the action.
Since:
0.1.0
Method Detail

configure

private static <T extends AbstractButton> T configure(T button,
                                                      Action action)
Configures the specified button for use with the given action.

If the action is a selectable action then selection support will be added.

Type Parameters:
T - the type of button to configure.
Parameters:
button - the button to configure.
action - the action to configure to button from.
Returns:
the button passed in for fluent style use.
Since:
0.1.0

createCheckBox

public static JCheckBox createCheckBox(Action action)
Creates a check box where properties are taken from the Action supplied.

Also provides selection support if the action specified is a selectable action.

Parameters:
action - the action to create the check box.
Returns:
the check box requested.
Since:
0.1.0

createToggleButton

public static JToggleButton createToggleButton(Action action)
Creates a toggle button where properties are taken from the Action supplied.

Also provides selection support if the action specified is a selectable action.

Parameters:
action - the action to create the toggle button.
Returns:
the toggle button requested.
Since:
0.1.0

createCheckBoxMenuItem

public static JCheckBoxMenuItem createCheckBoxMenuItem(Action action)
Creates a check box menu item where properties are taken from the Action supplied.

Also provides selection support if the action specified is a selectable action.

Parameters:
action - the action to create the check box menu item.
Returns:
the check box menu item requested.
Since:
0.1.0

isSelected

public boolean isSelected(Action action)
Check if the specified action is selected.

Only selectable actions can have the selected state, all others return false.

Parameters:
action - the action to check.
Returns:
true if it is selected, false otherwise.
Since:
0.1.0

createCheckBox

public JCheckBox createCheckBox()
Convenience factory method to create a check box that is bound to this action.

Returns:
the check box requested.
Since:
0.1.0

createToggleButton

public JToggleButton createToggleButton()
Convenience factory method to create a toggle button that is bound to this action.

Returns:
the toggle button requested.
Since:
0.1.0

createCheckBoxMenuItem

public JCheckBoxMenuItem createCheckBoxMenuItem()
Convenience factory method to create a check box menu item that is bound to this action.

Returns:
the check box menu item requested.
Since:
0.1.0

isSelectionEvent

public boolean isSelectionEvent(PropertyChangeEvent event)
Checks if the event is a selection change event fired by this action.

Use isSelected() to check the value or inspect the event values which are of type Boolean.

Parameters:
event - the event to check, may be null.
Returns:
true if the event is a selection change event on this action.
Since:
0.1.0

isSelected

public boolean isSelected()
Check if the specified action is selected.

Returns:
true if it is selected, false otherwise.
Since:
0.1.0

setSelected

public void setSelected(boolean selected)
Sets the selection state of this action.

Parameters:
selected - the new selection state of this action.
Since:
0.1.0

actionPerformed

public abstract void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener
Since:
0.1.0

itemStateChanged

public void itemStateChanged(ItemEvent e)
Synchronizes the selection state of this action with the one of the button.

If the button changes, the action will change as well.

Specified by:
itemStateChanged in interface ItemListener
Parameters:
e - the item state change event.
Since:
0.1.0


PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:15:22
Copyright (c) 2002-2007 Ergon Informatik AG