public class UndoBuffer
extends java.lang.Object
UndoBuffer implements a storage for undo operations. Stored undo operations are grouped by a special marker-operations, also stored into the buffer. Marker-operation is added to the buffer after real operations. Undoing processes all undo-operations till next marker-operation.
UndoBuffer contains a redo-buffer also. Undoed operations are stored in redo-buffer until next operation is stored into the undo-buffer.
Undo-buffer's size is limited to MAX_BUFFER_SIZE
operations.
Undo-buffer removes marked sets of operations until the number of operations
is below MAX_BUFFER_SIZE
.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_BUFFER_SIZE |
private java.util.LinkedList<UndoOperation> |
redobuffer |
static boolean |
SHOW_MESSAGE |
static boolean |
SKIP_EMPTY_OPERATIONS |
static boolean |
SKIP_OPERATIONS_TILL_NEXT_MARKER |
private java.util.LinkedList<UndoOperation> |
undobuffer |
Constructor and Description |
---|
UndoBuffer() |
Modifier and Type | Method and Description |
---|---|
void |
addMarker(java.lang.String label) |
void |
addMarker(java.lang.String undoLabel,
java.lang.String redoLabel) |
void |
addOperation(UndoOperation op) |
boolean |
canRedo() |
boolean |
canUndo() |
void |
clear() |
java.util.Collection<UndoOperation> |
getOperations() |
int |
getRedoOperationNumber() |
int |
getUndoOperationNumber() |
void |
pruneOne() |
void |
redo() |
private void |
redoOne() |
void |
setSkipEmptyOperations(boolean s) |
void |
undo() |
private void |
undoOne() |
public static boolean SKIP_EMPTY_OPERATIONS
public static boolean SHOW_MESSAGE
public static final int MAX_BUFFER_SIZE
public static boolean SKIP_OPERATIONS_TILL_NEXT_MARKER
private java.util.LinkedList<UndoOperation> undobuffer
private java.util.LinkedList<UndoOperation> redobuffer
public void clear()
public void addOperation(UndoOperation op)
public void pruneOne()
public void addMarker(java.lang.String label)
public void addMarker(java.lang.String undoLabel, java.lang.String redoLabel)
private void undoOne() throws UndoException
UndoException
public void undo() throws UndoException
UndoException
private void redoOne() throws UndoException
UndoException
public void redo() throws UndoException
UndoException
public boolean canUndo()
public boolean canRedo()
public int getUndoOperationNumber()
public int getRedoOperationNumber()
public void setSkipEmptyOperations(boolean s)
public java.util.Collection<UndoOperation> getOperations()
Copyright 2004-2015 Wandora Team