com.ephox.editlive.java2.editor.actionhandler
Class EphoxAction

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended bycom.ephox.editlive.java2.editor.actionhandler.EphoxAction
All Implemented Interfaces:
Action, ActionListener, Cloneable, Comparable, EventListener, Serializable

public class EphoxAction
extends AbstractAction
implements Comparable

An extension of Action that provides support for tracking selection and other useful settings.

See Also:
Serialized Form

Field Summary
static String BACKGROUND_COLOR
          The key to indicate the background color for the action.
static String BORDER
          Whether or not to paint a border when this action is in a combo box or menu.
static String COLOR
          The key to indicate the color to paint the item.
static String FONT
          The key to indicate the font face for the action.
static String FOREGROUND_COLOR
          The key to indicate the foreground color for the action.
static String SELECTED
          The property name used for property change events for the selected state of the action.
static String SHOW_CHECKMARK
          Whether or not to show the checkmark when selected.
static String SHOW_WHEN_DISABLED
          The log for this class.
static String SUB_ITEMS
          The property name used when the sub items for this action change.
static String TABLE_WIZARD
          Whether or not this action is a table wizard.
 
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
EphoxAction()
          Creates a new EphoxAction.
EphoxAction(String name)
          Creates a new EphoxAction.
EphoxAction(String name, Icon icon)
          Creates a new EphoxAction.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addActionListener(ActionListener listener)
          Add an action listener to notify when this action is performed.
 void addEnabledFilter(EnabledFilter filter)
          Add an enabled filter to this action.
 int compareTo(Object o)
          Simple comparator to implement standard string sorting based on the action name
protected  List createStaticSubItems()
          Create the static list of sub items for this action.
 boolean equals(Object obj)
           
 List getActionListeners()
          Get the list of action listeners added to this action
 List getEnabledFilters()
          Get the list of enabled filters that have been added to this action.
 List getSubItems()
          Get the sub items for this action.
 int hashCode()
           
 boolean hasSubItems()
           
 boolean isEnabled()
           
 boolean isSelected()
          Get whether or not the action is selected (ie: toggled on).
 void removeActionListener(ActionListener listener)
          Remove an action listener from this action.
 void setSelected(boolean selected)
          Set whether or not the action is selected.
 String toString()
           
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SHOW_WHEN_DISABLED

public static final String SHOW_WHEN_DISABLED
The log for this class.

See Also:
Constant Field Values

SELECTED

public static final String SELECTED
The property name used for property change events for the selected state of the action.

See Also:
Constant Field Values

COLOR

public static final String COLOR
The key to indicate the color to paint the item. Actions with this key paint as a color swab.

See Also:
Constant Field Values

TABLE_WIZARD

public static final String TABLE_WIZARD
Whether or not this action is a table wizard.

See Also:
Constant Field Values

FONT

public static final String FONT
The key to indicate the font face for the action.

See Also:
Constant Field Values

FOREGROUND_COLOR

public static final String FOREGROUND_COLOR
The key to indicate the foreground color for the action.

See Also:
Constant Field Values

BACKGROUND_COLOR

public static final String BACKGROUND_COLOR
The key to indicate the background color for the action.

See Also:
Constant Field Values

BORDER

public static final String BORDER
Whether or not to paint a border when this action is in a combo box or menu.

See Also:
Constant Field Values

SUB_ITEMS

public static final String SUB_ITEMS
The property name used when the sub items for this action change.

See Also:
Constant Field Values

SHOW_CHECKMARK

public static final String SHOW_CHECKMARK
Whether or not to show the checkmark when selected. Defaults to FALSE.

See Also:
Constant Field Values
Constructor Detail

EphoxAction

public EphoxAction()
Creates a new EphoxAction.


EphoxAction

public EphoxAction(String name)
Creates a new EphoxAction.

Parameters:
name - the name of the action.

EphoxAction

public EphoxAction(String name,
                   Icon icon)
Creates a new EphoxAction.

Parameters:
name - the name of the action.
icon - the icon for the action.
Method Detail

addActionListener

public void addActionListener(ActionListener listener)
Add an action listener to notify when this action is performed.

Parameters:
listener - the listener to notify.

removeActionListener

public void removeActionListener(ActionListener listener)
Remove an action listener from this action.

Parameters:
listener - the listener to remove.

getActionListeners

public List getActionListeners()
Get the list of action listeners added to this action

Returns:
an immutable list of listeners

addEnabledFilter

public void addEnabledFilter(EnabledFilter filter)
Add an enabled filter to this action. If any EnabledFilter returns false, the action is disabled.

Parameters:
filter - the filter to add.

getEnabledFilters

public List getEnabledFilters()
Get the list of enabled filters that have been added to this action.

Returns:
an immutable list of EnabledFilter instances that apply to this action.

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Action
See Also:
Action.isEnabled()

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)

isSelected

public boolean isSelected()
Get whether or not the action is selected (ie: toggled on).

Returns:
Returns true if the action is selected, otherwise false.

setSelected

public void setSelected(boolean selected)
Set whether or not the action is selected.

Parameters:
selected - true to select the action, otherwise false.

getSubItems

public List getSubItems()
Get the sub items for this action.

Override this method if dynamic subitems are required. For static items, instead override createStaticSubItems().

Returns:
the List of Action subitems for this action or null if this action doesn't ever have subitems.

createStaticSubItems

protected List createStaticSubItems()
Create the static list of sub items for this action.

Returns:
the list of static sub items for this action or null if this action never has sub items.

toString

public String toString()
See Also:
Object.toString()

compareTo

public int compareTo(Object o)
Simple comparator to implement standard string sorting based on the action name

Specified by:
compareTo in interface Comparable
Parameters:
o - EphoxAction to compare to
Returns:
the result of using the String compareTo function on the two names
See Also:
Comparable.compareTo(Object o)

equals

public boolean equals(Object obj)
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()

hasSubItems

public boolean hasSubItems()

Copyright (c) 2005-2007 Ephox Pty Ltd. All rights reserved.