diff --git a/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java b/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
index afa7c9f..468c33f 100644
|
a
|
b
|
public class JoinNodeWayAction extends JosmAction {
|
| 35 | 35 | public void actionPerformed(ActionEvent e) { |
| 36 | 36 | if (!isEnabled()) |
| 37 | 37 | return; |
| 38 | | Collection<OsmPrimitive> sel = getCurrentDataSet().getSelected(); |
| 39 | | if (sel.size() < 1) return; |
| | 38 | Collection<Node> selectedNodes = getCurrentDataSet().getSelectedNodes(); |
| | 39 | // Allow multiple selected nodes too? |
| | 40 | if (selectedNodes.size() != 1) return; |
| | 41 | |
| | 42 | Node node = selectedNodes.iterator().next(); |
| 40 | 43 | |
| 41 | 44 | Collection<Command> cmds = new LinkedList<Command>(); |
| 42 | 45 | |
| 43 | | for (OsmPrimitive osm : sel) { |
| 44 | | if (!(osm instanceof Node)) { |
| 45 | | continue; |
| 46 | | } |
| 47 | | Node node = (Node) osm; |
| | 46 | // If the user has selected some ways, only join the node to these. |
| | 47 | boolean restrictToSelectedWays = |
| | 48 | getCurrentDataSet().getSelectedWays().size() > 0; |
| 48 | 49 | |
| 49 | 50 | List<WaySegment> wss = Main.map.mapView.getNearestWaySegments( |
| 50 | 51 | Main.map.mapView.getPoint(node), OsmPrimitive.isSelectablePredicate); |
| 51 | 52 | HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>(); |
| 52 | 53 | for (WaySegment ws : wss) { |
| | 54 | // Maybe cleaner to pass a "isSelected" predicate to getNearestWaySegements, but this is atm. less invasive. |
| | 55 | if(restrictToSelectedWays && !ws.way.isSelected()) { |
| | 56 | continue; |
| | 57 | } |
| | 58 | |
| 53 | 59 | List<Integer> is; |
| 54 | 60 | if (insertPoints.containsKey(ws.way)) { |
| 55 | 61 | is = insertPoints.get(ws.way); |
| … |
… |
public class JoinNodeWayAction extends JosmAction {
|
| 80 | 86 | wnew.setNodes(nodesToAdd); |
| 81 | 87 | cmds.add(new ChangeCommand(w, wnew)); |
| 82 | 88 | } |
| 83 | | } |
| 84 | | if (cmds.size() == 0) return; |
| 85 | | Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds)); |
| 86 | | Main.map.repaint(); |
| | 89 | if (cmds.size() == 0) return; |
| | 90 | Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds)); |
| | 91 | Main.map.repaint(); |
| 87 | 92 | } |
| 88 | 93 | |
| 89 | 94 | private static void pruneSuccsAndReverse(List<Integer> is) { |