Class AbstractUndoableEdit

java.lang.Object
javax.swing.undo.AbstractUndoableEdit
All Implemented Interfaces:
Serializable, UndoableEdit
Direct Known Subclasses:
AbstractDocument.ElementEdit, CompoundEdit, DefaultStyledDocument.AttributeUndoableEdit, StateEdit

public class AbstractUndoableEdit extends Object implements UndoableEdit, Serializable
An abstract implementation of UndoableEdit, implementing simple responses to all boolean methods in that interface.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
    protected static final String
    String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an AbstractUndoableEdit which defaults hasBeenDone and alive to true.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    This default implementation returns false.
    boolean
    Returns true if this edit is alive and hasBeenDone is false.
    boolean
    Returns true if this edit is alive and hasBeenDone is true.
    void
    die()
    Sets alive to false.
    This default implementation returns "".
    Retrieves the value from the defaults table with key AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName.
    Retrieves the value from the defaults table with key AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName.
    boolean
    This default implementation returns true.
    void
    Throws CannotRedoException if canRedo returns false.
    boolean
    This default implementation returns false.
    Returns a string that displays and identifies this object's properties.
    void
    Throws CannotUndoException if canUndo returns false.

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • UndoName

      protected static final String UndoName
      String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. This value is now localized and comes from the defaults table with key AbstractUndoableEdit.undoText.
      See Also:
    • RedoName

      protected static final String RedoName
      String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used. This value is now localized and comes from the defaults table with key AbstractUndoableEdit.redoText.
      See Also:
  • Constructor Details

    • AbstractUndoableEdit

      public AbstractUndoableEdit()
      Creates an AbstractUndoableEdit which defaults hasBeenDone and alive to true.
  • Method Details

    • 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, or when it is dequeued from an UndoManager.

      Specified by:
      die in interface UndoableEdit
      See Also:
    • 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

      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: