JHotDraw 7.4.1

org.jhotdraw.app.action
Class AbstractApplicationAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jhotdraw.app.action.AbstractApplicationAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, Disposable
Direct Known Subclasses:
AboutAction, AbstractPreferencesAction, ClearRecentFilesMenuAction, ExitAction, NewFileAction, OpenApplicationAction, OpenApplicationFileAction, OpenFileAction, OpenRecentFileAction, ReOpenApplicationAction

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

This abstract class can be extended to implement an Action that acts on an Application.

If the Application object is disabled, the AbstractApplicationAction is disabled as well.

AbstractApplicationAction listens using a WeakPropertyChangeListener on the Application and thus may become garbage collected if it is not referenced by any other object.

Application actions are typically created by an ApplicationModel, and can be retrieved using getAction(String) from the application model. Application model typically links the actions to menu items and toolbars that it creates. Applicaton model may also put actions into its Views, so that they can be linked to components of a view.

Version:
$Id: AbstractApplicationAction.java 604 2010-01-09 12:00:29Z 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
AbstractApplicationAction(Application app)
          Creates a new instance.
 
Method Summary
 void dispose()
          Disposes of all resources held by this object so that they can be garbage collected.
 Application getApplication()
           
protected  void installApplicationListeners(Application app)
           
 boolean isEnabled()
          Returns true if the action is enabled.
 void setEnabled(boolean newValue)
          Enables or disables the action.
protected  void uninstallApplicationListeners(Application app)
          Installs listeners on the application object.
protected  void updateApplicationEnabled()
          Updates the enabled state of this action depending on the new enabled state 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
 

Constructor Detail

AbstractApplicationAction

public AbstractApplicationAction(Application app)
Creates a new instance.

Method Detail

installApplicationListeners

protected void installApplicationListeners(Application app)

uninstallApplicationListeners

protected void uninstallApplicationListeners(Application app)
Installs listeners on the application object.


getApplication

public Application getApplication()

updateApplicationEnabled

protected void updateApplicationEnabled()
Updates the enabled state of this action depending on the new enabled state of the application.


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)

dispose

public final void dispose()
Description copied from interface: Disposable
Disposes of all resources held by this object so that they can be garbage collected.

Specified by:
dispose in interface Disposable

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