com.dlsc.flexgantt.command

## Class AbstractCompoundCommand<T extends ICommand>

- java.lang.Object
- - com.dlsc.flexgantt.command.AbstractCommand
  - - com.dlsc.flexgantt.command.AbstractCompoundCommand<T>

- Type Parameters:
    `T` - the object type of the nested commands
  All Implemented Interfaces:
    ICommand, Serializable
  Direct Known Subclasses:
    DefaultChangeMultipleTimelineObjectsTimeSpanCommand, DefaultCreateMultipleTimelineObjectsCommand, DefaultDeleteMultipleEventlineObjectsCommand, DefaultDeleteMultipleNodesCommand, DefaultDeleteMultipleRelationshipsCommand, DefaultDeleteMultipleTimelineObjectsCommand

      public abstract class AbstractCompoundCommand<T extends ICommand>
      extends AbstractCommand

  A compound command can be used to group several commands together in order to execute them at the same time. Note: please read the comments on transactional integrity in the `ICommand` interface.
  Since:
    1.0
  Version:
    $Revision: 1.10 $
  Author:
    Dirk Lemmermann
  See Also:
    `ICommand`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractCompoundCommand(String name)` Creates a new compound command with the given name.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCommand(T cmd)` Adds a command to the compound command.
    `void` | `executeCommand(IProgressMonitor monitor)` Executes the compound command by iterating over the list of added commands and calling their execute method.
    `T` | `getCommand(int index)` Returns the nested command for the given index.
    `int` | `getCommandCount()` Returns the number of commands added to the compound command.
    `boolean` | `isRedoable()` Returns true if the compund command can be redone.
    `boolean` | `isUndoable()` Returns true if the compound command can be undone.
    `void` | `redoCommand(IProgressMonitor monitor)` Redos the command by calling the execute method of the command.
    `boolean` | `removeCommand(T cmd)` Removes a command from the compound command.
    `void` | `setCommands(T[] cmd)` Adds the given commands to the compound command and removed all previously added commands.
    `void` | `undoCommand(IProgressMonitor monitor)` Undos the compound command by iterating over the list of added commands (in reverse order: last added command gets undone first) and calling their undo method.

    - ### Methods inherited from class com.dlsc.flexgantt.command.AbstractCommand

      `getName, isRelevant, setName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractCompoundCommand

          public AbstractCompoundCommand(String name)

      Creates a new compound command with the given name.
      Parameters:
        `name` - the name of the command
      Since:
        1.0

  - ### Method Detail

    - #### addCommand

          public void addCommand(T cmd)

      Adds a command to the compound command. Commands will be executed in the order in which they were added (FIFO).
      Parameters:
        `cmd` - the added command
      Since:
        1.0

    - #### removeCommand

          public boolean removeCommand(T cmd)

      Removes a command from the compound command.
      Parameters:
        `cmd` - the removed command
      Returns:
        true if the command was part of the compound command and if it could be successfully removed
      Since:
        1.0

    - #### getCommandCount

          public int getCommandCount()

      Returns the number of commands added to the compound command.
      Returns:
        the number of commands added to the compound command
      Since:
        1.0

    - #### getCommand

          public T getCommand(int index)

      Returns the nested command for the given index.
      Parameters:
        `index` - the index of the nested command
      Returns:
        the nested command with the given index
      Since:
        1.0

    - #### setCommands

          public void setCommands(T[] cmd)

      Adds the given commands to the compound command and removed all previously added commands.
      Parameters:
        `cmd` - the commands to be executed by the compound command
      Since:
        1.0

    - #### executeCommand

          public void executeCommand(IProgressMonitor monitor)
                              throws CommandException

      Executes the compound command by iterating over the list of added commands and calling their execute method. If any of the nested commands fails then the entire compound command fails.
      Parameters:
        `monitor` - a monitor for reporting the progress of the command execution
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong
      Since:
        1.0
      See Also:
        `undoCommand(IProgressMonitor)`, `redoCommand(IProgressMonitor)`

    - #### undoCommand

          public void undoCommand(IProgressMonitor monitor)
                           throws CommandException

      Undos the compound command by iterating over the list of added commands (in reverse order: last added command gets undone first) and calling their undo method.
      Parameters:
        `monitor` - a monitor for reporting the progress of the command execution
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong
      Since:
        1.0
      See Also:
        `executeCommand(IProgressMonitor)`, `redoCommand(IProgressMonitor)`

    - #### redoCommand

          public void redoCommand(IProgressMonitor monitor)
                           throws CommandException

      Redos the command by calling the execute method of the command.
      Specified by:
        `redoCommand` in interface `ICommand`
      Overrides:
        `redoCommand` in class `AbstractCommand`
      Parameters:
        `monitor` - a monitor for reporting the progress of the command execution
      Throws:
        `CommandException` - if anything during the execution of the command has gone wrong
      Since:
        1.0
      See Also:
        `executeCommand(IProgressMonitor)`, `undoCommand(IProgressMonitor)`

    - #### isUndoable

          public boolean isUndoable()

      Returns true if the compound command can be undone. This is only the case if each of the added commands can be undone.
      Specified by:
        `isUndoable` in interface `ICommand`
      Overrides:
        `isUndoable` in class `AbstractCommand`
      Returns:
        true if the command can be undone
      Since:
        1.0
      See Also:
        `isRedoable()`

    - #### isRedoable

          public boolean isRedoable()

      Returns true if the compund command can be redone. This is only the case if each of the added commands can be redone.
      Specified by:
        `isRedoable` in interface `ICommand`
      Overrides:
        `isRedoable` in class `AbstractCommand`
      Returns:
        true if the command can be redone
      Since:
        1.0
      See Also:
        `isUndoable()`

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.