Package org.openstreetmap.josm.command
Class AddCommand
- java.lang.Object
-
- org.openstreetmap.josm.command.Command
-
- org.openstreetmap.josm.command.AddCommand
-
- All Implemented Interfaces:
PseudoCommand
public class AddCommand extends Command
A command that adds an osm primitive to a dataset. Keys cannot be added this way. SeeChangeCommandfor comments on relation back references.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState
-
-
Field Summary
Fields Modifier and Type Field Description private OsmPrimitiveosmThe primitive to add to the dataset.-
Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE
-
-
Constructor Summary
Constructors Constructor Description AddCommand(DataSet data, OsmPrimitive osm)Creates the command and specify the element to add in the context of the given data set.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidcheckNodeStyles(OsmPrimitive osm)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.javax.swing.IcongetDescriptionIcon()Provides a descriptive icon of this command.java.lang.StringgetDescriptionText()Provides a description text representing this command.java.util.Collection<OsmPrimitive>getParticipatingPrimitives()Return the primitives that take part in this command.inthashCode()voidundoCommand()Undoes the command.-
Methods inherited from class org.openstreetmap.josm.command.Command
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrig
-
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
-
-
-
-
Field Detail
-
osm
private final OsmPrimitive osm
The primitive to add to the dataset.
-
-
Constructor Detail
-
AddCommand
public AddCommand(DataSet data, OsmPrimitive osm)
Creates the command and specify the element to add in the context of the given data set.- Parameters:
data- The data set. Must not benullosm- The primitive to add- Since:
- 11240
-
-
Method Detail
-
checkNodeStyles
protected static final void checkNodeStyles(OsmPrimitive osm)
-
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
-
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
-
getDescriptionIcon
public javax.swing.Icon getDescriptionIcon()
Description copied from interface:PseudoCommandProvides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getParticipatingPrimitives
public java.util.Collection<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
-
-