com.partnersoft.gadgets
Class UndoStack

java.lang.Object
  extended by com.partnersoft.gadgets.UndoStack

public class UndoStack
extends java.lang.Object

Handles an undo/redo stack.

Author:
Paul Reavis Copyright 2002 Partner Software, Inc.

Constructor Summary
UndoStack()
           
 
Method Summary
 void clear()
           
 void execute(UndoableCommand command)
          Executes the new command, and clears the current redo stack.
 ChangeGadget getChangeGadget()
           
 int getRedoStackSize()
           
 boolean getSavingDisabled()
           
 int getUndoStackSize()
           
 UndoableCommand nextUndo()
           
 UndoableCommand redo()
           
 java.util.ArrayList removeCommandsSince(UndoableCommand command)
          This removes the commands executed since the given UndoableCommand on the stack, without undoing them.
 void setSavingDisabled(boolean tizit)
          This disables pushing the commands onto the stack during execute/undo/redo all that happens is an execute.
 UndoableCommand undo()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UndoStack

public UndoStack()
Method Detail

execute

public void execute(UndoableCommand command)
Executes the new command, and clears the current redo stack.


undo

public UndoableCommand undo()

redo

public UndoableCommand redo()

nextUndo

public UndoableCommand nextUndo()

getUndoStackSize

public int getUndoStackSize()

getRedoStackSize

public int getRedoStackSize()

getChangeGadget

public ChangeGadget getChangeGadget()

clear

public void clear()

setSavingDisabled

public void setSavingDisabled(boolean tizit)
This disables pushing the commands onto the stack during execute/undo/redo all that happens is an execute. Useful for when you want to use your regular logic to change things, but don't actually want the changes to affect the stack.


getSavingDisabled

public boolean getSavingDisabled()

removeCommandsSince

public java.util.ArrayList removeCommandsSince(UndoableCommand command)
This removes the commands executed since the given UndoableCommand on the stack, without undoing them. This is handy for dealing with transitional problems where one undoable actually triggers other undoables, but you don't want to undo the resulting undoables. On an undo. Sigh. Maybe an example is in order - in the Map Viewer, selection of a map item that's off the screen triggers a view change so the item is visible. Both the selection and the view change are UndoableCommands, but to the user, only one actual event has happened. They need to be bundled, so I rigged this to return all the commands since the selection change undoable so that they can be managed by the selection undoable automagically. Returns the commands in the order you'd need to undo them (in order of pop). Returns null if there are none.