Class DeleteCommand

    • Constructor Detail

      • DeleteCommand

        public DeleteCommand​(java.util.Collection<? extends OsmPrimitive> data)
        Constructor. Deletes a collection of primitives in the current edit layer.
        Parameters:
        data - the primitives to delete. Must neither be null nor empty, and belong to a data set
        Throws:
        java.lang.IllegalArgumentException - if data is null or empty
      • DeleteCommand

        public DeleteCommand​(OsmPrimitive data)
        Constructor. Deletes a single primitive in the current edit layer.
        Parameters:
        data - the primitive to delete. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if data is null
      • DeleteCommand

        public DeleteCommand​(DataSet dataset,
                             OsmPrimitive data)
        Constructor for a single data item. Use the collection constructor to delete multiple objects.
        Parameters:
        dataset - the data set context for deleting this primitive. Must not be null.
        data - the primitive to delete. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if data is null
        java.lang.IllegalArgumentException - if layer is null
        Since:
        12718
      • DeleteCommand

        public DeleteCommand​(DataSet dataset,
                             java.util.Collection<? extends OsmPrimitive> data)
        Constructor for a collection of data to be deleted in the context of a specific data set
        Parameters:
        dataset - the dataset context for deleting these primitives. Must not be null.
        data - the primitives to delete. Must neither be null nor empty.
        Throws:
        java.lang.IllegalArgumentException - if dataset is null
        java.lang.IllegalArgumentException - if data is null or empty
        Since:
        11240
    • Method Detail

      • 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 class Command
        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 class 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 class Command
        Parameters:
        modified - The modified primitives
        deleted - The deleted primitives
        added - The added primitives
      • 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
      • getChildren

        public java.util.Collection<PseudoCommandgetChildren()
        Description copied from interface: PseudoCommand
        Returns the subcommands of this command. Override for subclasses that have child commands.
        Returns:
        the subcommands, null if there are no child commands
      • deleteWithReferences

        public static Command deleteWithReferences​(java.util.Collection<? extends OsmPrimitive> selection,
                                                   boolean silent)
        Delete the primitives and everything they reference. If a node is deleted, the node and all ways and relations the node is part of are deleted as well. If a way is deleted, all relations the way is member of are also deleted. If a way is deleted, only the way and no nodes are deleted.
        Parameters:
        selection - The list of all object to be deleted.
        silent - Set to true if the user should not be bugged with additional dialogs
        Returns:
        command A command to perform the deletions, or null of there is nothing to delete.
        Throws:
        java.lang.IllegalArgumentException - if layer is null
        Since:
        12718
      • deleteWithReferences

        public static Command deleteWithReferences​(java.util.Collection<? extends OsmPrimitive> selection)
        Delete the primitives and everything they reference. If a node is deleted, the node and all ways and relations the node is part of are deleted as well. If a way is deleted, all relations the way is member of are also deleted. If a way is deleted, only the way and no nodes are deleted.
        Parameters:
        selection - The list of all object to be deleted.
        Returns:
        command A command to perform the deletions, or null of there is nothing to delete.
        Throws:
        java.lang.IllegalArgumentException - if layer is null
        Since:
        12718
      • delete

        public static Command delete​(java.util.Collection<? extends OsmPrimitive> selection)
        Try to delete all given primitives. If a node is used by a way, it's removed from that way. If a node or a way is used by a relation, inform the user and do not delete. If this would cause ways with less than 2 nodes to be created, delete these ways instead. If they are part of a relation, inform the user and do not delete.
        Parameters:
        selection - the objects to delete.
        Returns:
        command a command to perform the deletions, or null if there is nothing to delete.
        Since:
        12718
      • computeNodesToDelete

        protected static java.util.Collection<NodecomputeNodesToDelete​(java.util.Collection<OsmPrimitive> primitivesToDelete)
        Replies the collection of nodes referred to by primitives in primitivesToDelete which can be deleted too. A node can be deleted if
        Parameters:
        primitivesToDelete - the primitives to delete
        Returns:
        the collection of nodes referred to by primitives in primitivesToDelete which can be deleted too
      • delete

        public static Command delete​(java.util.Collection<? extends OsmPrimitive> selection,
                                     boolean alsoDeleteNodesInWay)
        Try to delete all given primitives. If a node is used by a way, it's removed from that way. If a node or a way is used by a relation, inform the user and do not delete. If this would cause ways with less than 2 nodes to be created, delete these ways instead. If they are part of a relation, inform the user and do not delete.
        Parameters:
        selection - the objects to delete.
        alsoDeleteNodesInWay - true if nodes should be deleted as well
        Returns:
        command a command to perform the deletions, or null if there is nothing to delete.
        Since:
        12718
      • delete

        public static Command delete​(java.util.Collection<? extends OsmPrimitive> selection,
                                     boolean alsoDeleteNodesInWay,
                                     boolean silent)
        Try to delete all given primitives. If a node is used by a way, it's removed from that way. If a node or a way is used by a relation, inform the user and do not delete. If this would cause ways with less than 2 nodes to be created, delete these ways instead. If they are part of a relation, inform the user and do not delete.
        Parameters:
        selection - the objects to delete.
        alsoDeleteNodesInWay - true if nodes should be deleted as well
        silent - set to true if the user should not be bugged with additional questions
        Returns:
        command a command to perform the deletions, or null if there is nothing to delete.
        Since:
        12718
      • deleteWaySegment

        public static Command deleteWaySegment​(WaySegment ws)
        Create a command that deletes a single way segment. The way may be split by this.
        Parameters:
        ws - The way segment that should be deleted
        Returns:
        A matching command to safely delete that segment.
        Since:
        12718
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class Command