Class Command

    • Constructor Detail

      • Command

        protected Command​(DataSet data)
        Creates a new command in the context of a specific data set, without data layer
        Parameters:
        data - the data set. Must not be null.
        Throws:
        java.lang.IllegalArgumentException - if data is null
        Since:
        11240
    • 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 null if 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 primitives
        deleted - The deleted primitives
        added - The added primitives
      • 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 on
        ignore - null or 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 no DataSet is set or if any primitive does not belong to that dataset.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

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