[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model History.java, 1.1, 1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-10-18 09:19:26
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9671/src/net/sourceforge/bprocessor/model Modified Files: History.java Log Message: History class cleared Index: History.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/History.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** History.java 11 Jan 2006 10:19:58 -0000 1.1 --- History.java 18 Oct 2007 09:19:28 -0000 1.2 *************** *** 8,107 **** package net.sourceforge.bprocessor.model; - import java.util.Stack; - /** ! * The History for containing commands for undo and redo support */ public class History { - /** The undo stack */ - private Stack undoStack; - - /** The redo stack */ - private Stack redoStack; - - /** A singular history instance */ - private static History instance = new History(); - - /** - * Return the singular history instance - * @return The history - */ - public static History getInstance() { - return instance; - } - - /** - * Constructor for History - */ - public History() { - undoStack = new Stack(); - redoStack = new Stack(); - } - - /** - * Apply a command, clear the redo stack and - * push the new command on the undo stack. - * @param command The command to apply - */ - public void apply(Command command) { - command.apply(); - redoStack.clear(); - undoStack.push(command); - } - - /** - * Undo the command on top of undo stack and push - * it on the redo stack - */ - public void undo() { - if (!undoStack.isEmpty()) { - Command top = (Command) undoStack.pop(); - top.undo(); - redoStack.push(top); - } - } - - /** - * Redo the command on top of redo stack and push - * it on the undo stack - */ - public void redo() { - if (!redoStack.isEmpty()) { - Command top = (Command) redoStack.pop(); - top.redo(); - undoStack.push(top); - } - } - /** - * Return the top of the undo stack or null if empty. - * @return The top of the undo stack - */ - public Command undoTop() { - if (!undoStack.isEmpty()) { - return (Command) undoStack.peek(); - } else { - return null; - } - } - - /** - * Return the top of the redo stack or null if empty. - * @return The top of the redo stack - */ - public Command redoTop() { - if (!redoStack.isEmpty()) { - return (Command) redoStack.peek(); - } else { - return null; - } - } - - /** - * Clear this History - */ - public void clear() { - undoStack.clear(); - redoStack.clear(); - } } --- 8,15 ---- package net.sourceforge.bprocessor.model; /** ! * History */ public class History { } |