Class SequenceCommand

java.lang.Object
org.openstreetmap.josm.command.Command
org.openstreetmap.josm.command.SequenceCommand
All Implemented Interfaces:
PseudoCommand
Direct Known Subclasses:
JoinAreasAction.JoinAreaCommand, SplitWayCommand, ValidatorDialog.AutofixCommand

public class SequenceCommand extends Command
A command consisting of a sequence of other commands. Executes the other commands and undo them in reverse order.
Since:
31
  • Field Details

    • sequence

      private Command[] sequence
      The command sequence to be executed.
    • sequenceComplete

      private boolean sequenceComplete
    • name

      private final String name
    • continueOnError

      protected final boolean continueOnError
      Determines if the sequence execution should continue after one of its commands fails.
  • Constructor Details

    • SequenceCommand

      public SequenceCommand(DataSet ds, String name, Collection<Command> sequenz, boolean continueOnError)
      Create the command by specifying the list of commands to execute.
      Parameters:
      ds - The target data set. Must not be null
      name - The description text
      sequenz - The sequence that should be executed
      continueOnError - Determines if the sequence execution should continue after one of its commands fails
      Since:
      12726
    • SequenceCommand

      public SequenceCommand(String name, Collection<Command> sequenz, boolean continueOnError)
      Create the command by specifying the list of commands to execute.
      Parameters:
      name - The description text
      sequenz - The sequence that should be executed. Must not be null or empty
      continueOnError - Determines if the sequence execution should continue after one of its commands fails
      Since:
      11874
    • SequenceCommand

      public SequenceCommand(String name, Collection<Command> sequenz)
      Create the command by specifying the list of commands to execute.
      Parameters:
      name - The description text
      sequenz - The sequence that should be executed.
    • SequenceCommand

      public SequenceCommand(String name, Command... sequenz)
      Convenient constructor, if the commands are known at compile time.
      Parameters:
      name - The description text
      sequenz - The sequence that should be executed.
  • Method Details

    • wrapIfNeeded

      public static Command wrapIfNeeded(String name, Command... sequenz)
      Convenient constructor, if the commands are known at compile time.
      Parameters:
      name - The description text to be used for the sequence command, if one is created.
      sequenz - The sequence that should be executed.
      Returns:
      Either a SequenceCommand, or the only command in the potential sequence
      Since:
      16573
    • wrapIfNeeded

      public static Command wrapIfNeeded(String name, Collection<Command> sequenz)
      Convenient constructor, if the commands are known at compile time.
      Parameters:
      name - The description text to be used for the sequence command, if one is created.
      sequenz - The sequence that should be executed.
      Returns:
      Either a SequenceCommand, or the only command in the potential sequence
      Since:
      16573
    • executeCommand

      public boolean executeCommand()
      Description copied from class: Command
      Executes the command on the dataset. This implementation will remember all primitives returned by fillModifiedData for restoring them on undo.

      The layer should be invalidated after execution so that it can be re-painted.

      Overrides:
      executeCommand in class Command
      Returns:
      true
    • getLastCommand

      Returns the last command.
      Returns:
      The last command, or null if the sequence is empty.
    • undoCommands

      protected final void undoCommands(int start)
    • createReportedException

    • undoCommand

      public void undoCommand()
      Description copied from class: Command
      Undoes the command. It can be assumed that all objects are in the same state they were before. It can also be assumed that executeCommand was called exactly once before. This implementation undoes all objects stored by a former call to executeCommand.
      Overrides:
      undoCommand in class Command
    • fillModifiedData

      Description copied from class: Command
      Fill in the changed data this command operates on. Add to the lists, don't clear them.
      Specified by:
      fillModifiedData in class Command
      Parameters:
      modified - The modified primitives
      deleted - The deleted primitives
      added - The added primitives
    • getDescriptionText

      Description copied from interface: PseudoCommand
      Provides a description text representing this command.
      Returns:
      description text representing this command
    • getName

      public final String getName()
      Returns the command name used in description text.
      Returns:
      the command name
      Since:
      14283
    • getDescriptionIcon

      Description copied from interface: PseudoCommand
      Provides a descriptive icon of this command.
      Returns:
      descriptive icon of this command
    • getChildren

      Description copied from interface: PseudoCommand
      Returns the subcommands of this command. Override for subclasses that have child commands.
      Returns:
      the subcommands, null if there are no child commands
    • getParticipatingPrimitives

      Description copied from class: Command
      Return the primitives that take part in this command. The collection is computed during execution.
      Specified by:
      getParticipatingPrimitives in interface PseudoCommand
      Overrides:
      getParticipatingPrimitives in class Command
      Returns:
      primitives that take part in this command
    • setSequence

      protected final void setSequence(Command... sequence)
    • setSequenceComplete

      protected final void setSequenceComplete(boolean sequenceComplete)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Command
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Command