Package org.eclipse.jface.text

# Class DefaultUndoManager

java.lang.Object
org.eclipse.jface.text.DefaultUndoManager

All Implemented Interfaces:
  `IUndoManager`, `IUndoManagerExtension`

@Deprecated(forRemoval=true, since="2025-03") public class DefaultUndoManager extends Object implements IUndoManager, IUndoManagerExtension
Deprecated, for removal: This API element is subject to removal in a future version.
As of 3.2, replaced by `TextViewerUndoManager`
Standard implementation of `IUndoManager`.

It registers with the connected text viewer as text input listener and document listener and logs all changes. It also monitors mouse and keyboard activities in order to partition the stream of text changes into undo-able edit commands.

Since 3.1 this undo manager is a facade to the global operation history.

The usage of `IAdaptable` in the JFace layer has been approved by Platform UI, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=87669#c9

This class is not intended to be subclassed.

See Also:
  - `ITextViewer`
  - `ITextInputListener`
  - `IDocumentListener`
  - `IUndoableOperation`
  - `IOperationHistory`
  - `MouseListener`
  - `KeyListener`
Restriction:
  This class is not intended to be subclassed by clients.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected long`
`fPreservedRedoModificationStamp`
Deprecated, for removal: This API element is subject to removal in a future version.
The document modification stamp for redo.
`protected long`
`fPreservedUndoModificationStamp`
Deprecated, for removal: This API element is subject to removal in a future version.
The document modification stamp for undo.

## Constructor Summary

Constructors
Constructor
Description
`DefaultUndoManager(int undoLevel)`
Deprecated, for removal: This API element is subject to removal in a future version.
Creates a new undo manager who remembers the specified number of edit commands.

## Method Summary

Modifier and Type
Method
Description
`void`
`beginCompoundChange()`
Deprecated, for removal: This API element is subject to removal in a future version.
Signals the undo manager that all subsequent changes until `endCompoundChange` is called are to be undone in one piece.
`void`
`connect(ITextViewer textViewer)`
Deprecated, for removal: This API element is subject to removal in a future version.
Connects this undo manager to the given text viewer.
`void`
`disconnect()`
Deprecated, for removal: This API element is subject to removal in a future version.
Disconnects this undo manager from its text viewer.
`void`
`endCompoundChange()`
Deprecated, for removal: This API element is subject to removal in a future version.
Signals the undo manager that the sequence of changes which started with `beginCompoundChange` has been finished.
`IUndoContext`
`getUndoContext()`
Deprecated, for removal: This API element is subject to removal in a future version.
Returns this undo manager's undo context.
`void`
`redo()`
Deprecated, for removal: This API element is subject to removal in a future version.
Repeats the most recently rolled back text change.
`boolean`
`redoable()`
Deprecated, for removal: This API element is subject to removal in a future version.
Returns whether at least one text change can be repeated.
`void`
`reset()`
Deprecated, for removal: This API element is subject to removal in a future version.
Resets the history of the undo manager.
`protected void`
`selectAndReveal(int offset, int length)`
Deprecated, for removal: This API element is subject to removal in a future version.
Selects and reveals the specified range.
`void`
`setMaximalUndoLevel(int undoLevel)`
Deprecated, for removal: This API element is subject to removal in a future version.
The given parameter determines the maximal length of the history remembered by the undo manager.
`void`
`undo()`
Deprecated, for removal: This API element is subject to removal in a future version.
Rolls back the most recently executed text change.
`boolean`
`undoable()`
Deprecated, for removal: This API element is subject to removal in a future version.
Returns whether at least one text change can be rolled back.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### fPreservedUndoModificationStamp

protected long fPreservedUndoModificationStamp
Deprecated, for removal: This API element is subject to removal in a future version.
The document modification stamp for undo.

### fPreservedRedoModificationStamp

protected long fPreservedRedoModificationStamp
Deprecated, for removal: This API element is subject to removal in a future version.
The document modification stamp for redo.

## Constructor Details

### DefaultUndoManager

public DefaultUndoManager(int undoLevel)
Deprecated, for removal: This API element is subject to removal in a future version.
Creates a new undo manager who remembers the specified number of edit commands.

Parameters:
  `undoLevel` - the length of this manager's history

## Method Details

### beginCompoundChange

public void beginCompoundChange()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Signals the undo manager that all subsequent changes until `endCompoundChange` is called are to be undone in one piece.

Specified by:
  `beginCompoundChange` in interface `IUndoManager`

### endCompoundChange

public void endCompoundChange()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Signals the undo manager that the sequence of changes which started with `beginCompoundChange` has been finished. All subsequent changes are considered to be individually undo-able.

Specified by:
  `endCompoundChange` in interface `IUndoManager`

### setMaximalUndoLevel

public void setMaximalUndoLevel(int undoLevel)
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
The given parameter determines the maximal length of the history remembered by the undo manager.

Specified by:
  `setMaximalUndoLevel` in interface `IUndoManager`
Parameters:
  `undoLevel` - the length of this undo manager's history

### connect

public void connect(ITextViewer textViewer)
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Connects this undo manager to the given text viewer.

Specified by:
  `connect` in interface `IUndoManager`
Parameters:
  `textViewer` - the viewer the undo manager is connected to

### disconnect

public void disconnect()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Disconnects this undo manager from its text viewer. If this undo manager hasn't been connected before this operation has no effect.

Specified by:
  `disconnect` in interface `IUndoManager`

### reset

public void reset()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
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 interface `IUndoManager`

### redoable

public boolean redoable()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
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 interface `IUndoManager`
Returns:
  `true` if at least on text change can be repeated

### undoable

public boolean undoable()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Returns whether at least one text change can be rolled back.

Specified by:
  `undoable` in interface `IUndoManager`
Returns:
  `true` if at least one text change can be rolled back

### redo

public void redo()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Repeats the most recently rolled back text change.

Specified by:
  `redo` in interface `IUndoManager`

### undo

public void undo()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManager`
Rolls back the most recently executed text change.

Specified by:
  `undo` in interface `IUndoManager`

### selectAndReveal

protected void selectAndReveal(int offset, int length)
Deprecated, for removal: This API element is subject to removal in a future version.
Selects and reveals the specified range.

Parameters:
  `offset` - the offset of the range
  `length` - the length of the range
Since:
  3.0

### getUndoContext

public IUndoContext getUndoContext()
Deprecated, for removal: This API element is subject to removal in a future version.
Description copied from interface: `IUndoManagerExtension`
Returns this undo manager's undo context.

Specified by:
  `getUndoContext` in interface `IUndoManagerExtension`
Returns:
  the undo context or `null` if the undo manager is not connected
See Also:
  - `IUndoContext`