- 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 ofUndoableEdit
, implementing simple responses to all boolean methods in that interface.
-
-
Field Summary
Fields Modifier and Type Field and Description protected static String
RedoName
String returned bygetRedoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used.protected static String
UndoName
String returned bygetUndoPresentationName
; as of Java 2 platform v1.3.1 this field is no longer used.
-
Constructor Summary
Constructors Constructor and Description AbstractUndoableEdit()
Creates anAbstractUndoableEdit
which defaultshasBeenDone
andalive
totrue
.
-
Method Summary
Methods Modifier and Type Method and Description boolean
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.String
getPresentationName()
This default implementation returns "".String
getRedoPresentationName()
Retreives the value from the defaults table with keyAbstractUndoableEdit.redoText
and returns that value followed by a space, followed bygetPresentationName
.String
getUndoPresentationName()
Retreives the value from the defaults table with keyAbstractUndoableEdit.undoText
and returns that value followed by a space, followed bygetPresentationName
.boolean
isSignificant()
This default implementation returns true.void
redo()
ThrowsCannotRedoException
ifcanRedo
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()
ThrowsCannotUndoException
ifcanUndo
returnsfalse
.
-
-
-
Field Detail
-
UndoName
protected static final String 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:
UIDefaults
, Constant Field Values
-
RedoName
protected static final String 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:
UIDefaults
, Constant Field Values
-
-
Constructor Detail
-
AbstractUndoableEdit
public AbstractUndoableEdit()
Creates anAbstractUndoableEdit
which defaultshasBeenDone
andalive
totrue
.
-
-
Method Detail
-
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:
CompoundEdit.die()
-
undo
public void undo() throws CannotUndoException
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()
-
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:
die()
,undo()
,redo()
-
redo
public void redo() throws CannotRedoException
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()
-
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:
die()
,undo()
,redo()
-
addEdit
public boolean addEdit(UndoableEdit anEdit)
This default implementation returns false.- Specified by:
addEdit
in interfaceUndoableEdit
- 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 interfaceUndoableEdit
- 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 interfaceUndoableEdit
- Returns:
- true
- See Also:
UndoableEdit.isSignificant()
-
getPresentationName
public String 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()
,getRedoPresentationName()
-
getUndoPresentationName
public String getUndoPresentationName()
Retreives 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:
getPresentationName()
-
getRedoPresentationName
public String getRedoPresentationName()
Retreives 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:
getPresentationName()
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/undo/abstractundoableedit.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.