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

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.ephox.editlive.java2.editor.actionhandler.EphoxAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, Comparable<EphoxAction>, EventListener, Action

public class EphoxAction
extends AbstractAction
implements Comparable<EphoxAction>

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

NOTE: Eventually this class will move into com.ephox.editlive.ephoxaction

See Also:
Serialized Form

Field Summary
static String ALLOW_TEXT
          Whether or not to allow text on Toolbar Buttons
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
           
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, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
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.
 void addEnabledFilters(EnabledFilter... filters)
           
 boolean allowsText()
           
 int compareTo(EphoxAction o)
          Simple comparator to implement standard string sorting based on the action name
protected  List<EphoxAction> createStaticSubItems()
          Create the static list of sub items for this action.
 boolean equals(Object obj)
           
 List<ActionListener> getActionListeners()
          Get the list of action listeners added to this action
 List<EnabledFilter> getEnabledFilters()
          Get the list of enabled filters that have been added to this action.
 JPopupMenu getPopupMenu()
          Returns the popup menu for this action
 List<EphoxAction> 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 setMnemonicFromName()
           
 void setMnemonicFromString(String mnemonic)
           
 void setSelected(boolean selected)
          Set whether or not the action is selected.
 void setSubItems(List<EphoxAction> subItems)
          Set the sub items for this action.
 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
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

ALLOW_TEXT

public static final String ALLOW_TEXT
Whether or not to allow text on Toolbar Buttons

See Also:
Constant Field Values
Constructor Detail

EphoxAction

public 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<ActionListener> 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.

addEnabledFilters

public void addEnabledFilters(EnabledFilter... filters)

getEnabledFilters

public List<EnabledFilter> 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
Overrides:
isEnabled in class AbstractAction

actionPerformed

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

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<EphoxAction> 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<EphoxAction> 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.

setSubItems

public void setSubItems(List<EphoxAction> subItems)
Set the sub items for this action.

Parameters:
subItems - the sub items for the action.

toString

public String toString()
Overrides:
toString in class Object

compareTo

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

Specified by:
compareTo in interface Comparable<EphoxAction>
Parameters:
o - EphoxAction to compare to
Returns:
the result of using the String compareTo function on the two names

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

hasSubItems

public boolean hasSubItems()

getPopupMenu

public JPopupMenu getPopupMenu()
Returns the popup menu for this action

Returns:
null if this action is not a COLOR action or TABLE_WIZARD action

allowsText

public boolean allowsText()

setMnemonicFromName

public void setMnemonicFromName()

setMnemonicFromString

public void setMnemonicFromString(String mnemonic)

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