Ignore:
Timestamp:
28.10.2009 19:33:49 (3 years ago)
Author:
Gubaer
Message:

applied #3798: patch by bastiK: Merge nodes tool - respect selection order

File:
1 edited

Legend:

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

    r2333 r2341  
    33 
    44import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.combineTigerTags; 
    5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 
    65import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.completeTagCollectionForEditing; 
    76import static org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing; 
     
    1413import java.util.Collection; 
    1514import java.util.HashSet; 
     15import java.util.LinkedHashSet; 
    1616import java.util.LinkedList; 
    1717import java.util.List; 
     
    5454            return; 
    5555        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected(); 
    56         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class); 
     56        LinkedHashSet<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class); 
    5757        if (selectedNodes.size() < 2) { 
    5858            JOptionPane.showMessageDialog( 
     
    7474 
    7575    /** 
    76      * Selects a node out of a collection of candidate nodes. The selected 
    77      * node will become the target node the remaining nodes are merged to. 
    78      *  
     76     * Find which node to merge into (i.e. which one will be left) 
     77     * The last selected node will become the target node the remaining  
     78     * nodes are merged to. 
     79     *   
    7980     * @param candidates the collection of candidate nodes 
    8081     * @return the selected target node 
    8182     */ 
    82     public static Node selectTargetNode(Collection<Node> candidates) { 
    83         // Find which node to merge into (i.e. which one will be left) 
    84         // - this should be combined from two things: 
    85         //   1. It will be the first node in the list that has a 
    86         //      positive ID number, OR the first node. 
    87         //   2. It will be at the position of the first node in the 
    88         //      list. 
    89         // 
    90         // *However* - there is the problem that the selection list is 
    91         // _not_ in the order that the nodes were clicked on, meaning 
    92         // that the user doesn't know which node will be chosen (so 
    93         // (2) is not implemented yet.)  :-( 
     83    public static Node selectTargetNode(LinkedHashSet<Node> candidates) { 
    9484        Node targetNode = null; 
    95         for (Node n: candidates) { 
    96             if (!n.isNew()) { 
    97                 targetNode = n; 
    98                 break; 
    99             } 
    100         } 
    101         if (targetNode == null) { 
    102             // an arbitrary node 
    103             targetNode = candidates.iterator().next(); 
     85        for (Node n : candidates) { // pick last one 
     86            targetNode = n; 
    10487        } 
    10588        return targetNode; 
Note: See TracChangeset for help on using the changeset viewer.