Ticket #7239: multijoin.diff
File multijoin.diff, 3.1 KB (added by , 13 years ago) |
---|
-
src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
35 35 public void actionPerformed(ActionEvent e) { 36 36 if (!isEnabled()) 37 37 return; 38 Collection<Node> selectedNodes = getCurrentDataSet().getSelectedNodes();39 // Allow multiple selected nodes too?40 if (selectedNodes.size() != 1) return;38 39 Collection<Command> cmds2 = new LinkedList<Command>(); 40 for (Node node : getCurrentDataSet().getSelectedNodes()) { 41 41 42 Node node = selectedNodes.iterator().next();42 Collection<Command> cmds = new LinkedList<Command>(); 43 43 44 Collection<Command> cmds = new LinkedList<Command>(); 44 // If the user has selected some ways, only join the node to these. 45 boolean restrictToSelectedWays = 46 getCurrentDataSet().getSelectedWays().size() > 0; 45 47 46 // If the user has selected some ways, only join the node to these.47 boolean restrictToSelectedWays =48 getCurrentDataSet().getSelectedWays().size() > 0;49 50 48 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( 51 49 Main.map.mapView.getPoint(node), OsmPrimitive.isSelectablePredicate); 52 50 HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); … … 86 84 wnew.setNodes(nodesToAdd); 87 85 cmds.add(new ChangeCommand(w, wnew)); 88 86 } 89 if (cmds.size() == 0) return; 90 Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds)); 91 Main.map.repaint(); 87 88 if (!cmds.isEmpty()) { 89 SequenceCommand sc = new SequenceCommand(tr("Join Node and Line Segment"), cmds) { 90 int state = 0; 91 92 /* 93 * override it to prevent the re-execution on final Main.main.undoRedo.add 94 */ 95 @Override 96 public boolean executeCommand() { 97 switch (state) { 98 case 0: // point A 99 state = 1; 100 return super.executeCommand(); 101 case 1: 102 state = 2; // point B - skip the execution 103 return true; 104 default: 105 return super.executeCommand(); // redo execution point 106 } 107 } 108 }; 109 sc.executeCommand(); // execute it so that next iteration work on modified data (reaches point A) 110 cmds2.add(sc); 111 } 112 } 113 114 Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds2)); // reaches point B 115 Main.map.repaint(); 92 116 } 93 117 94 118 private static void pruneSuccsAndReverse(List<Integer> is) {