sk.uniba.euromath.document
Class UndoManager

java.lang.Object
  extended by sk.uniba.euromath.document.UndoManager
All Implemented Interfaces:
EventListener, sk.baka.ikslibs.INodeObserver

public final class UndoManager
extends Object
implements EventListener, sk.baka.ikslibs.INodeObserver

Manages undoing of the modification operations. Thread-unsafe.

Author:
Martin Vysny

Constructor Summary
UndoManager()
          Constructs an empty undo manager.
 
Method Summary
 boolean canRedo()
          Checks if there are some undo actions that can be applied back to the document.
 boolean canUndo()
          Checks if there are some undoable operations.
 int getMarkCount()
          Returns the maximum number of marks.
 void handleEvent(Event evt)
           
 boolean isSavePoint()
          Checks if the manager is currently 'standing' on the savepoint mark.
 void mark()
          Marks the end of previous modification operations group and the start of a new group.
 void mark(boolean savePoint)
          Marks the end of previous modification operations group and the start of a new group.
 void observe(Node node)
           
 void redo()
           Redoes previously undone modification operations up to the nearest mark point.
 void setMarkCount(int count)
          Sets new maximum count of marks - a maximum undo history length.
 void stopObservation(Node node)
           
 void undo()
           Rollbacks all previous modification operations up to the nearest mark point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UndoManager

public UndoManager()
Constructs an empty undo manager.

Method Detail

mark

public void mark()
Marks the end of previous modification operations group and the start of a new group. When undo is requested all modifications are rolled back to nearest mark point.


mark

public void mark(boolean savePoint)
Marks the end of previous modification operations group and the start of a new group. When undo is requested all modifications are rolled back to nearest mark point.

Parameters:
savePoint - if true then this mark marks a point when the document was saved.

isSavePoint

public boolean isSavePoint()
Checks if the manager is currently 'standing' on the savepoint mark.

Returns:
true if last undo group is empty (it contains no actions) and savepoint.

undo

public void undo()

Rollbacks all previous modification operations up to the nearest mark point. If no operations were performed then nothing is done.

The document must be in the modifying mode (DocumentModifier.startModify() must have been called).


canUndo

public boolean canUndo()
Checks if there are some undoable operations.

Returns:
true if there are some undoable operations, false otherwise.

redo

public void redo()

Redoes previously undone modification operations up to the nearest mark point. If no operations can be redone then nothing is done.

The document must be in the modifying mode (DocumentModifier.startModify() must have been called).


canRedo

public boolean canRedo()
Checks if there are some undo actions that can be applied back to the document.

Returns:
true if there are some redoable operations, false otherwise.

getMarkCount

public int getMarkCount()
Returns the maximum number of marks. Defaults to 5.

Returns:
maximum length of undo history.

setMarkCount

public void setMarkCount(int count)
Sets new maximum count of marks - a maximum undo history length. If new mark exceeds this limit then first (oldest) mark is forgotten and undo is impossible beyond that mark point.

Parameters:
count - the maximum marks count.

handleEvent

public void handleEvent(Event evt)
Specified by:
handleEvent in interface EventListener

observe

public void observe(Node node)
Specified by:
observe in interface sk.baka.ikslibs.INodeObserver

stopObservation

public void stopObservation(Node node)
Specified by:
stopObservation in interface sk.baka.ikslibs.INodeObserver


Copyright © 2003-2006 null. All Rights Reserved.