org.acm.seguin.refactor.undo
Class UndoStack

java.lang.Object
  extended by org.acm.seguin.refactor.undo.UndoStack

public class UndoStack
extends java.lang.Object

The stack of refactorings that we can undo. This stack holds all the refactorings that have occurred in the system.

This object is a singleton object because we only want one object responsible for storing the refactorings that can be undone.

Version:
$Id: UndoStack.java,v 1.6 2003/12/02 23:39:40 mikeatkinson Exp $
Author:
Chris Seguin, Mike Atkinson

Constructor Summary
UndoStack()
          Constructor for the UndoStack object
 
Method Summary
 UndoAction add(Refactoring ref)
          Adds a refactoring to the undo stack.
 void delete()
          Deletes the undo stack
 void done()
          Description of the Method
static UndoStack get()
          Gets the singleton undo operation
 boolean isStackEmpty()
          Gets the StackEmpty attribute of the UndoStack object
 java.util.Iterator list()
          Lists the undo actions in the stack
 UndoAction peek()
          Return the top option without removing it from the stack
 void setUndoAction(java.lang.Class undoer)
          This sets the class that holds undo actions.
 void undo()
          Performs an undo of the top action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UndoStack

public UndoStack()
Constructor for the UndoStack object

Method Detail

setUndoAction

public void setUndoAction(java.lang.Class undoer)
                   throws java.lang.IllegalArgumentException
This sets the class that holds undo actions. If not called the org.acm.seguin.refactor.undo.DefaultUndoAction class is used. This creates file backups with extensions of incrementing integers.

Parameters:
undoer - a class that implements org.acm.seguin.refactor.undo.UndoAction
Throws:
java.lang.IllegalArgumentException - if the class cannot be instantiated or does not implement UndoAction

isStackEmpty

public boolean isStackEmpty()
Gets the StackEmpty attribute of the UndoStack object

Returns:
The StackEmpty value

add

public UndoAction add(Refactoring ref)
Adds a refactoring to the undo stack. You provide the refactoring, this method provides the undo action.

Parameters:
ref - the refactoring about to be performed
Returns:
an undo action

peek

public UndoAction peek()
Return the top option without removing it from the stack

Returns:
the top object

list

public java.util.Iterator list()
Lists the undo actions in the stack

Returns:
an iterator of undo actions

undo

public void undo()
Performs an undo of the top action


done

public void done()
Description of the Method


delete

public void delete()
Deletes the undo stack


get

public static UndoStack get()
Gets the singleton undo operation

Returns:
the undo stack for the system