JSR-209 (Final Release)

javax.swing.undo
Class AbstractUndoableEdit

java.lang.Object
  extended byjavax.swing.undo.AbstractUndoableEdit
All Implemented Interfaces:
java.io.Serializable, UndoableEdit
Direct Known Subclasses:
AbstractDocument.ElementEdit, CompoundEdit

public class AbstractUndoableEdit
extends java.lang.Object
implements UndoableEdit, java.io.Serializable

An abstract implementation of UndoableEdit, implementing simple responses to all boolean methods in that interface.


Constructor Summary
protected AbstractUndoableEdit()
          Creates an AbstractUndoableEdit which defaults and alive to true.
 
Method Summary
 boolean addEdit(UndoableEdit anEdit)
          This default implementation returns false.
 boolean canRedo()
          Returns true if this edit is alive and hasBeenDone is false.
 boolean canUndo()
          Returns true if this edit is alive and hasBeenDone is true.
 void die()
          Sets alive to false.
 java.lang.String getPresentationName()
          This default implementation returns "".
 boolean isSignificant()
          This default implementation returns true.
 void redo()
          Throws CannotRedoException if canRedo returns false.
 boolean replaceEdit(UndoableEdit anEdit)
          This default implementation returns false.
 java.lang.String toString()
          Returns a string that displays and identifies this object's properties.
 void undo()
          Throws CannotUndoException if canUndo returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractUndoableEdit

protected AbstractUndoableEdit()
Creates an AbstractUndoableEdit which defaults and alive to true.

Method Detail

die

public void die()
Sets alive to false. Note that this is a one way operation; dead edits cannot be resurrected. Sending undo or redo to a dead edit results in an exception being thrown.

Typically an edit is killed when it is consolidated by another edit's addEdit or replaceEdit method.

Specified by:
die in interface UndoableEdit
See Also:
CompoundEdit.die()

undo

public void undo()
          throws CannotUndoException
Throws CannotUndoException if canUndo returns false. Sets hasBeenDone to false. Subclasses should override to undo the operation represented by this edit. Override should begin with a call to super.

Specified by:
undo in interface UndoableEdit
Throws:
CannotUndoException - if canUndo returns false
See Also:
canUndo()

canUndo

public boolean canUndo()
Returns true if this edit is alive and hasBeenDone is true.

Specified by:
canUndo in interface UndoableEdit
Returns:
true if this edit is alive and hasBeenDone is true
See Also:
die(), undo(), redo()

redo

public void redo()
          throws CannotRedoException
Throws CannotRedoException if canRedo returns false. Sets hasBeenDone to true. Subclasses should override to redo the operation represented by this edit. Override should begin with a call to super.

Specified by:
redo in interface UndoableEdit
Throws:
CannotRedoException - if canRedo returns false
See Also:
canRedo()

canRedo

public boolean canRedo()
Returns true if this edit is alive and hasBeenDone is false.

Specified by:
canRedo in interface UndoableEdit
Returns:
true if this edit is alive and hasBeenDone is false
See Also:
die(), undo(), redo()

addEdit

public boolean addEdit(UndoableEdit anEdit)
This default implementation returns false.

Specified by:
addEdit in interface UndoableEdit
Parameters:
anEdit - the edit to be added
Returns:
false
See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)

replaceEdit

public boolean replaceEdit(UndoableEdit anEdit)
This default implementation returns false.

Specified by:
replaceEdit in interface UndoableEdit
Parameters:
anEdit - the edit to replace
Returns:
false
See Also:
UndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit)

isSignificant

public boolean isSignificant()
This default implementation returns true.

Specified by:
isSignificant in interface UndoableEdit
Returns:
true
See Also:
UndoableEdit.isSignificant()

getPresentationName

public java.lang.String getPresentationName()
This default implementation returns "". Subclasses should override to return an appropriate description of the operation this edit represents.

Specified by:
getPresentationName in interface UndoableEdit
Returns:
the empty string ""

toString

public java.lang.String toString()
Returns a string that displays and identifies this object's properties.

Returns:
a String representation of this object

JSR-209 (Final Release)

Java and Java 2D are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Copyright 1993 - 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All Rights Reserved.
Use of this specification is subject to this license.