Class GanttUndoRedoManager
- java.lang.Object
-
- org.eclipse.nebula.widgets.ganttchart.undoredo.GanttUndoRedoManager
-
public class GanttUndoRedoManager extends java.lang.Object
Deals with Undo/Redo events in the chart. Implemented per Command-structure standards.
-
-
Field Summary
Fields Modifier and Type Field Description private GanttComposite
_comp
private int
_currentIndex
private java.util.List
_listeners
private int
_maxStackSize
private java.util.List
_undoRedoEvents
static int
STACK_SIZE
-
Constructor Summary
Constructors Constructor Description GanttUndoRedoManager(GanttComposite parent, int maxStackSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUndoRedoListener(IUndoRedoListener listener)
Adds a listener to be notified when undo/redo possibilities changeboolean
canRedo()
Whether a Redo is possible.boolean
canUndo()
Whether an Undo is possible.void
clear()
Removes all undo/redo events from the stackprivate void
fixStack()
Clears up the stack of undo/redo events and keeps its size in check.int
getCurrentIndex()
The current index of where the undo/redo marker isjava.util.List
getUndoRedoEvents()
void
record(IUndoRedoCommand command)
Records an undoable/redoable commandboolean
redo()
Redoes the last GanttChart action.void
removeUndoRedoListener(IUndoRedoListener listener)
Removes a listener from being notified when undo/redo possibilities changevoid
setCurrentIndex(int currentIndex)
void
setMaxStackSize(int stackSize)
Sets a new max undo/redo sack size, value must be a positive integer or it is ignored.boolean
undo()
Undoes the last GanttChart action.private void
updateListeners()
-
-
-
Field Detail
-
STACK_SIZE
public static final int STACK_SIZE
- See Also:
- Constant Field Values
-
_undoRedoEvents
private final java.util.List _undoRedoEvents
-
_currentIndex
private int _currentIndex
-
_maxStackSize
private int _maxStackSize
-
_comp
private final GanttComposite _comp
-
_listeners
private final java.util.List _listeners
-
-
Constructor Detail
-
GanttUndoRedoManager
public GanttUndoRedoManager(GanttComposite parent, int maxStackSize)
-
-
Method Detail
-
getUndoRedoEvents
public java.util.List getUndoRedoEvents()
-
addUndoRedoListener
public void addUndoRedoListener(IUndoRedoListener listener)
Adds a listener to be notified when undo/redo possibilities change- Parameters:
listener
-
-
removeUndoRedoListener
public void removeUndoRedoListener(IUndoRedoListener listener)
Removes a listener from being notified when undo/redo possibilities change- Parameters:
listener
-
-
record
public void record(IUndoRedoCommand command)
Records an undoable/redoable command- Parameters:
command
-
-
updateListeners
private void updateListeners()
-
clear
public void clear()
Removes all undo/redo events from the stack
-
canUndo
public boolean canUndo()
Whether an Undo is possible.- Returns:
- true if user can Undo
-
undo
public boolean undo()
Undoes the last GanttChart action.- Returns:
-
redo
public boolean redo()
Redoes the last GanttChart action.- Returns:
-
canRedo
public boolean canRedo()
Whether a Redo is possible.- Returns:
- true if user can Redo
-
getCurrentIndex
public int getCurrentIndex()
The current index of where the undo/redo marker is- Returns:
-
setCurrentIndex
public void setCurrentIndex(int currentIndex)
- Parameters:
currentIndex
- The current index of where the undo/redo marker is
-
fixStack
private void fixStack()
Clears up the stack of undo/redo events and keeps its size in check.
-
setMaxStackSize
public void setMaxStackSize(int stackSize)
Sets a new max undo/redo sack size, value must be a positive integer or it is ignored.- Parameters:
stackSize
- new max undo/redo stack size
-
-