public abstract class AbstractSelectedAction extends javax.swing.AbstractAction implements Disposable
Action
that acts
on behalf of the selected figures of a DrawingView
.
By default the enabled state of this action reflects the enabled state of the
active DrawingView
. If no drawing view is active, this action is
disabled. When many actions listen to the enabled state of the active drawing
views 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.
Constructor and Description |
---|
AbstractSelectedAction(DrawingEditor editor)
Creates an action which acts on the selected figures on the current view
of the specified editor.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes of all resources held by this object so that they can be
garbage collected.
|
protected void |
fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit) |
protected Drawing |
getDrawing() |
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 . |
void |
setEditor(DrawingEditor editor) |
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 . |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
public AbstractSelectedAction(DrawingEditor editor)
protected void updateEnabledState()
DrawingView
. If no drawing view is active, this
action is disabled.public void dispose()
Disposable
dispose
in interface Disposable
public void setEditor(DrawingEditor editor)
public DrawingEditor getEditor()
protected DrawingView getView()
protected Drawing getDrawing()
protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
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
.