- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.undo.CompoundEdit
-
- All Implemented Interfaces:
- Serializable, UndoableEdit
- Direct Known Subclasses:
- AbstractDocument.DefaultDocumentEvent, UndoManager
public class CompoundEdit extends AbstractUndoableEdit
A concrete subclass of AbstractUndoableEdit, used to assemble little UndoableEdits into great big ones.
-
-
Field Summary
Fields Modifier and Type Field and Description protected Vector<UndoableEdit>
edits
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
Constructor Summary
Constructors Constructor and Description CompoundEdit()
-
Method Summary
Methods Modifier and Type Method and Description boolean
addEdit(UndoableEdit anEdit)
If this edit isinProgress
, acceptsanEdit
and returns true.boolean
canRedo()
Returns false ifisInProgress
or if super returns false.boolean
canUndo()
Returns false ifisInProgress
or if super returns false.void
die()
Sendsdie
to each subedit, in the reverse of the order that they were added.void
end()
SetsinProgress
to false.String
getPresentationName()
ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
.String
getRedoPresentationName()
ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
.String
getUndoPresentationName()
ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
.boolean
isInProgress()
Returns true if this edit is in progress--that is, it has not received end.boolean
isSignificant()
Returns true if any of theUndoableEdit
s inedits
do.protected UndoableEdit
lastEdit()
Returns the lastUndoableEdit
inedits
, ornull
ifedits
is empty.void
redo()
Sendsredo
to all containedUndoableEdit
s in the order in which they were added.String
toString()
Returns a string that displays and identifies this object's properties.void
undo()
Sendsundo
to all containedUndoableEdits
in the reverse of the order in which they were added.-
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
-
-
-
Field Detail
-
edits
protected Vector<UndoableEdit> edits
The collection ofUndoableEdit
s undone/redone en masse by thisCompoundEdit
.
-
-
Method Detail
-
undo
public void undo() throws CannotUndoException
Sendsundo
to all containedUndoableEdits
in the reverse of the order in which they were added.- Specified by:
undo
in interfaceUndoableEdit
- Overrides:
undo
in classAbstractUndoableEdit
- Throws:
CannotUndoException
- ifcanUndo
returnsfalse
- See Also:
AbstractUndoableEdit.canUndo()
-
redo
public void redo() throws CannotRedoException
Sendsredo
to all containedUndoableEdit
s in the order in which they were added.- Specified by:
redo
in interfaceUndoableEdit
- Overrides:
redo
in classAbstractUndoableEdit
- Throws:
CannotRedoException
- ifcanRedo
returnsfalse
- See Also:
AbstractUndoableEdit.canRedo()
-
lastEdit
protected UndoableEdit lastEdit()
Returns the lastUndoableEdit
inedits
, ornull
ifedits
is empty.
-
die
public void die()
Sendsdie
to each subedit, in the reverse of the order that they were added.- Specified by:
die
in interfaceUndoableEdit
- Overrides:
die
in classAbstractUndoableEdit
- See Also:
die()
-
addEdit
public boolean addEdit(UndoableEdit anEdit)
If this edit isinProgress
, acceptsanEdit
and returns true.The last edit added to this
CompoundEdit
is given a chance toaddEdit(anEdit)
. If it refuses (returns false),anEdit
is given a chance toreplaceEdit
the last edit. IfanEdit
returns false here, it is added toedits
.- Specified by:
addEdit
in interfaceUndoableEdit
- Overrides:
addEdit
in classAbstractUndoableEdit
- Parameters:
anEdit
- the edit to be added- Returns:
- true if the edit is
inProgress
; otherwise returns false - See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)
-
canUndo
public boolean canUndo()
Returns false ifisInProgress
or if super returns false.- Specified by:
canUndo
in interfaceUndoableEdit
- Overrides:
canUndo
in classAbstractUndoableEdit
- Returns:
- true if this edit is
alive
andhasBeenDone
istrue
- See Also:
isInProgress()
-
canRedo
public boolean canRedo()
Returns false ifisInProgress
or if super returns false.- Specified by:
canRedo
in interfaceUndoableEdit
- Overrides:
canRedo
in classAbstractUndoableEdit
- Returns:
true
if this edit isalive
andhasBeenDone
isfalse
- See Also:
isInProgress()
-
isInProgress
public boolean isInProgress()
Returns true if this edit is in progress--that is, it has not received end. This generally means that edits are still being added to it.- See Also:
end()
-
isSignificant
public boolean isSignificant()
Returns true if any of theUndoableEdit
s inedits
do. Returns false if they all return false.- Specified by:
isSignificant
in interfaceUndoableEdit
- Overrides:
isSignificant
in classAbstractUndoableEdit
- Returns:
- true
- See Also:
UndoableEdit.isSignificant()
-
getPresentationName
public String getPresentationName()
ReturnsgetPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getPresentationName
in interfaceUndoableEdit
- Overrides:
getPresentationName
in classAbstractUndoableEdit
- Returns:
- the empty string ""
- See Also:
AbstractUndoableEdit.getUndoPresentationName()
,AbstractUndoableEdit.getRedoPresentationName()
-
getUndoPresentationName
public String getUndoPresentationName()
ReturnsgetUndoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getUndoPresentationName
in interfaceUndoableEdit
- Overrides:
getUndoPresentationName
in classAbstractUndoableEdit
- 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:
AbstractUndoableEdit.getPresentationName()
-
getRedoPresentationName
public String getRedoPresentationName()
ReturnsgetRedoPresentationName
from the lastUndoableEdit
added toedits
. Ifedits
is empty, calls super.- Specified by:
getRedoPresentationName
in interfaceUndoableEdit
- Overrides:
getRedoPresentationName
in classAbstractUndoableEdit
- 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:
AbstractUndoableEdit.getPresentationName()
-
toString
public String toString()
Returns a string that displays and identifies this object's properties.- Overrides:
toString
in classAbstractUndoableEdit
- Returns:
- a String representation of this object
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/11/2024 21:39:05 Cette version de la page est en cache (à la date du 21/11/2024 21:39:05) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/undo/compoundedit.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.