|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
org.jhotdraw.draw.action.AbstractDrawingViewAction
public abstract class AbstractDrawingViewAction
This abstract class can be extended to implement an Action
that acts
on behalf of a DrawingView
.
By default the enabled state of this action reflects the enabled state of the
DrawingView
. If no drawing view is active, this action is
disabled. When many actions listen to the enabled state this can considerably
slow down the editor. If updating the enabled state is not necessary, you can
disable it using setUpdateEnabledState(boolean)
.
If the AbstractDrawingEditorAction
acts on the currently active
DrawingView
it listens for property changes in the
DrawingEditor
. It listens using a WeakPropertyChangeListener
on the DrawingEditor
and thus may become garbage collected if it is
not referenced by any other object.
Nested Class Summary | |
---|---|
private class |
AbstractDrawingViewAction.EventHandler
|
Field Summary | |
---|---|
private DrawingView |
activeView
|
private DrawingEditor |
editor
|
private AbstractDrawingViewAction.EventHandler |
eventHandler
|
private DrawingView |
specificView
|
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 | |
---|---|
AbstractDrawingViewAction(DrawingEditor editor)
Creates a view action which acts on the current view of the editor. |
|
AbstractDrawingViewAction(DrawingView view)
Creates a view action which acts on the specified view. |
Method Summary | |
---|---|
void |
dispose()
Frees all resources held by this object, so that it can be garbage collected. |
protected void |
fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
|
protected Drawing |
getDrawing()
|
protected DrawingEditor |
getEditor()
|
protected DrawingView |
getView()
|
boolean |
isUpdatEnabledState()
Returns true, if this action automatically updates its enabled state to reflect the enabled state of the active DrawingView . |
private void |
registerEventHandler()
Registers the event handler from the drawing editor and the active drawing view. |
protected void |
setEditor(DrawingEditor newValue)
|
void |
setUpdateEnabledState(boolean newValue)
By default, the enabled state of this action is updated to reflect the enabled state of the active DrawingView . |
private void |
unregisterEventHandler()
Unregisters the event handler from the drawing editor and the active drawing view. |
void |
updateEnabledState()
Updates the enabled state of this action to reflect the enabled state of the active DrawingView . |
protected void |
updateViewState()
This method is called when the active drawing view of the drawing editor changed. |
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 |
Field Detail |
---|
private DrawingEditor editor
private DrawingView specificView
private transient DrawingView activeView
private AbstractDrawingViewAction.EventHandler eventHandler
Constructor Detail |
---|
public AbstractDrawingViewAction(DrawingEditor editor)
public AbstractDrawingViewAction(DrawingView view)
Method Detail |
---|
protected void setEditor(DrawingEditor newValue)
protected DrawingEditor getEditor()
protected DrawingView getView()
protected Drawing getDrawing()
protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
public void updateEnabledState()
DrawingView
. If no drawing view is active, this
action is disabled.
protected void updateViewState()
public void dispose()
dispose
in interface Disposable
public void setUpdateEnabledState(boolean newValue)
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.
newValue
- Specify false to prevent automatic updating of the
enabled state.public boolean isUpdatEnabledState()
DrawingView
.
private void unregisterEventHandler()
private void registerEventHandler()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |