JHotDraw 7.4.1

org.jhotdraw.undo
Class UndoRedoManager

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by javax.swing.undo.UndoManager
              extended by org.jhotdraw.undo.UndoRedoManager
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.event.UndoableEditListener, javax.swing.undo.UndoableEdit

public class UndoRedoManager
extends javax.swing.undo.UndoManager

Same as javax.swing.UndoManager but provides actions for undo and redo operations.

Version:
$Id: UndoRedoManager.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
static javax.swing.undo.UndoableEdit DISCARD_ALL_EDITS
          Sending this UndoableEdit event to the UndoRedoManager disables the Undo and Redo functions of the manager.
protected  java.beans.PropertyChangeSupport propertySupport
           
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
UndoRedoManager()
          Creates new UndoRedoManager
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          If inProgress, inserts anEdit at indexOfNextAdd, and removes any old edits that were at indexOfNextAdd or later.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void discardAllEdits()
          Discards all edits.
protected  void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
           
protected  void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
           
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
static ResourceBundleUtil getLabels()
           
 javax.swing.Action getRedoAction()
          Gets the redo action for use as a Redo menu item.
 javax.swing.Action getUndoAction()
          Gets the undo action for use as an Undo menu item.
 boolean hasSignificantEdits()
          Returns true if at least one significant UndoableEdit has been added since the last call to discardAllEdits.
 void redo()
          Redoes the last undone edit event.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void setHasSignificantEdits(boolean newValue)
           
 void setLocale(java.util.Locale l)
           
 void undo()
          Undoes the last edit event.
 void undoOrRedo()
          Undoes or redoes the last edit event.
 
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, toString, trimEdits, trimForLimit, undoableEditHappened, undoTo
 
Methods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificant, lastEdit
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

propertySupport

protected java.beans.PropertyChangeSupport propertySupport

DISCARD_ALL_EDITS

public static final javax.swing.undo.UndoableEdit DISCARD_ALL_EDITS
Sending this UndoableEdit event to the UndoRedoManager disables the Undo and Redo functions of the manager.

Constructor Detail

UndoRedoManager

public UndoRedoManager()
Creates new UndoRedoManager

Method Detail

getLabels

public static ResourceBundleUtil getLabels()

setLocale

public void setLocale(java.util.Locale l)

discardAllEdits

public void discardAllEdits()
Discards all edits.

Overrides:
discardAllEdits in class javax.swing.undo.UndoManager

setHasSignificantEdits

public void setHasSignificantEdits(boolean newValue)

hasSignificantEdits

public boolean hasSignificantEdits()
Returns true if at least one significant UndoableEdit has been added since the last call to discardAllEdits.


addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
If inProgress, inserts anEdit at indexOfNextAdd, and removes any old edits that were at indexOfNextAdd or later. The die method is called on each edit that is removed is sent, in the reverse of the order the edits were added. Updates indexOfNextAdd.

If not inProgress, acts as a CompoundEdit

Regardless of inProgress, if undoOrRedoInProgress, calls die on each edit that is sent.

Specified by:
addEdit in interface javax.swing.undo.UndoableEdit
Overrides:
addEdit in class javax.swing.undo.UndoManager
See Also:
CompoundEdit.end(), CompoundEdit.addEdit(javax.swing.undo.UndoableEdit)

getUndoAction

public javax.swing.Action getUndoAction()
Gets the undo action for use as an Undo menu item.


getRedoAction

public javax.swing.Action getRedoAction()
Gets the redo action for use as a Redo menu item.


undo

public void undo()
          throws javax.swing.undo.CannotUndoException
Undoes the last edit event. The UndoRedoManager ignores all incoming UndoableEdit events, while undo is in progress.

Specified by:
undo in interface javax.swing.undo.UndoableEdit
Overrides:
undo in class javax.swing.undo.UndoManager
Throws:
javax.swing.undo.CannotUndoException

redo

public void redo()
          throws javax.swing.undo.CannotUndoException
Redoes the last undone edit event. The UndoRedoManager ignores all incoming UndoableEdit events, while redo is in progress.

Specified by:
redo in interface javax.swing.undo.UndoableEdit
Overrides:
redo in class javax.swing.undo.UndoManager
Throws:
javax.swing.undo.CannotUndoException

undoOrRedo

public void undoOrRedo()
                throws javax.swing.undo.CannotUndoException,
                       javax.swing.undo.CannotRedoException
Undoes or redoes the last edit event. The UndoRedoManager ignores all incoming UndoableEdit events, while undo or redo is in progress.

Overrides:
undoOrRedo in class javax.swing.undo.UndoManager
Throws:
javax.swing.undo.CannotUndoException
javax.swing.undo.CannotRedoException

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  boolean oldValue,
                                  boolean newValue)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  int oldValue,
                                  int newValue)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)

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