Commands


Commands are executed, undone and redone via the Gantt chart, which internally uses a replaceable command stack. Commands are executed in their own thread in order to keep the user interface responsive. Command stack events are issued during the execution of the command. Progress monitors are used to display the progress made by a command. Sub-progress monitors are used for compound commands that consist of several other commands. Once a command has finished execution it will be added to the command stack‘s list of undoable commands. This list will be cleared when a command gets executed that can not be undone. The command framework uses a high level of abstraction so that an already existing command infrastructure (legacy code) can be reused.

The easiest way to execute / undo / redo a command is to use the appropriate methods in AbstractGanttChart:

void AbstractGanttChart.commandExecute(ICommand cmd);
void AbstractGanttChart.commandUndo();
void AbstractGanttChart.commandRedo();


These methods delegate to the command stack of the Gantt chart and invoke the matching methods on it:

void ICommandStack.execute(ICommand cmd, IProgressMonitor monitor);
void ICommandStack.undo(IProgressMonitor monitor);
void ICommandStack.redo();


The command stack methods require a progress monitor instance, which gets created by the Gantt chart via an instance of IProgressMonitorFactory. The progress monitor gets passed to the methods of the commands:

void ICommandStack.execute(ICommand cmd, IProgressMonitor monitor);
void ICommandStack.undo(ICommand cmd, IProgressMonitor monitor);
void ICommandStack.redo(ICommand cmd, IProgressMonitor monitor);