Class OperationsManager
- java.lang.Object
-
- org.eclipse.nebula.visualization.internal.xygraph.undo.OperationsManager
-
public class OperationsManager extends java.lang.ObjectThe operation manager will help to manage the undoable and redoable operations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IOperationsManagerListener>listenersprivate SizeLimitedStack<IUndoableCommand>redoStackprivate SizeLimitedStack<IUndoableCommand>undoStack
-
Constructor Summary
Constructors Constructor Description OperationsManager()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(IUndoableCommand command)Execute a command and push it to undo stack.voidaddListener(IOperationsManagerListener listener)private voidfireOperationsHistoryChanged()java.lang.Object[]getRedoCommands()intgetRedoCommandsSize()java.lang.Object[]getUndoCommands()intgetUndoCommandsSize()voidredo()redo the last undone command.voidredoCommand(IUndoableCommand command)Re-do the command.booleanremoveListener(IOperationsManagerListener listener)voidundo()undo the last command.voidundoCommand(IUndoableCommand command)Undo the command.
-
-
-
Field Detail
-
undoStack
private SizeLimitedStack<IUndoableCommand> undoStack
-
redoStack
private SizeLimitedStack<IUndoableCommand> redoStack
-
listeners
private java.util.List<IOperationsManagerListener> listeners
-
-
Method Detail
-
addCommand
public void addCommand(IUndoableCommand command)
Execute a command and push it to undo stack.- Parameters:
command- the command to be executed.
-
undoCommand
public void undoCommand(IUndoableCommand command)
Undo the command. Restore the state of the target to the previous state before this command has been executed.- Parameters:
command-
-
redoCommand
public void redoCommand(IUndoableCommand command)
Re-do the command. Restore the state of the target to the state after this command has been executed.- Parameters:
command-
-
undo
public void undo()
undo the last command. Do nothing if there is no last command.
-
redo
public void redo()
redo the last undone command. Do nothing if there is no last undone command.
-
getUndoCommands
public java.lang.Object[] getUndoCommands()
- Returns:
- the undo commands array. The first element is the oldest commands and the last element is the latest commands.
-
getRedoCommands
public java.lang.Object[] getRedoCommands()
- Returns:
- the redo commands array. The first element is the oldest commands and the last element is the latest commands.
-
addListener
public void addListener(IOperationsManagerListener listener)
-
removeListener
public boolean removeListener(IOperationsManagerListener listener)
-
fireOperationsHistoryChanged
private void fireOperationsHistoryChanged()
-
getUndoCommandsSize
public int getUndoCommandsSize()
-
getRedoCommandsSize
public int getRedoCommandsSize()
-
-