Command Interceptor


Depending on the current context in which a command gets used it might be necessary to edit the command before it is being executed. The user might want to edit the start and end times of a newly created eventline or timeline object. Maybe notes should be added to a task or a certain flag needs to be set. To accomplish this the application needs to register so-called command interceptors on the Gantt chart. This is done by mapping the interceptor to a command class like this:

AbstractGanttChart.setCommandInterceptor(Class<? extends ICommand> cl, ICommandInterceptor interceptor);


Now every time a command of the given type gets executed the interceptor will be invoked and it might decide to show a dialog to the user so that the required additonal information can be entered. The dialog can query the command that gets passed to it for information and display these to the user. By invoking the command's set() methods the user input can be passed back to the command.

Example


The eventline always registers an interceptor for commands of type DefaultCreateEventlineObjectCommand. The interceptor will then display a dialog to the user so that a label, a time span, and a color for the eventline object can be entered.

Screenshot_8