public class DeleteCommand extends Command
Command.OldNodeState
Modifier and Type | Field and Description |
---|---|
private Map<OsmPrimitive,PrimitiveData> |
clonedPrimitives |
private Collection<? extends OsmPrimitive> |
toDelete
The primitives that get deleted.
|
Constructor and Description |
---|
DeleteCommand(Collection<? extends OsmPrimitive> data)
Constructor.
|
DeleteCommand(OsmDataLayer layer,
Collection<? extends OsmPrimitive> data)
Constructor for a collection of data to be deleted in the context of
a specific layer
|
DeleteCommand(OsmDataLayer layer,
OsmPrimitive data)
Constructor for a single data item.
|
DeleteCommand(OsmPrimitive data)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives,
Collection<? extends OsmPrimitive> ignore) |
private void |
checkConsistency() |
protected static Collection<Node> |
computeNodesToDelete(OsmDataLayer layer,
Collection<OsmPrimitive> primitivesToDelete)
Replies the collection of nodes referred to by primitives in
primitivesToDelete which
can be deleted too. |
private static boolean |
confirmRelationDeletion(Collection<Relation> relations) |
static Command |
delete(OsmDataLayer layer,
Collection<? extends OsmPrimitive> selection)
Try to delete all given primitives.
|
static Command |
delete(OsmDataLayer layer,
Collection<? extends OsmPrimitive> selection,
boolean alsoDeleteNodesInWay)
Try to delete all given primitives.
|
static Command |
delete(OsmDataLayer layer,
Collection<? extends OsmPrimitive> selection,
boolean alsoDeleteNodesInWay,
boolean silent)
Try to delete all given primitives.
|
static Command |
deleteWaySegment(OsmDataLayer layer,
WaySegment ws) |
static Command |
deleteWithReferences(OsmDataLayer layer,
Collection<? extends OsmPrimitive> selection)
Delete the primitives and everything they reference.
|
static Command |
deleteWithReferences(OsmDataLayer layer,
Collection<? extends OsmPrimitive> selection,
boolean silent)
Delete the primitives and everything they reference.
|
boolean |
executeCommand()
Executes the command on the dataset.
|
void |
fillModifiedData(Collection<OsmPrimitive> modified,
Collection<OsmPrimitive> deleted,
Collection<OsmPrimitive> added)
Fill in the changed data this command operates on.
|
Collection<PseudoCommand> |
getChildren()
Returns the subcommands of this command.
|
Icon |
getDescriptionIcon()
Provides a descriptive icon of this command.
|
String |
getDescriptionText()
Provides a description text representing this command.
|
Collection<? extends OsmPrimitive> |
getParticipatingPrimitives()
Return the primitives that take part in this command.
|
private Set<OsmPrimitiveType> |
getTypesToDelete() |
void |
undoCommand()
Undoes the command.
|
checkAndConfirmOutlyingOperation, getLayer, getOrig, invalidBecauselayerRemoved
private final Collection<? extends OsmPrimitive> toDelete
private final Map<OsmPrimitive,PrimitiveData> clonedPrimitives
public DeleteCommand(Collection<? extends OsmPrimitive> data) throws IllegalArgumentException
data
- the primitives to delete. Must neither be null nor empty.IllegalArgumentException
- thrown if data is null or emptypublic DeleteCommand(OsmPrimitive data) throws IllegalArgumentException
data
- the primitive to delete. Must not be null.IllegalArgumentException
- thrown if data is nullpublic DeleteCommand(OsmDataLayer layer, OsmPrimitive data) throws IllegalArgumentException
layer
- the layer context for deleting this primitive. Must not be null.data
- the primitive to delete. Must not be null.IllegalArgumentException
- thrown if data is nullIllegalArgumentException
- thrown if layer is nullpublic DeleteCommand(OsmDataLayer layer, Collection<? extends OsmPrimitive> data) throws IllegalArgumentException
layer
- the layer context for deleting these primitives. Must not be null.data
- the primitives to delete. Must neither be null nor empty.IllegalArgumentException
- thrown if layer is nullIllegalArgumentException
- thrown if data is null or emptyprivate void checkConsistency()
public boolean executeCommand()
Command
executeCommand
in class Command
public void undoCommand()
Command
undoCommand
in class Command
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added)
Command
fillModifiedData
in class Command
modified
- The modified primitivesdeleted
- The deleted primitivesadded
- The added primitivesprivate Set<OsmPrimitiveType> getTypesToDelete()
public String getDescriptionText()
PseudoCommand
getDescriptionText
in class PseudoCommand
public Icon getDescriptionIcon()
PseudoCommand
getDescriptionIcon
in class PseudoCommand
public Collection<PseudoCommand> getChildren()
PseudoCommand
getChildren
in class PseudoCommand
public Collection<? extends OsmPrimitive> getParticipatingPrimitives()
Command
getParticipatingPrimitives
in class Command
public static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean silent) throws IllegalArgumentException
layer
- the OsmDataLayer
in whose context primitives are deleted. Must not be null.selection
- The list of all object to be deleted.silent
- Set to true if the user should not be bugged with additional dialogsIllegalArgumentException
- thrown if layer is nullpublic static Command deleteWithReferences(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection)
layer
- the OsmDataLayer
in whose context primitives are deleted. Must not be null.selection
- The list of all object to be deleted.IllegalArgumentException
- thrown if layer is nullpublic static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection)
layer
- the OsmDataLayer
in whose context the primitives are deletedselection
- the objects to delete.protected static Collection<Node> computeNodesToDelete(OsmDataLayer layer, Collection<OsmPrimitive> primitivesToDelete)
primitivesToDelete
which
can be deleted too. A node can be deleted if
OsmPrimitive.isTagged()
primitivesToDelete
layer
- the layer in whose context primitives are deletedprimitivesToDelete
- the primitives to deleteprimitivesToDelete
which
can be deleted toopublic static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay)
layer
- the OsmDataLayer
in whose context the primitives are deletedselection
- the objects to delete.alsoDeleteNodesInWay
- true
if nodes should be deleted as wellpublic static Command delete(OsmDataLayer layer, Collection<? extends OsmPrimitive> selection, boolean alsoDeleteNodesInWay, boolean silent)
layer
- the OsmDataLayer
in whose context the primitives are deletedselection
- the objects to delete.alsoDeleteNodesInWay
- true
if nodes should be deleted as wellsilent
- set to true if the user should not be bugged with additional questionspublic static Command deleteWaySegment(OsmDataLayer layer, WaySegment ws)
public static boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore)
private static boolean confirmRelationDeletion(Collection<Relation> relations)