KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > command > CommandStack


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: CommandStack.java,v 1.2 2005/06/08 05:44:08 nickb Exp $
16  */

17 package org.eclipse.emf.common.command;
18
19
20
21 /**
22  * A simple and obvious interface for an undoable stack of commands with a listener.
23  * See {@link Command} for more details about the command methods that this implementation uses
24  * and {@link CommandStackListener} for details about the listener.
25  */

26 public interface CommandStack
27 {
28   /**
29    * Clears any redoable commands not yet redone, adds the command, and then executes the command.
30    * @param command the command to execute.
31    */

32   void execute(Command command);
33
34   /**
35    * Returns whether the top command on the stack can be undone.
36    * @return whether the top command on the stack can be undone.
37    */

38   boolean canUndo();
39
40   /**
41    * Moves the top of the stack down, undoing what was formerly the top command.
42    */

43   void undo();
44
45   /**
46    * Returns whether there are commands past the top of the stack that can be redone.
47    * @return whether there are commands past the top of the stack that can be redone.
48    */

49   boolean canRedo();
50
51   /**
52    * Returns the command that will be undone if {@link #undo} is called.
53    * @return the command that will be undone if {@link #undo} is called.
54    */

55   public Command getUndoCommand();
56   
57   /**
58    * Returns the command that will be redone if {@link #redo} is called.
59    * @return the command that will be redone if {@link #redo} is called.
60    */

61   public Command getRedoCommand();
62   
63   /**
64    * Returns the command most recently executed, undone, or redone.
65    * @return the command most recently executed, undone, or redone.
66    */

67   public Command getMostRecentCommand();
68
69   /**
70    * Moves the top of the stack up, redoing the new top command.
71    */

72   void redo();
73
74   /**
75    * Disposes all the commands in the stack.
76    */

77   void flush();
78
79   /**
80    * Adds a listener to the command stack, which will be notified whenever a command has been processed on the stack.
81    * @param listener the listener to add.
82    */

83   void addCommandStackListener(CommandStackListener listener);
84
85   /**
86    * Removes a listener from the command stack.
87    * @param listener the listener to remove.
88    */

89   void removeCommandStackListener(CommandStackListener listener);
90 }
91
Popular Tags