java.lang.Object
javax.swing.undo.AbstractUndoableEdit
- All Implemented Interfaces:
Serializable
,UndoableEdit
- Direct Known Subclasses:
AbstractDocument.ElementEdit
,CompoundEdit
,DefaultStyledDocument.AttributeUndoableEdit
,StateEdit
An abstract implementation of
UndoableEdit
,
implementing simple responses to all boolean methods in
that interface.-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
String returned bygetRedoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used.protected static final String
String returned bygetUndoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used. -
Constructor Summary
ConstructorDescriptionCreates anAbstractUndoableEdit
which defaultshasBeenDone
andalive
totrue
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEdit
(UndoableEdit anEdit) This default implementation returns false.boolean
canRedo()
Returnstrue
if this edit isalive
andhasBeenDone
isfalse
.boolean
canUndo()
Returns true if this edit isalive
andhasBeenDone
istrue
.void
die()
Setsalive
to false.This default implementation returns "".Retrieves the value from the defaults table with keyAbstractUndoableEdit.redoText
and returns that value followed by a space, followed bygetPresentationName
.Retrieves the value from the defaults table with keyAbstractUndoableEdit.undoText
and returns that value followed by a space, followed bygetPresentationName
.boolean
This default implementation returns true.void
redo()
ThrowsCannotRedoException
ifcanRedo
returns false.boolean
replaceEdit
(UndoableEdit anEdit) This default implementation returns false.toString()
Returns a string that displays and identifies this object's properties.void
undo()
ThrowsCannotUndoException
ifcanUndo
returnsfalse
.
-
Field Details
-
UndoName
String returned bygetUndoPresentationName
; 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 keyAbstractUndoableEdit.undoText
.- See Also:
-
RedoName
String returned bygetRedoPresentationName
; 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 keyAbstractUndoableEdit.redoText
.- See Also:
-
-
Constructor Details
-
AbstractUndoableEdit
public AbstractUndoableEdit()Creates anAbstractUndoableEdit
which defaultshasBeenDone
andalive
totrue
.
-
-
Method Details
-
die
public void die()Setsalive
to false. Note that this is a one way operation; dead edits cannot be resurrected. Sendingundo
orredo
to a dead edit results in an exception being thrown.Typically an edit is killed when it is consolidated by another edit's
addEdit
orreplaceEdit
method, or when it is dequeued from anUndoManager
.- Specified by:
die
in interfaceUndoableEdit
- See Also:
-
undo
ThrowsCannotUndoException
ifcanUndo
returnsfalse
. SetshasBeenDone
tofalse
. Subclasses should override to undo the operation represented by this edit. Override should begin with a call to super.- Specified by:
undo
in interfaceUndoableEdit
- Throws:
CannotUndoException
- ifcanUndo
returnsfalse
- See Also:
-
canUndo
public boolean canUndo()Returns true if this edit isalive
andhasBeenDone
istrue
.- Specified by:
canUndo
in interfaceUndoableEdit
- Returns:
- true if this edit is
alive
andhasBeenDone
istrue
- See Also:
-
redo
ThrowsCannotRedoException
ifcanRedo
returns false. SetshasBeenDone
totrue
. Subclasses should override to redo the operation represented by this edit. Override should begin with a call to super.- Specified by:
redo
in interfaceUndoableEdit
- Throws:
CannotRedoException
- ifcanRedo
returnsfalse
- See Also:
-
canRedo
public boolean canRedo()Returnstrue
if this edit isalive
andhasBeenDone
isfalse
.- Specified by:
canRedo
in interfaceUndoableEdit
- Returns:
true
if this edit isalive
andhasBeenDone
isfalse
- See Also:
-
addEdit
This default implementation returns false.- Specified by:
addEdit
in interfaceUndoableEdit
- Parameters:
anEdit
- the edit to be added- Returns:
- false
- See Also:
-
replaceEdit
This default implementation returns false.- Specified by:
replaceEdit
in interfaceUndoableEdit
- Parameters:
anEdit
- the edit to replace- Returns:
- false
- See Also:
-
isSignificant
public boolean isSignificant()This default implementation returns true.- Specified by:
isSignificant
in interfaceUndoableEdit
- Returns:
- true
- See Also:
-
getPresentationName
This default implementation returns "". Used bygetUndoPresentationName
andgetRedoPresentationName
to construct the strings they return. Subclasses should override to return an appropriate description of the operation this edit represents.- Specified by:
getPresentationName
in interfaceUndoableEdit
- Returns:
- the empty string ""
- See Also:
-
getUndoPresentationName
Retrieves the value from the defaults table with keyAbstractUndoableEdit.undoText
and returns that value followed by a space, followed bygetPresentationName
. IfgetPresentationName
returns "", then the defaults value is returned alone.- Specified by:
getUndoPresentationName
in interfaceUndoableEdit
- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.undoText
, followed by a space, followed bygetPresentationName
unlessgetPresentationName
is "" in which case, the defaults value is returned alone. - See Also:
-
getRedoPresentationName
Retrieves the value from the defaults table with keyAbstractUndoableEdit.redoText
and returns that value followed by a space, followed bygetPresentationName
. IfgetPresentationName
returns "", then the defaults value is returned alone.- Specified by:
getRedoPresentationName
in interfaceUndoableEdit
- Returns:
- the value from the defaults table with key
AbstractUndoableEdit.redoText
, followed by a space, followed bygetPresentationName
unlessgetPresentationName
is "" in which case, the defaults value is returned alone. - See Also:
-
toString
-