JHotDraw 7.5.1

org.jhotdraw.draw.action
Class AbstractDrawingViewAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jhotdraw.draw.action.AbstractDrawingViewAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, Disposable
Direct Known Subclasses:
DrawingAttributeAction, DrawingColorChooserHandler, EditCanvasAction, EditGridAction, ToggleGridAction, ZoomAction

public abstract class AbstractDrawingViewAction
extends javax.swing.AbstractAction
implements Disposable

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.

Version:
$Id: AbstractDrawingViewAction.java 673 2010-07-29 10:02:46Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
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.
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.
 
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
 

Constructor Detail

AbstractDrawingViewAction

public AbstractDrawingViewAction(DrawingEditor editor)
Creates a view action which acts on the current view of the editor.


AbstractDrawingViewAction

public AbstractDrawingViewAction(DrawingView view)
Creates a view action which acts on the specified view.

Method Detail

setEditor

protected void setEditor(DrawingEditor newValue)

getEditor

protected DrawingEditor getEditor()

getView

protected DrawingView getView()

getDrawing

protected Drawing getDrawing()

fireUndoableEditHappened

protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)

updateEnabledState

protected void updateEnabledState()
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.


updateViewState

protected void updateViewState()
This method is called when the active drawing view of the drawing editor changed. The implementation in this class does nothing.


dispose

public void dispose()
Frees all resources held by this object, so that it can be garbage collected.

Specified by:
dispose in interface Disposable

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.


Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.