APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.undo

public Class AbstractUndoableEdit

extends Object
implements UndoableEdit, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.undo.UndoableEdit
Known Direct Subclasses
javax.swing.undo.CompoundEdit, javax.swing.undo.StateEdit, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.GapContent.InsertUndo, javax.swing.text.GapContent.RemoveUndo, javax.swing.text.StringContent.InsertUndo, javax.swing.text.StringContent.RemoveUndo, javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.StyleChangeUndoableEdit
Annotations
@SuppressWarnings:serial
Imports
java.io.Serializable, javax.swing.UIManager

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

Field Summary

Modifier and TypeField and Description
pack-priv boolean
alive

True if this edit has not received die; defaults to true.

pack-priv boolean
hasBeenDone

Defaults to true; becomes false if this edit is undone, true again if it is redone.

protected static final String
RedoName

String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.

protected static final String
UndoName

String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.

Constructor Summary

AccessConstructor and Description
public
AbstractUndoableEdit()

Creates an AbstractUndoableEdit which defaults hasBeenDone and alive to true.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

false
addEdit
(UndoableEdit
the edit to be added
anEdit
)

Implements javax.swing.undo.UndoableEdit.addEdit.

This default implementation returns false.

public boolean

Returns:

true if this edit is alive and hasBeenDone is false
canRedo
()

Implements javax.swing.undo.UndoableEdit.canRedo.

Returns true if this edit is alive and hasBeenDone is false.

public boolean

Returns:

true if this edit is alive and hasBeenDone is true
canUndo
()

Implements javax.swing.undo.UndoableEdit.canUndo.

Returns true if this edit is alive and hasBeenDone is true.

public void
die()

Implements javax.swing.undo.UndoableEdit.die.

Sets alive to false.

public String

Returns:

the empty string ""
getPresentationName
()

Implements javax.swing.undo.UndoableEdit.getPresentationName.

This default implementation returns "".

public String

Returns:

the value from the defaults table with key AbstractUndoableEdit.redoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.
getRedoPresentationName
()

Implements javax.swing.undo.UndoableEdit.getRedoPresentationName.

Retrieves the value from the defaults table with key AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName.

public String

Returns:

the value from the defaults table with key AbstractUndoableEdit.undoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.
getUndoPresentationName
()

Implements javax.swing.undo.UndoableEdit.getUndoPresentationName.

Retrieves the value from the defaults table with key AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName.

public boolean

Returns:

true
isSignificant
()

Implements javax.swing.undo.UndoableEdit.isSignificant.

This default implementation returns true.

public void
redo()

Implements javax.swing.undo.UndoableEdit.redo.

Throws CannotRedoException if canRedo returns false.

public boolean

Returns:

false
replaceEdit
(UndoableEdit
the edit to replace
anEdit
)

Implements javax.swing.undo.UndoableEdit.replaceEdit.

This default implementation returns false.

public String

Returns:

a String representation of this object
toString
()

Overrides java.lang.Object.toString.

Returns a string that displays and identifies this object's properties.

public void
undo()

Implements javax.swing.undo.UndoableEdit.undo.

Throws CannotUndoException if canUndo returns false.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aliveback to summary
pack-priv boolean alive

True if this edit has not received die; defaults to true.

hasBeenDoneback to summary
pack-priv boolean hasBeenDone

Defaults to true; becomes false if this edit is undone, true again if it is redone.

RedoNameback to summary
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
javax.swing.UIDefaults
UndoNameback to summary
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
javax.swing.UIDefaults

Constructor Detail

AbstractUndoableEditback to summary
public AbstractUndoableEdit()

Creates an AbstractUndoableEdit which defaults hasBeenDone and alive to true.

Method Detail

addEditback to summary
public boolean addEdit(UndoableEdit anEdit)

Implements javax.swing.undo.UndoableEdit.addEdit.

This default implementation returns false.

Parameters
anEdit:UndoableEdit

the edit to be added

Returns:boolean

false

See Also
UndoableEdit#addEdit
canRedoback to summary
public boolean canRedo()

Implements javax.swing.undo.UndoableEdit.canRedo.

Returns true if this edit is alive and hasBeenDone is false.

Returns:boolean

true if this edit is alive and hasBeenDone is false

See Also
die, undo, redo
canUndoback to summary
public boolean canUndo()

Implements javax.swing.undo.UndoableEdit.canUndo.

Returns true if this edit is alive and hasBeenDone is true.

Returns:boolean

true if this edit is alive and hasBeenDone is true

See Also
die, undo, redo
dieback to summary
public void die()

Implements javax.swing.undo.UndoableEdit.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.

getPresentationNameback to summary
public String getPresentationName()

Implements javax.swing.undo.UndoableEdit.getPresentationName.

This default implementation returns "". Used by getUndoPresentationName and getRedoPresentationName to construct the strings they return. Subclasses should override to return an appropriate description of the operation this edit represents.

Returns:String

the empty string ""

See Also
getUndoPresentationName, getRedoPresentationName
getRedoPresentationNameback to summary
public String getRedoPresentationName()

Implements javax.swing.undo.UndoableEdit.getRedoPresentationName.

Retrieves the value from the defaults table with key AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

Returns:String

the value from the defaults table with key AbstractUndoableEdit.redoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.

See Also
getPresentationName
getUndoPresentationNameback to summary
public String getUndoPresentationName()

Implements javax.swing.undo.UndoableEdit.getUndoPresentationName.

Retrieves the value from the defaults table with key AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

Returns:String

the value from the defaults table with key AbstractUndoableEdit.undoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.

See Also
getPresentationName
isSignificantback to summary
public boolean isSignificant()

Implements javax.swing.undo.UndoableEdit.isSignificant.

This default implementation returns true.

Returns:boolean

true

See Also
UndoableEdit#isSignificant
redoback to summary
public void redo() throws CannotRedoException

Implements javax.swing.undo.UndoableEdit.redo.

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.

Exceptions
CannotRedoException:
if canRedo returns false
See Also
canRedo
replaceEditback to summary
public boolean replaceEdit(UndoableEdit anEdit)

Implements javax.swing.undo.UndoableEdit.replaceEdit.

This default implementation returns false.

Parameters
anEdit:UndoableEdit

the edit to replace

Returns:boolean

false

See Also
UndoableEdit#replaceEdit
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string that displays and identifies this object's properties.

Returns:String

a String representation of this object

undoback to summary
public void undo() throws CannotUndoException

Implements javax.swing.undo.UndoableEdit.undo.

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.

Exceptions
CannotUndoException:
if canUndo returns false
See Also
canUndo