Class OperationsManager
- java.lang.Object
-
- org.eclipse.nebula.visualization.internal.xygraph.undo.OperationsManager
-
public class OperationsManager extends java.lang.Object
The operation manager will help to manage the undoable and redoable operations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IOperationsManagerListener>
listeners
private SizeLimitedStack<IUndoableCommand>
redoStack
private SizeLimitedStack<IUndoableCommand>
undoStack
-
Constructor Summary
Constructors Constructor Description OperationsManager()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(IUndoableCommand command)
Execute a command and push it to undo stack.void
addListener(IOperationsManagerListener listener)
private void
fireOperationsHistoryChanged()
java.lang.Object[]
getRedoCommands()
int
getRedoCommandsSize()
java.lang.Object[]
getUndoCommands()
int
getUndoCommandsSize()
void
redo()
redo the last undone command.void
redoCommand(IUndoableCommand command)
Re-do the command.boolean
removeListener(IOperationsManagerListener listener)
void
undo()
undo the last command.void
undoCommand(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()
-
-