org.gvsig.tools.undo.command.impl
Class DefaultUndoRedoCommandStack

java.lang.Object
  extended by org.gvsig.tools.undo.command.impl.DefaultUndoRedoCommandStack
All Implemented Interfaces:
Observable, WeakReferencingObservable, UndoRedoCommandStack, UndoRedoStack

public class DefaultUndoRedoCommandStack
extends Object
implements UndoRedoCommandStack

Clase en memoria para registrar y gestionar los comandos que vamos realizando. La forma en que ha sido implementada esta clase, en vez de una única lista para albergar los comandos de deshacer(undos) y los de rehacer(redos), se ha optado por dos pilas una para deshacer(undos) y otra para rehacer(redos), de esta forma : Cuando se añade un nuevo comando, se inserta este a la pila de deshacer(undos) y se borra de la de rehacer(redos). Si se realiza un deshacer se desapila este comando de la pila deshacer(undos) y se apila en la de rehacer(redos). Y de la misma forma cuando se realiza un rehacer se desapila este comando de la pila de rehacer(redos) y pasa a la de deshacer(undos).

Author:
Vicente Caballero Navarro

Constructor Summary
DefaultUndoRedoCommandStack()
           
 
Method Summary
 void add(Command command)
           
 void addObserver(Observer o)
           
 boolean canRedo()
          If a redo can be performed on the stack.
 boolean canUndo()
          If an undo can be performed on the stack.
 void clear()
           
 void deleteObserver(Observer o)
           
 void deleteObservers()
           
 void endComplex()
           
 Command getNextRedoCommand()
           
 Command getNextUndoCommand()
           
 List getRedoInfos()
          Returns the list of UndoRedoInfo in the REDO stack
 List getUndoInfos()
          Returns the list of UndoRedoInfo in the UNDO stack
 boolean inComplex()
           
 void redo()
          Re-does the following redoable elements.
 void redo(int commands)
          Re-does a number of the following redoable element.
 int size()
           
 void startComplex(String description)
           
 void undo()
          Undoes the following undoable elements.
 void undo(int commands)
          Undoes a number of the following undoable elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUndoRedoCommandStack

public DefaultUndoRedoCommandStack()
Method Detail

add

public void add(Command command)
Specified by:
add in interface UndoRedoCommandStack

undo

public void undo()
          throws UndoException
Description copied from interface: UndoRedoStack
Undoes the following undoable elements.

Specified by:
undo in interface UndoRedoStack
Throws:
UndoException - if there is an error performing de undo element

redo

public void redo()
          throws RedoException
Description copied from interface: UndoRedoStack
Re-does the following redoable elements.

Specified by:
redo in interface UndoRedoStack
Throws:
RedoException - if there is an error performing de redo element

redo

public void redo(int commands)
          throws RedoException
Description copied from interface: UndoRedoStack
Re-does a number of the following redoable element.

Specified by:
redo in interface UndoRedoStack
Parameters:
commands - the number of elements to redo
Throws:
RedoException - if there is an error performing de redo element

undo

public void undo(int commands)
          throws UndoException
Description copied from interface: UndoRedoStack
Undoes a number of the following undoable elements.

Specified by:
undo in interface UndoRedoStack
Parameters:
commands - the number of elements to undo
Throws:
UndoException - if there is an error performing de undo element

canUndo

public boolean canUndo()
Description copied from interface: UndoRedoStack
If an undo can be performed on the stack.

Specified by:
canUndo in interface UndoRedoStack
Returns:
an undo can be performed

canRedo

public boolean canRedo()
Description copied from interface: UndoRedoStack
If a redo can be performed on the stack.

Specified by:
canRedo in interface UndoRedoStack
Returns:
a redo can be performed

getUndoInfos

public List getUndoInfos()
Description copied from interface: UndoRedoStack
Returns the list of UndoRedoInfo in the UNDO stack

Specified by:
getUndoInfos in interface UndoRedoStack
Returns:
list of UndoRedoInfo in the UNDO stack

getRedoInfos

public List getRedoInfos()
Description copied from interface: UndoRedoStack
Returns the list of UndoRedoInfo in the REDO stack

Specified by:
getRedoInfos in interface UndoRedoStack
Returns:
list of UndoRedoInfo in the REDO stack

size

public int size()
Specified by:
size in interface UndoRedoCommandStack

clear

public void clear()
Specified by:
clear in interface UndoRedoCommandStack

getNextUndoCommand

public Command getNextUndoCommand()
Specified by:
getNextUndoCommand in interface UndoRedoCommandStack

getNextRedoCommand

public Command getNextRedoCommand()
Specified by:
getNextRedoCommand in interface UndoRedoCommandStack

addObserver

public void addObserver(Observer o)
Specified by:
addObserver in interface Observable

deleteObserver

public void deleteObserver(Observer o)
Specified by:
deleteObserver in interface Observable

deleteObservers

public void deleteObservers()
Specified by:
deleteObservers in interface Observable

endComplex

public void endComplex()
Specified by:
endComplex in interface UndoRedoCommandStack

startComplex

public void startComplex(String description)
Specified by:
startComplex in interface UndoRedoCommandStack

inComplex

public boolean inComplex()
Specified by:
inComplex in interface UndoRedoCommandStack


Copyright © 2004-2011 gvSIG. All Rights Reserved.