JHotDraw 7.3.1

org.jhotdraw.app.action
Class AbstractViewAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jhotdraw.app.action.AbstractViewAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
AbstractSaveBeforeAction, ExportAction, FindAction, MaximizeAction, MinimizeAction, PrintAction, RedoAction, SaveAction, ToggleLineNumbersAction, ToggleLineWrapAction, TogglePropertiesPanelAction, ToggleStatusBarAction, ToggleViewPropertyAction, UndoAction, ViewPropertyAction, ViewSourceAction

public abstract class AbstractViewAction
extends javax.swing.AbstractAction

This abstract class can be extended to implement an Action that acts on behalf of a View.

If the current View object is disabled or is null, the AbstractViewAction is disabled as well.

A property name can be specified. When the specified property changes or when the current view changes, method updateView is invoked.

Version:
$Id: AbstractViewAction.java 556 2009-09-06 13:06:03Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
static java.lang.String ENABLED_PROPERTY
           
static java.lang.String VIEW_PROPERTY
           
 
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
AbstractViewAction(Application app)
          Creates a new instance which acts on the active view of the application.
AbstractViewAction(Application app, View view)
          Creates a new instance which acts on the specified view of the application.
 
Method Summary
 View getActiveView()
           
 Application getApplication()
           
protected  java.lang.String getPropertyName()
          Gets the property name.
protected  void installViewListeners(View p)
          Installs listeners on the view object.
 boolean isEnabled()
          Returns true if the action is enabled.
 void setEnabled(boolean newValue)
          Enables or disables the action.
protected  void setPropertyName(java.lang.String name)
          Sets the property name.
protected  void uninstallViewListeners(View p)
          Uninstalls listeners on the view object.
protected  void updateEnabled(boolean oldValue, boolean newValue)
          Updates the enabled state of this action depending on the new enabled state of the view.
protected  void updateView()
          This method is invoked, when the property changed and when the view changed.
protected  void updateView(View oldValue, View newValue)
          Updates the listeners of this action depending on the current view of the application.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, putValue, removePropertyChangeListener
 
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

VIEW_PROPERTY

public static final java.lang.String VIEW_PROPERTY
See Also:
Constant Field Values

ENABLED_PROPERTY

public static final java.lang.String ENABLED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

AbstractViewAction

public AbstractViewAction(Application app)
Creates a new instance which acts on the active view of the application.


AbstractViewAction

public AbstractViewAction(Application app,
                          View view)
Creates a new instance which acts on the specified view of the application.

Method Detail

updateView

protected void updateView(View oldValue,
                          View newValue)
Updates the listeners of this action depending on the current view of the application.


setPropertyName

protected void setPropertyName(java.lang.String name)
Sets the property name.


getPropertyName

protected java.lang.String getPropertyName()
Gets the property name.


updateView

protected void updateView()
This method is invoked, when the property changed and when the view changed.


installViewListeners

protected void installViewListeners(View p)
Installs listeners on the view object.


uninstallViewListeners

protected void uninstallViewListeners(View p)
Uninstalls listeners on the view object.


updateEnabled

protected void updateEnabled(boolean oldValue,
                             boolean newValue)
Updates the enabled state of this action depending on the new enabled state of the view.


getApplication

public Application getApplication()

getActiveView

public View getActiveView()

isEnabled

public boolean isEnabled()
Returns true if the action is enabled. The enabled state of the action depends on the state that has been set using setEnabled() and on the enabled state of the application.

Specified by:
isEnabled in interface javax.swing.Action
Overrides:
isEnabled in class javax.swing.AbstractAction
Returns:
true if the action is enabled, false otherwise
See Also:
Action.isEnabled()

setEnabled

public void setEnabled(boolean newValue)
Enables or disables the action. The enabled state of the action depends on the value that is set here and on the enabled state of the application.

Specified by:
setEnabled in interface javax.swing.Action
Overrides:
setEnabled in class javax.swing.AbstractAction
Parameters:
newValue - true to enable the action, false to disable it
See Also:
Action.setEnabled(boolean)

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