Class DocumentUndoManager
- All Implemented Interfaces:
IDocumentUndoManager
Based on the 3.1 implementation of DefaultUndoManager, it was implemented using the document-related manipulations defined in the original DefaultUndoManager, by separating the document manipulations from the viewer-specific processing.
The classes representing individual text edits (formerly text commands) were promoted from inner types to their own classes in order to support reassignment to a different undo manager.
This class is not intended to be subclassed.
- Since:
- 3.2
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
ConstructorDescriptionDocumentUndoManager
(IDocument document) Create a DocumentUndoManager for the given document. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDocumentUndoListener
(IDocumentUndoListener listener) Adds the specified listener to the list of document undo listeners that are notified before and after changes are undone or redone in the document.void
Signals the undo manager that all subsequent changes untilendCompoundChange
is called are to be undone in one piece.void
commit()
Closes the currently open text edit and open a new one.void
Connects to the undo manager.void
disconnect
(Object client) Disconnects from the undo manager.void
Signals the undo manager that the sequence of changes which started withbeginCompoundChange
has been finished.Returns the undo context registered for this documentvoid
redo()
Repeats the most recently rolled back text change.boolean
redoable()
Returns whether at least one text change can be repeated.void
Removes the specified listener from the list of document undo listeners.void
reset()
Resets the history of the undo manager.void
setMaximalUndoLevel
(int undoLimit) Sets the limit of the undo history to the specified value.void
transferUndoHistory
(IDocumentUndoManager manager) Transfers the undo history from the specified document undo manager to this undo manager.void
undo()
Rolls back the most recently executed text change.boolean
undoable()
Returns whether at least one text change can be rolled back.
-
Constructor Details
-
DocumentUndoManager
Create a DocumentUndoManager for the given document.- Parameters:
document
- the document whose undo history is being managed.
-
-
Method Details
-
addDocumentUndoListener
Description copied from interface:IDocumentUndoManager
Adds the specified listener to the list of document undo listeners that are notified before and after changes are undone or redone in the document. This method has no effect if the instance being added is already in the list.Notifications will not be received if there are no clients connected to the receiver. Registering a document undo listener does not implicitly connect the listener to the receiver.
Document undo listeners must be prepared to receive notifications from a background thread. Any UI access occurring inside the implementation must be properly synchronized using the techniques specified by the client's widget library.
- Specified by:
addDocumentUndoListener
in interfaceIDocumentUndoManager
- Parameters:
listener
- the document undo listener to be added as a listener
-
removeDocumentUndoListener
Description copied from interface:IDocumentUndoManager
Removes the specified listener from the list of document undo listeners.Removing a listener which is not registered has no effect
- Specified by:
removeDocumentUndoListener
in interfaceIDocumentUndoManager
- Parameters:
listener
- the document undo listener to be removed
-
getUndoContext
Description copied from interface:IDocumentUndoManager
Returns the undo context registered for this document- Specified by:
getUndoContext
in interfaceIDocumentUndoManager
- Returns:
- the undo context registered for this document
-
commit
public void commit()Description copied from interface:IDocumentUndoManager
Closes the currently open text edit and open a new one.- Specified by:
commit
in interfaceIDocumentUndoManager
-
reset
public void reset()Description copied from interface:IDocumentUndoManager
Resets the history of the undo manager. After that call, there aren't any undo-able or redo-able text changes.- Specified by:
reset
in interfaceIDocumentUndoManager
-
redoable
public boolean redoable()Description copied from interface:IDocumentUndoManager
Returns whether at least one text change can be repeated. A text change can be repeated only if it was executed and rolled back.- Specified by:
redoable
in interfaceIDocumentUndoManager
- Returns:
true
if at least on text change can be repeated
-
undoable
public boolean undoable()Description copied from interface:IDocumentUndoManager
Returns whether at least one text change can be rolled back.- Specified by:
undoable
in interfaceIDocumentUndoManager
- Returns:
true
if at least one text change can be rolled back
-
redo
Description copied from interface:IDocumentUndoManager
Repeats the most recently rolled back text change.- Specified by:
redo
in interfaceIDocumentUndoManager
- Throws:
ExecutionException
- if an exception occurred during redo
-
undo
Description copied from interface:IDocumentUndoManager
Rolls back the most recently executed text change.- Specified by:
undo
in interfaceIDocumentUndoManager
- Throws:
ExecutionException
- if an exception occurred during undo
-
connect
Description copied from interface:IDocumentUndoManager
Connects to the undo manager. Used to signify that a client is monitoring the history kept by the undo manager. This message has no effect if the client is already connected.- Specified by:
connect
in interfaceIDocumentUndoManager
- Parameters:
client
- the object connecting to the undo manager
-
disconnect
Description copied from interface:IDocumentUndoManager
Disconnects from the undo manager. Used to signify that a client is no longer monitoring the history kept by the undo manager. If all clients have disconnected from the undo manager, the undo history will be deleted.- Specified by:
disconnect
in interfaceIDocumentUndoManager
- Parameters:
client
- the object disconnecting from the undo manager
-
beginCompoundChange
public void beginCompoundChange()Description copied from interface:IDocumentUndoManager
Signals the undo manager that all subsequent changes untilendCompoundChange
is called are to be undone in one piece.- Specified by:
beginCompoundChange
in interfaceIDocumentUndoManager
-
endCompoundChange
public void endCompoundChange()Description copied from interface:IDocumentUndoManager
Signals the undo manager that the sequence of changes which started withbeginCompoundChange
has been finished. All subsequent changes are considered to be individually undo-able.- Specified by:
endCompoundChange
in interfaceIDocumentUndoManager
-
setMaximalUndoLevel
public void setMaximalUndoLevel(int undoLimit) Description copied from interface:IDocumentUndoManager
Sets the limit of the undo history to the specified value. The provided limit will supersede any previously set limit.- Specified by:
setMaximalUndoLevel
in interfaceIDocumentUndoManager
- Parameters:
undoLimit
- the length of this undo manager's history
-
transferUndoHistory
Description copied from interface:IDocumentUndoManager
Transfers the undo history from the specified document undo manager to this undo manager. This message should only be used when it is known that the content of the document of the original undo manager when the last undo operation was recorded is the same as this undo manager's current document content, since the undo history is based on document indexes. It is the responsibility of the caller to ensure that this call is used correctly.- Specified by:
transferUndoHistory
in interfaceIDocumentUndoManager
- Parameters:
manager
- the document undo manger whose history is to be transferred to the receiver
-