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 boolean
continueOnError
Determines if the sequence execution should continue after one of its commands fails.private java.lang.String
name
private Command[]
sequence
The command sequence to be executed.private boolean
sequenceComplete
-
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 ReportedException
createReportedException(java.lang.Throwable e, int i)
boolean
equals(java.lang.Object obj)
boolean
executeCommand()
Executes the command on the dataset.void
fillModifiedData(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.Icon
getDescriptionIcon()
Provides a descriptive icon of this command.java.lang.String
getDescriptionText()
Provides a description text representing this command.Command
getLastCommand()
Returns the last command.java.lang.String
getName()
Returns the command name used in description text.java.util.Collection<? extends OsmPrimitive>
getParticipatingPrimitives()
Return the primitives that take part in this command.int
hashCode()
protected void
setSequence(Command... sequence)
protected void
setSequenceComplete(boolean sequenceComplete)
void
undoCommand()
Undoes the command.protected void
undoCommands(int start)
static Command
wrapIfNeeded(java.lang.String name, java.util.Collection<Command> sequenz)
Convenient constructor, if the commands are known at compile time.static Command
wrapIfNeeded(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 benull
name
- 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: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 classCommand
- Returns:
- true
-
getLastCommand
public Command getLastCommand()
Returns the last command.- Returns:
- The last command, or
null
if 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: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 classCommand
-
fillModifiedData
public void fillModifiedData(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.Collection<OsmPrimitive> added)
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 classCommand
- Parameters:
modified
- The modified primitivesdeleted
- The deleted primitivesadded
- The added primitives
-
getDescriptionText
public java.lang.String getDescriptionText()
Description copied from interface:PseudoCommand
Provides 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:PseudoCommand
Provides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getChildren
public java.util.Collection<PseudoCommand> 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
public java.util.Collection<? extends OsmPrimitive> 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 interfacePseudoCommand
- Overrides:
getParticipatingPrimitives
in classCommand
- Returns:
- primitives that take part in this command
-
setSequence
protected final void setSequence(Command... sequence)
-
setSequenceComplete
protected final void setSequenceComplete(boolean sequenceComplete)
-
-