JHotDraw 7.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, TogglePropertiesPanelAction, ToggleStatusBarAction, ToggleViewPropertyAction, UndoAction, ViewPropertyAction, ViewSourceAction

public abstract class AbstractViewAction
extends javax.swing.AbstractAction

An Action that acts on on the current View of an Application. 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:
1.0 October 9, 2005 Created.
Author:
Werner Randelshofer
See Also:
View, Application, 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, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractViewAction(Application app)
          Creates a new instance.
 
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.

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-2007 (c) JHotDraw.org.
Some rights reserved.