public abstract class AbstractDrawingViewAction extends javax.swing.AbstractAction implements Disposable
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.
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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 . |
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 . |
protected 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.
|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public AbstractDrawingViewAction(DrawingEditor editor)
public AbstractDrawingViewAction(DrawingView view)
protected void setEditor(DrawingEditor newValue)
protected DrawingEditor getEditor()
protected DrawingView getView()
protected Drawing getDrawing()
protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
protected 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
.