Changeset 12689 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-08-28T19:09:01+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - refactor MergeNodesAction to avoid unneeded GUI dependence in DuplicateNode test

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r12663 r12689  
    9393        if (targetNode != null) {
    9494            Node targetLocationNode = selectTargetLocationNode(selectedNodes);
    95             Command cmd = mergeNodes(getLayerManager().getEditLayer(), selectedNodes, targetNode, targetLocationNode);
     95            Command cmd = mergeNodes(selectedNodes, targetNode, targetLocationNode);
    9696            if (cmd != null) {
    9797                MainApplication.undoRedo.add(cmd);
     
    272272
    273273        if (target != null) {
    274             Command cmd = mergeNodes(layer, nodes, target, targetLocationNode);
     274            Command cmd = mergeNodes(nodes, target, targetLocationNode);
    275275            if (cmd != null) {
    276276                MainApplication.undoRedo.add(cmd);
     
    281281
    282282    /**
    283      * Merges the nodes in {@code nodes} at the specified node's location. Uses the dataset
    284      * managed by {@code layer} as reference.
    285      *
    286      * @param layer layer the reference data layer. Must not be null.
     283     * Merges the nodes in {@code nodes} at the specified node's location.
     284     *
     285     * @param layer unused
    287286     * @param nodes the collection of nodes. Ignored if null.
    288287     * @param targetLocationNode this node's location will be used for the targetNode.
    289288     * @return The command necessary to run in order to perform action, or {@code null} if there is nothing to do
    290289     * @throws IllegalArgumentException if {@code layer} is null
    291      */
     290     * @deprecated use {@link #mergeNodes(Collection, Node)} instead
     291     */
     292    @Deprecated
    292293    public static Command mergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetLocationNode) {
     294        return mergeNodes(nodes, targetLocationNode);
     295    }
     296
     297    /**
     298     * Merges the nodes in {@code nodes} at the specified node's location.
     299     *
     300     * @param nodes the collection of nodes. Ignored if null.
     301     * @param targetLocationNode this node's location will be used for the targetNode.
     302     * @return The command necessary to run in order to perform action, or {@code null} if there is nothing to do
     303     * @throws IllegalArgumentException if {@code layer} is null
     304     * @since 12689
     305     */
     306    public static Command mergeNodes(Collection<Node> nodes, Node targetLocationNode) {
    293307        if (nodes == null) {
    294308            return null;
     
    296310        Set<Node> allNodes = new HashSet<>(nodes);
    297311        allNodes.add(targetLocationNode);
    298         return mergeNodes(layer, nodes, selectTargetNode(allNodes), targetLocationNode);
    299     }
    300 
    301     /**
    302      * Merges the nodes in <code>nodes</code> onto one of the nodes. Uses the dataset
    303      * managed by <code>layer</code> as reference.
    304      *
    305      * @param layer layer the reference data layer. Must not be null.
     312        return mergeNodes(nodes, selectTargetNode(allNodes), targetLocationNode);
     313    }
     314
     315    /**
     316     * Merges the nodes in <code>nodes</code> onto one of the nodes.
     317     *
    306318     * @param nodes the collection of nodes. Ignored if null.
    307319     * @param targetNode the target node the collection of nodes is merged to. Must not be null.
     
    310322     * @throws IllegalArgumentException if layer is null
    311323     */
    312     public static Command mergeNodes(OsmDataLayer layer, Collection<Node> nodes, Node targetNode, Node targetLocationNode) {
    313         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
     324    public static Command mergeNodes(Collection<Node> nodes, Node targetNode, Node targetLocationNode) {
    314325        CheckParameterUtil.ensureParameterNotNull(targetNode, "targetNode");
    315326        if (nodes == null) {
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r12643 r12689  
    722722        Node targetNode = MergeNodesAction.selectTargetNode(changedNodes);
    723723        Node locNode = MergeNodesAction.selectTargetLocationNode(changedNodes);
    724         Command mergeCmd = MergeNodesAction.mergeNodes(MainApplication.getLayerManager().getEditLayer(), changedNodes, targetNode, locNode);
     724        Command mergeCmd = MergeNodesAction.mergeNodes(changedNodes, targetNode, locNode);
    725725        if (mergeCmd != null) {
    726726            MainApplication.undoRedo.add(mergeCmd);
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r12636 r12689  
    3434import org.openstreetmap.josm.data.validation.Test;
    3535import org.openstreetmap.josm.data.validation.TestError;
    36 import org.openstreetmap.josm.gui.MainApplication;
    3736import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    3837import org.openstreetmap.josm.tools.MultiMap;
     
    334333
    335334            if (Command.checkOutlyingOrIncompleteOperation(nodes, Collections.singleton(target)) == Command.IS_OK)
    336                 return MergeNodesAction.mergeNodes(MainApplication.getLayerManager().getEditLayer(), nodes, target);
     335                return MergeNodesAction.mergeNodes(nodes, target);
    337336        }
    338337
Note: See TracChangeset for help on using the changeset viewer.