org.jhotdraw.draw.action
Class AbstractDrawingEditorAction
java.lang.Object
javax.swing.AbstractAction
org.jhotdraw.draw.action.AbstractDrawingEditorAction
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
- Direct Known Subclasses:
- ZoomEditorAction
public abstract class AbstractDrawingEditorAction
- extends javax.swing.AbstractAction
This abstract class can be extended to implement an Action
that acts
on behalf of a DrawingEditor
.
By default the enabled state of this action reflects the enabled state of the
DrawingEditor
. When many actions listen to the enabled state of the
drawing editor this can considerably slow down the editor. If updating the
enabled state is not necessary, you can prevent the action from doing so using
setUpdateEnabledState(boolean)
.
AbstractDrawingEditorAction
listens using a
WeakPropertyChangeListener
on the DrawingEditor
and thus may
become garbage collected if it is not referenced by any other object.
- Version:
- $Id: AbstractDrawingEditorAction.java 647 2010-01-24 22:52:59Z rawcoder $
- Author:
- Werner Randelshofer
- See Also:
- Serialized Form
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 |
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 |
Methods inherited from interface java.awt.event.ActionListener |
actionPerformed |
editor
protected DrawingEditor editor
AbstractDrawingEditorAction
public AbstractDrawingEditorAction(DrawingEditor editor)
- Creates a new instance.
setEditor
public void setEditor(DrawingEditor newValue)
updateEnabledState
protected void updateEnabledState()
getEditor
public DrawingEditor getEditor()
getView
protected DrawingView getView()
getDrawing
protected Drawing getDrawing()
fireUndoableEditHappened
protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
- Updates the enabled state of this action to reflect the enabled state
of the active
DrawingView
. If no drawing view is active, this
action is disabled.
setUpdateEnabledState
public void setUpdateEnabledState(boolean newValue)
- By default, the enabled state of this action is updated to reflect
the enabled state of the active
DrawingView
.
Since this is not always necessary, and since many listening actions
may considerably slow down the drawing editor, you can switch this
behavior off here.
- Parameters:
newValue
- Specify false to prevent automatic updating of the
enabled state.
isUpdatEnabledState
public boolean isUpdatEnabledState()
- Returns true, if this action automatically updates its enabled
state to reflect the enabled state of the active
DrawingView
.