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
ConstructorsConstructorDescriptionDocumentUndoManager(IDocument document) Create a DocumentUndoManager for the given document. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDocumentUndoListener(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.voidSignals the undo manager that all subsequent changes untilendCompoundChangeis called are to be undone in one piece.voidcommit()Closes the currently open text edit and open a new one.voidConnects to the undo manager.voiddisconnect(Object client) Disconnects from the undo manager.voidSignals the undo manager that the sequence of changes which started withbeginCompoundChangehas been finished.Returns the undo context registered for this documentvoidredo()Repeats the most recently rolled back text change.booleanredoable()Returns whether at least one text change can be repeated.voidRemoves the specified listener from the list of document undo listeners.voidreset()Resets the history of the undo manager.voidsetMaximalUndoLevel(int undoLimit) Sets the limit of the undo history to the specified value.voidtransferUndoHistory(IDocumentUndoManager manager) Transfers the undo history from the specified document undo manager to this undo manager.voidundo()Rolls back the most recently executed text change.booleanundoable()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:IDocumentUndoManagerAdds 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:
addDocumentUndoListenerin interfaceIDocumentUndoManager- Parameters:
listener- the document undo listener to be added as a listener
-
removeDocumentUndoListener
Description copied from interface:IDocumentUndoManagerRemoves the specified listener from the list of document undo listeners.Removing a listener which is not registered has no effect
- Specified by:
removeDocumentUndoListenerin interfaceIDocumentUndoManager- Parameters:
listener- the document undo listener to be removed
-
getUndoContext
Description copied from interface:IDocumentUndoManagerReturns the undo context registered for this document- Specified by:
getUndoContextin interfaceIDocumentUndoManager- Returns:
- the undo context registered for this document
-
commit
public void commit()Description copied from interface:IDocumentUndoManagerCloses the currently open text edit and open a new one.- Specified by:
commitin interfaceIDocumentUndoManager
-
reset
public void reset()Description copied from interface:IDocumentUndoManagerResets the history of the undo manager. After that call, there aren't any undo-able or redo-able text changes.- Specified by:
resetin interfaceIDocumentUndoManager
-
redoable
public boolean redoable()Description copied from interface:IDocumentUndoManagerReturns 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:
redoablein interfaceIDocumentUndoManager- Returns:
trueif at least on text change can be repeated
-
undoable
public boolean undoable()Description copied from interface:IDocumentUndoManagerReturns whether at least one text change can be rolled back.- Specified by:
undoablein interfaceIDocumentUndoManager- Returns:
trueif at least one text change can be rolled back
-
redo
Description copied from interface:IDocumentUndoManagerRepeats the most recently rolled back text change.- Specified by:
redoin interfaceIDocumentUndoManager- Throws:
ExecutionException- if an exception occurred during redo
-
undo
Description copied from interface:IDocumentUndoManagerRolls back the most recently executed text change.- Specified by:
undoin interfaceIDocumentUndoManager- Throws:
ExecutionException- if an exception occurred during undo
-
connect
Description copied from interface:IDocumentUndoManagerConnects 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:
connectin interfaceIDocumentUndoManager- Parameters:
client- the object connecting to the undo manager
-
disconnect
Description copied from interface:IDocumentUndoManagerDisconnects 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:
disconnectin interfaceIDocumentUndoManager- Parameters:
client- the object disconnecting from the undo manager
-
beginCompoundChange
public void beginCompoundChange()Description copied from interface:IDocumentUndoManagerSignals the undo manager that all subsequent changes untilendCompoundChangeis called are to be undone in one piece.- Specified by:
beginCompoundChangein interfaceIDocumentUndoManager
-
endCompoundChange
public void endCompoundChange()Description copied from interface:IDocumentUndoManagerSignals the undo manager that the sequence of changes which started withbeginCompoundChangehas been finished. All subsequent changes are considered to be individually undo-able.- Specified by:
endCompoundChangein interfaceIDocumentUndoManager
-
setMaximalUndoLevel
public void setMaximalUndoLevel(int undoLimit) Description copied from interface:IDocumentUndoManagerSets the limit of the undo history to the specified value. The provided limit will supersede any previously set limit.- Specified by:
setMaximalUndoLevelin interfaceIDocumentUndoManager- Parameters:
undoLimit- the length of this undo manager's history
-
transferUndoHistory
Description copied from interface:IDocumentUndoManagerTransfers 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:
transferUndoHistoryin interfaceIDocumentUndoManager- Parameters:
manager- the document undo manger whose history is to be transferred to the receiver
-