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
public abstract class Command extends java.lang.Object implements PseudoCommand
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 theDataSetit is operating on.- Since:
 - 21 (creation), 10599 (signature)
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCommand.CloneVisitorstatic classCommand.OldNodeStateSmall helper for holding the interesting part of the old data state of the objects. 
- 
Field Summary
Fields Modifier and Type Field Description private java.util.Map<OsmPrimitive,PrimitiveData>cloneMapthe map of OsmPrimitives in the original state to OsmPrimitives in cloned stateprivate DataSetdatathe dataset which this command is applied tostatic intIS_INCOMPLETEIS_INCOMPLETE: operation on incomplete targetstatic intIS_OKIS_OK : operation is okaystatic intIS_OUTSIDEIS_OUTSIDE : operation on element outside of download area 
- 
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static intcheckOutlyingOrIncompleteOperation(java.util.Collection<? extends OsmPrimitive> primitives, java.util.Collection<? extends OsmPrimitive> ignore)Check whether user is about to operate on data outside of the download area.protected voidensurePrimitivesAreInDataset()Ensures that all primitives that are participating in this command belong to the affected data set.booleanequals(java.lang.Object obj)booleanexecuteCommand()Executes the command on the dataset.abstract 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.DataSetgetAffectedDataSet()Gets the data set this command affects.PrimitiveDatagetOrig(OsmPrimitive osm)Lets other commands access the original version of the object.java.util.Collection<? extends OsmPrimitive>getParticipatingPrimitives()Return the primitives that take part in this command.inthashCode()voidundoCommand()Undoes the command.- 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.openstreetmap.josm.command.PseudoCommand
getChildren, getDescriptionIcon, getDescriptionText 
 - 
 
 - 
 
- 
- 
Field Detail
- 
IS_OK
public static final int IS_OK
IS_OK : operation is okay- See Also:
 - Constant Field Values
 
 
- 
IS_OUTSIDE
public static final int IS_OUTSIDE
IS_OUTSIDE : operation on element outside of download area- See Also:
 - Constant Field Values
 
 
- 
IS_INCOMPLETE
public static final int IS_INCOMPLETE
IS_INCOMPLETE: operation on incomplete target- See Also:
 - Constant Field Values
 
 
- 
cloneMap
private java.util.Map<OsmPrimitive,PrimitiveData> cloneMap
the map of OsmPrimitives in the original state to OsmPrimitives in cloned state 
 - 
 
- 
Method Detail
- 
executeCommand
public boolean 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
public void 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
public PrimitiveData getOrig(OsmPrimitive osm)
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
public DataSet 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(java.util.Collection<OsmPrimitive> modified, java.util.Collection<OsmPrimitive> deleted, java.util.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
public java.util.Collection<? extends OsmPrimitive> 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(java.util.Collection<? extends OsmPrimitive> primitives, java.util.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
protected void 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:
 java.lang.AssertionError- if noDataSetis set or if any primitive does not belong to that dataset.
 
- 
hashCode
public int hashCode()
- Overrides:
 hashCodein classjava.lang.Object
 
- 
equals
public boolean equals(java.lang.Object obj)
- Overrides:
 equalsin classjava.lang.Object
 
 - 
 
 -