Package org.openstreetmap.josm.command
Class PurgeCommand
- java.lang.Object
-
- org.openstreetmap.josm.command.Command
-
- org.openstreetmap.josm.command.PurgeCommand
-
- All Implemented Interfaces:
PseudoCommand
public class PurgeCommand extends Command
Command, to purge a list of primitives.
-
-
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 Storage<PrimitiveData>
makeIncompleteData
protected java.util.Map<PrimitiveId,PrimitiveData>
makeIncompleteDataByPrimId
protected ConflictCollection
purgedConflicts
protected java.util.List<OsmPrimitive>
toPurge
-
Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE
-
-
Constructor Summary
Constructors Constructor Description PurgeCommand(DataSet data, java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<OsmPrimitive> makeIncomplete)
Constructs a newPurgeCommand
(does not handle conflicts).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PurgeCommand
build(java.util.Collection<OsmPrimitive> sel, java.util.List<OsmPrimitive> toPurgeAdditionally)
Creates a newPurgeCommand
to purge selected OSM primitives.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.javax.swing.Icon
getDescriptionIcon()
Provides a descriptive icon of this command.java.lang.String
getDescriptionText()
Provides a description text representing this command.java.util.Collection<? extends OsmPrimitive>
getParticipatingPrimitives()
Return the primitives that take part in this command.int
hashCode()
private static boolean
hasOnlyIncompleteMembers(Relation r, java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<? extends OsmPrimitive> moreToPurge)
private void
init(java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<OsmPrimitive> makeIncomplete)
protected void
saveIncomplete(java.util.Collection<OsmPrimitive> makeIncomplete)
static java.util.List<OsmPrimitive>
topoSort(java.util.Collection<OsmPrimitive> sel)
Sorts a collection of primitives such that for each object its referrers come later in the sorted collection.void
undoCommand()
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
-
toPurge
protected java.util.List<OsmPrimitive> toPurge
-
makeIncompleteData
protected Storage<PrimitiveData> makeIncompleteData
-
makeIncompleteDataByPrimId
protected java.util.Map<PrimitiveId,PrimitiveData> makeIncompleteDataByPrimId
-
purgedConflicts
protected final ConflictCollection purgedConflicts
-
-
Constructor Detail
-
PurgeCommand
public PurgeCommand(DataSet data, java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<OsmPrimitive> makeIncomplete)
Constructs a newPurgeCommand
(does not handle conflicts). This command relies on a number of consistency conditions: - makeIncomplete must be a subset of toPurge. - Each primitive, that is in toPurge but not in makeIncomplete, must have all its referrers in toPurge. - Each element of makeIncomplete must not be new and must have only referrers that are either a relation or included in toPurge.- Parameters:
data
- OSM data settoPurge
- primitives to purgemakeIncomplete
- primitives to make incomplete- Since:
- 11240
-
-
Method Detail
-
init
private void init(java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<OsmPrimitive> makeIncomplete)
-
saveIncomplete
protected final void saveIncomplete(java.util.Collection<OsmPrimitive> makeIncomplete)
-
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
-
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
-
topoSort
public static java.util.List<OsmPrimitive> topoSort(java.util.Collection<OsmPrimitive> sel)
Sorts a collection of primitives such that for each object its referrers come later in the sorted collection.- Parameters:
sel
- collection of primitives to sort- Returns:
- sorted list
-
getDescriptionText
public java.lang.String getDescriptionText()
Description copied from interface:PseudoCommand
Provides a description text representing this command.- Returns:
- description text representing this command
-
getDescriptionIcon
public javax.swing.Icon getDescriptionIcon()
Description copied from interface:PseudoCommand
Provides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
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
-
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
-
build
public static PurgeCommand build(java.util.Collection<OsmPrimitive> sel, java.util.List<OsmPrimitive> toPurgeAdditionally)
Creates a newPurgeCommand
to purge selected OSM primitives.- Parameters:
sel
- selected OSM primitivestoPurgeAdditionally
- optional list that will be filled with primitives to be purged that have not been in the selection- Returns:
- command to purge selected OSM primitives
- Since:
- 12718
-
hasOnlyIncompleteMembers
private static boolean hasOnlyIncompleteMembers(Relation r, java.util.Collection<OsmPrimitive> toPurge, java.util.Collection<? extends OsmPrimitive> moreToPurge)
-
-