Package org.openstreetmap.josm.command
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancontinueOnErrorDetermines if the sequence execution should continue after one of its commands fails.private java.lang.Stringnameprivate Command[]sequenceThe command sequence to be executed.private booleansequenceComplete-
Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE
-
-
Constructor Summary
Constructors Constructor Description SequenceCommand(java.lang.String name, java.util.Collection<Command> sequenz)Create the command by specifying the list of commands to execute.SequenceCommand(java.lang.String name, java.util.Collection<Command> sequenz, boolean continueOnError)Create the command by specifying the list of commands to execute.SequenceCommand(java.lang.String name, Command... sequenz)Convenient constructor, if the commands are known at compile time.SequenceCommand(DataSet ds, java.lang.String name, java.util.Collection<Command> sequenz, boolean continueOnError)Create the command by specifying the list of commands to execute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ReportedExceptioncreateReportedException(java.lang.Throwable e, int i)booleanequals(java.lang.Object obj)booleanexecuteCommand()Executes the command on the dataset.voidfillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)Fill in the changed data this command operates on.java.util.Collection<PseudoCommand>getChildren()Returns the subcommands of this command.javax.swing.IcongetDescriptionIcon()Provides a descriptive icon of this command.java.lang.StringgetDescriptionText()Provides a description text representing this command.CommandgetLastCommand()Returns the last command.java.lang.StringgetName()Returns the command name used in description text.java.util.Collection<? extends OsmPrimitive>getParticipatingPrimitives()Return the primitives that take part in this command.inthashCode()protected voidsetSequence(Command... sequence)protected voidsetSequenceComplete(boolean sequenceComplete)voidundoCommand()Undoes the command.protected voidundoCommands(int start)static CommandwrapIfNeeded(java.lang.String name, java.util.Collection<Command> sequenz)Convenient constructor, if the commands are known at compile time.static CommandwrapIfNeeded(java.lang.String name, Command... sequenz)Convenient constructor, if the commands are known at compile time.-
Methods inherited from class org.openstreetmap.josm.command.Command
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrig
-
-
-
-
Field Detail
-
sequenceComplete
private boolean sequenceComplete
-
name
private final java.lang.String name
-
continueOnError
protected final boolean continueOnError
Determines if the sequence execution should continue after one of its commands fails.
-
-
Constructor Detail
-
SequenceCommand
public SequenceCommand(DataSet ds, java.lang.String name, java.util.Collection<Command> sequenz, boolean continueOnError)
Create the command by specifying the list of commands to execute.- Parameters:
ds- The target data set. Must not benullname- The description textsequenz- The sequence that should be executedcontinueOnError- Determines if the sequence execution should continue after one of its commands fails- Since:
- 12726
-
SequenceCommand
public SequenceCommand(java.lang.String name, java.util.Collection<Command> sequenz, boolean continueOnError)
Create the command by specifying the list of commands to execute.- Parameters:
name- The description textsequenz- The sequence that should be executed. Must not be null or emptycontinueOnError- Determines if the sequence execution should continue after one of its commands fails- Since:
- 11874
-
SequenceCommand
public SequenceCommand(java.lang.String name, java.util.Collection<Command> sequenz)
Create the command by specifying the list of commands to execute.- Parameters:
name- The description textsequenz- The sequence that should be executed.
-
SequenceCommand
public SequenceCommand(java.lang.String name, Command... sequenz)
Convenient constructor, if the commands are known at compile time.- Parameters:
name- The description textsequenz- The sequence that should be executed.
-
-
Method Detail
-
wrapIfNeeded
public static Command wrapIfNeeded(java.lang.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(java.lang.String name, java.util.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:CommandExecutes 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:
executeCommandin classCommand- Returns:
- true
-
getLastCommand
public Command getLastCommand()
Returns the last command.- Returns:
- The last command, or
nullif the sequence is empty.
-
undoCommands
protected final void undoCommands(int start)
-
createReportedException
private ReportedException createReportedException(java.lang.Throwable e, int i)
-
undoCommand
public void undoCommand()
Description copied from class:CommandUndoes 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:
undoCommandin classCommand
-
fillModifiedData
public void fillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)
Description copied from class:CommandFill in the changed data this command operates on. Add to the lists, don't clear them.- Specified by:
fillModifiedDatain classCommand- Parameters:
modified- The modified primitivesdeleted- The deleted primitivesadded- The added primitives
-
getDescriptionText
public java.lang.String getDescriptionText()
Description copied from interface:PseudoCommandProvides a description text representing this command.- Returns:
- description text representing this command
-
getName
public final java.lang.String getName()
Returns the command name used in description text.- Returns:
- the command name
- Since:
- 14283
-
getDescriptionIcon
public javax.swing.Icon getDescriptionIcon()
Description copied from interface:PseudoCommandProvides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getChildren
public java.util.Collection<PseudoCommand> getChildren()
Description copied from interface:PseudoCommandReturns the subcommands of this command. Override for subclasses that have child commands.- Returns:
- the subcommands, null if there are no child commands
-
getParticipatingPrimitives
public java.util.Collection<? extends OsmPrimitive> getParticipatingPrimitives()
Description copied from class:CommandReturn the primitives that take part in this command. The collection is computed during execution.- Specified by:
getParticipatingPrimitivesin interfacePseudoCommand- Overrides:
getParticipatingPrimitivesin classCommand- Returns:
- primitives that take part in this command
-
setSequence
protected final void setSequence(Command... sequence)
-
setSequenceComplete
protected final void setSequenceComplete(boolean sequenceComplete)
-
-