Package org.openstreetmap.josm.command
Class Command
java.lang.Object
org.openstreetmap.josm.command.Command
- All Implemented Interfaces:
PseudoCommand
- Direct Known Subclasses:
AbstractNodesCommand,AddCommand,AddPrimitivesCommand,ChangeCommand,ChangeMembersCommand,ChangePropertyCommand,ChangePropertyKeyCommand,ChangeRelationMemberRoleCommand,ConflictAddCommand,ConflictResolveCommand,DeleteCommand,MoveCommand,PurgeCommand,SelectCommand,SequenceCommand,TransformNodesCommand
Classes implementing Command modify a dataset in a specific way. A command is
one atomic action on a specific dataset, such as move or delete.
The command remembers the
DataSet it is operating on.- Since:
- 21 (creation), 10599 (signature)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classstatic classSmall helper for holding the interesting part of the old data state of the objects. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<OsmPrimitive,PrimitiveData> the map of OsmPrimitives in the original state to OsmPrimitives in cloned stateprivate final DataSetthe dataset which this command is applied tostatic final intIS_INCOMPLETE: operation on incomplete targetstatic final intIS_OK : operation is okaystatic final intIS_OUTSIDE : operation on element outside of download area -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcheckOutlyingOrIncompleteOperation(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) Check whether user is about to operate on data outside of the download area.protected voidEnsures that all primitives that are participating in this command belong to the affected data set.booleanbooleanExecutes the command on the dataset.abstract voidfillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Fill in the changed data this command operates on.Gets the data set this command affects.getOrig(OsmPrimitive osm) Lets other commands access the original version of the object.Collection<? extends OsmPrimitive>Return the primitives that take part in this command.inthashCode()voidUndoes the command.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.command.PseudoCommand
getChildren, getDescriptionIcon, getDescriptionText
-
Field Details
-
IS_OK
IS_OK : operation is okay- See Also:
-
IS_OUTSIDE
IS_OUTSIDE : operation on element outside of download area- See Also:
-
IS_INCOMPLETE
IS_INCOMPLETE: operation on incomplete target- See Also:
-
cloneMap
the map of OsmPrimitives in the original state to OsmPrimitives in cloned state -
data
the dataset which this command is applied to
-
-
Constructor Details
-
Command
Creates a new command in the context of a specific data set, without data layer- Parameters:
data- the data set. Must not be null.- Throws:
IllegalArgumentException- if data is null- Since:
- 11240
-
-
Method Details
-
executeCommand
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.
- Returns:
- true
-
undoCommand
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. -
getOrig
Lets other commands access the original version of the object. Usually for undoing.- Parameters:
osm- The requested OSM object- Returns:
- The original version of the requested object, if any
-
getAffectedDataSet
Gets the data set this command affects.- Returns:
- The data set. May be
nullif no layer was set and no edit layer was found. - Since:
- 10467
-
fillModifiedData
public abstract void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Fill in the changed data this command operates on. Add to the lists, don't clear them.- Parameters:
modified- The modified primitivesdeleted- The deleted primitivesadded- The added primitives
-
getParticipatingPrimitives
Return the primitives that take part in this command. The collection is computed during execution.- Specified by:
getParticipatingPrimitivesin interfacePseudoCommand- Returns:
- primitives that take part in this command
-
checkOutlyingOrIncompleteOperation
public static int checkOutlyingOrIncompleteOperation(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) Check whether user is about to operate on data outside of the download area.- Parameters:
primitives- the primitives to operate onignore-nullor a primitive to be ignored- Returns:
- true, if operating on outlying primitives is OK; false, otherwise
-
ensurePrimitivesAreInDataset
Ensures that all primitives that are participating in this command belong to the affected data set. Commands may use this in their update methods to check the consistency of the primitives they operate on.- Throws:
AssertionError- if noDataSetis set or if any primitive does not belong to that dataset.
-
hashCode
-
equals
-