Interface IDocumentUndoManager
- All Known Implementing Classes:
DocumentUndoManager
Clients must explicitly connect to the undo manager to express their interest in the undo history. Clients should disconnect from the undo manager when they are no longer interested in tracking the undo history. If there are no clients connected to the undo manager, it will not track the document's changes and will dispose of any history that was previously kept.
Clients may also listen to the undo manager for notifications before and after undo or redo events are performed. Clients must connect to the undo manager in addition to registering listeners.
Clients may implement this interface.
- Since:
- 3.2
- See Also:
-
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.
-
Method Details
-
addDocumentUndoListener
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.
- Parameters:
listener
- the document undo listener to be added as a listener
-
removeDocumentUndoListener
Removes the specified listener from the list of document undo listeners.Removing a listener which is not registered has no effect
- Parameters:
listener
- the document undo listener to be removed
-
getUndoContext
IUndoContext getUndoContext()Returns the undo context registered for this document- Returns:
- the undo context registered for this document
-
commit
void commit()Closes the currently open text edit and open a new one. -
connect
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.- Parameters:
client
- the object connecting to the undo manager
-
disconnect
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.- Parameters:
client
- the object disconnecting from the undo manager
-
beginCompoundChange
void beginCompoundChange()Signals the undo manager that all subsequent changes untilendCompoundChange
is called are to be undone in one piece. -
endCompoundChange
void endCompoundChange()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. -
setMaximalUndoLevel
void setMaximalUndoLevel(int undoLimit) Sets the limit of the undo history to the specified value. The provided limit will supersede any previously set limit.- Parameters:
undoLimit
- the length of this undo manager's history
-
reset
void reset()Resets the history of the undo manager. After that call, there aren't any undo-able or redo-able text changes. -
undoable
boolean undoable()Returns whether at least one text change can be rolled back.- Returns:
true
if at least one text change can be rolled back
-
redoable
boolean redoable()Returns whether at least one text change can be repeated. A text change can be repeated only if it was executed and rolled back.- Returns:
true
if at least on text change can be repeated
-
undo
Rolls back the most recently executed text change.- Throws:
ExecutionException
- if an exception occurred during undo
-
redo
Repeats the most recently rolled back text change.- Throws:
ExecutionException
- if an exception occurred during redo
-
transferUndoHistory
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.- Parameters:
manager
- the document undo manger whose history is to be transferred to the receiver
-