Command Stack


Each Gantt chart owns a command stack. The standard command stack is an instance of DefaultCommandStack. The stack is responsible for executing, undoing, redoing commands. It keeps a list of executed commands that can be undone. This list gets cleared once a command gets executed that can not be undone.

Command stack listeners can be attached to the stack. These listeners will be informed about state changes of commands (started, executed, cancelled, failed, undone).

The command stack is defined as an interface so that applications can easily use a custom command stack implementation. It is often the case that applications already define their own command stack, which executes commands from other areas of their user interface. To ensure that the undo / redo logic will still work after adding the Gantt chart it is mandatory that a common / single stack gets used.

Relevant API


ICommandStack
ICommandStackListener
CommandStackEvent
void ICommandStack.execute(ICommand cmd, IProgressMonitor monitor);
void ICommandStack.undo(IProgressMonitor monitor);
void ICommandStack.redo(IProgressMonitor monitor);
void ICommandStack.addCommandStackListener(ICommandStackListener);
void AbstractGanttChart.getCommandStack();
void AbstractGanttChart.setCommandStack(ICommandStack stack);
boolean ICommand.isUndoable();