public class AbstractUndoableEdit extends Object implements UndoableEdit, Serializable
UndoableEdit
,
implementing simple responses to all boolean methods in
that interface.Modifier and Type | Field and Description |
---|---|
protected static String |
RedoName
String returned by
getRedoPresentationName ;
as of Java 2 platform v1.3.1 this field is no longer used. |
protected static String |
UndoName
String returned by
getUndoPresentationName ;
as of Java 2 platform v1.3.1 this field is no longer used. |
Constructor and Description |
---|
AbstractUndoableEdit()
Creates an
AbstractUndoableEdit which defaults
hasBeenDone and alive to true . |
Modifier and Type | Method and Description |
---|---|
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. |
String |
getPresentationName()
This default implementation returns "".
|
String |
getRedoPresentationName()
Retreives the value from the defaults table with key
AbstractUndoableEdit.redoText and returns
that value followed by a space, followed by
getPresentationName . |
String |
getUndoPresentationName()
Retreives the value from the defaults table with key
AbstractUndoableEdit.undoText and returns
that value followed by a space, followed by
getPresentationName . |
boolean |
isSignificant()
This default implementation returns true.
|
void |
redo()
Throws
CannotRedoException if canRedo
returns false. |
boolean |
replaceEdit(UndoableEdit anEdit)
This default implementation returns false.
|
String |
toString()
Returns a string that displays and identifies this
object's properties.
|
void |
undo()
Throws
CannotUndoException if canUndo
returns false . |
protected static final String UndoName
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
.UIDefaults
,
Constant Field Valuesprotected static final String RedoName
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
.UIDefaults
,
Constant Field Valuespublic AbstractUndoableEdit()
AbstractUndoableEdit
which defaults
hasBeenDone
and alive
to true
.public void die()
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
.
die
in interface UndoableEdit
CompoundEdit.die()
public void undo() throws CannotUndoException
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.undo
in interface UndoableEdit
CannotUndoException
- if canUndo
returns false
canUndo()
public boolean canUndo()
alive
and hasBeenDone
is true
.canUndo
in interface UndoableEdit
alive
and hasBeenDone
is true
die()
,
undo()
,
redo()
public void redo() throws CannotRedoException
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.redo
in interface UndoableEdit
CannotRedoException
- if canRedo
returns false
canRedo()
public boolean canRedo()
true
if this edit is alive
and hasBeenDone
is false
.canRedo
in interface UndoableEdit
true
if this edit is alive
and hasBeenDone
is false
die()
,
undo()
,
redo()
public boolean addEdit(UndoableEdit anEdit)
addEdit
in interface UndoableEdit
anEdit
- the edit to be addedUndoableEdit.addEdit(javax.swing.undo.UndoableEdit)
public boolean replaceEdit(UndoableEdit anEdit)
replaceEdit
in interface UndoableEdit
anEdit
- the edit to replaceUndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit)
public boolean isSignificant()
isSignificant
in interface UndoableEdit
UndoableEdit.isSignificant()
public String getPresentationName()
getUndoPresentationName
and
getRedoPresentationName
to
construct the strings they return. Subclasses should override to
return an appropriate description of the operation this edit
represents.getPresentationName
in interface UndoableEdit
getUndoPresentationName()
,
getRedoPresentationName()
public String getUndoPresentationName()
AbstractUndoableEdit.undoText
and returns
that value followed by a space, followed by
getPresentationName
.
If getPresentationName
returns "",
then the defaults value is returned alone.getUndoPresentationName
in interface UndoableEdit
AbstractUndoableEdit.undoText
, followed
by a space, followed by getPresentationName
unless getPresentationName
is "" in which
case, the defaults value is returned alone.getPresentationName()
public String getRedoPresentationName()
AbstractUndoableEdit.redoText
and returns
that value followed by a space, followed by
getPresentationName
.
If getPresentationName
returns "",
then the defaults value is returned alone.getRedoPresentationName
in interface UndoableEdit
AbstractUndoableEdit.redoText
, followed
by a space, followed by getPresentationName
unless getPresentationName
is "" in which
case, the defaults value is returned alone.getPresentationName()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2022, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.