Changeset 34780 in osm for applications/editors/josm
- Timestamp:
- 2018-12-14T10:40:49+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java
r34454 r34780 9 9 import java.util.Collection; 10 10 import java.util.HashMap; 11 import java.util.HashSet; 11 12 import java.util.Iterator; 12 13 import java.util.List; 13 14 import java.util.Map; 15 import java.util.Map.Entry; 16 import java.util.Set; 14 17 15 18 import javax.swing.JOptionPane; … … 22 25 import org.openstreetmap.josm.data.osm.Node; 23 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm.Relation; 24 28 import org.openstreetmap.josm.data.osm.Way; 25 29 import org.openstreetmap.josm.gui.Notification; … … 34 38 public class SplitOnIntersectionsAction extends JosmAction { 35 39 private static final String TITLE = tr("Split adjacent ways"); 36 40 private static final String TOOL_DESC = tr("Split adjacent ways on T-intersections"); 37 41 public SplitOnIntersectionsAction() { 38 super(TITLE, "dumbutils/splitonintersections", tr("Split adjacent ways on T-intersections"),39 Shortcut.registerShortcut("tools:splitonintersections", tr("Tool: {0}", tr("Split adjacent ways")),42 super(TITLE, "dumbutils/splitonintersections", TOOL_DESC, 43 Shortcut.registerShortcut("tools:splitonintersections", tr("Tool: {0}", TITLE), 40 44 KeyEvent.VK_P, Shortcut.ALT_CTRL_SHIFT), true); 41 45 } … … 84 88 } 85 89 90 if (splitWays.isEmpty()) { 91 new Notification(tr("The selection cannot be used for action ''{0}''", TOOL_DESC)) 92 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 93 return; 94 } 95 96 // fix #16006: Don't generate SequenceCommand when ways are part of the same relation. 97 boolean createSequenceCommand = true; 98 Set<Relation> allWayRefs = new HashSet<>(); 86 99 for (Way splitWay : splitWays.keySet()) { 87 List<List<Node>> wayChunks = SplitWayCommand.buildSplitChunks(splitWay, splitWays.get(splitWay)); 88 if (wayChunks != null) { 89 list.add(SplitWayCommand.splitWay(splitWay, wayChunks, new ArrayList<>(selectedWays))); 100 for (Relation rel : OsmPrimitive.getFilteredList(splitWay.getReferrers(), Relation.class)) { 101 createSequenceCommand &= allWayRefs.add(rel); 90 102 } 103 } 104 for (Entry<Way, List<Node>> entry : splitWays.entrySet()) { 105 SplitWayCommand cmd = SplitWayCommand.split(entry.getKey(), entry.getValue(), selectedWays); 106 if (!createSequenceCommand) { 107 UndoRedoHandler.getInstance().add(cmd); 108 } 109 list.add(cmd); 91 110 } 92 111 93 112 if (!list.isEmpty()) { 94 UndoRedoHandler.getInstance().add(list.size() == 1 ? list.get(0) : new SequenceCommand(TITLE, list)); 113 if (createSequenceCommand) { 114 UndoRedoHandler.getInstance().add(list.size() == 1 ? list.get(0) : new SequenceCommand(TITLE, list)); 115 } else { 116 new Notification( 117 tr("Affected ways are members of the same relation. {0} actions were created for this split.", 118 list.size())).setIcon(JOptionPane.WARNING_MESSAGE).show(); 119 } 95 120 getLayerManager().getEditDataSet().clearSelection(); 96 121 }
Note:
See TracChangeset
for help on using the changeset viewer.