org.jhotdraw.app.action
Class AbstractSaveBeforeAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.jhotdraw.app.action.AbstractViewAction
          extended by org.jhotdraw.app.action.AbstractSaveBeforeAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
ClearAction, CloseAction, LoadAction, LoadRecentAction

public abstract class AbstractSaveBeforeAction
extends AbstractViewAction

This abstract class can be extended to implement an Action that asks to save unsaved changes of a View before the the action is performed.

If the view has no unsaved changes, method doIt is invoked immediately. If unsaved changes are present, a dialog is shown asking whether the user wants to discard the changes, cancel or save the changes before doing it. If the user chooses to discard the chanegs, toIt is invoked immediately. If the user chooses to cancel, the action is aborted. If the user chooses to save the changes, the view is saved, and doIt is only invoked after the view was successfully saved.

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

Field Summary
private  java.awt.Component oldFocusOwner
           
 
Fields inherited from class org.jhotdraw.app.action.AbstractViewAction
ENABLED_PROPERTY, 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
AbstractSaveBeforeAction(Application app)
          Creates a new instance.
AbstractSaveBeforeAction(Application app, View view)
          Creates a new instance.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
protected abstract  void doIt(View p)
           
protected  void saveChanges(View p)
           
protected  void saveToFile(View p, java.io.File file)
           
 
Methods inherited from class org.jhotdraw.app.action.AbstractViewAction
getActiveView, getApplication, getPropertyName, installViewListeners, isEnabled, setEnabled, setPropertyName, uninstallViewListeners, updateEnabled, updateView, updateView
 
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
 

Field Detail

oldFocusOwner

private java.awt.Component oldFocusOwner
Constructor Detail

AbstractSaveBeforeAction

public AbstractSaveBeforeAction(Application app)
Creates a new instance.


AbstractSaveBeforeAction

public AbstractSaveBeforeAction(Application app,
                                View view)
Creates a new instance.

Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)

saveChanges

protected void saveChanges(View p)

saveToFile

protected void saveToFile(View p,
                          java.io.File file)

doIt

protected abstract void doIt(View p)