Changeset 34790 in osm for applications/editors/josm/plugins
- Timestamp:
- 2018-12-23T08:23:59+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
r34785 r34790 9 9 import java.util.Collection; 10 10 import java.util.HashMap; 11 import java.util.HashSet;12 11 import java.util.Iterator; 13 12 import java.util.List; 14 13 import java.util.Map; 15 14 import java.util.Map.Entry; 16 import java.util.Set;17 15 18 16 import javax.swing.JOptionPane; … … 25 23 import org.openstreetmap.josm.data.osm.Node; 26 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 import org.openstreetmap.josm.data.osm.Relation;28 25 import org.openstreetmap.josm.data.osm.Way; 29 26 import org.openstreetmap.josm.gui.Notification; … … 95 92 } 96 93 97 // fix #16006: Don't generate SequenceCommand when ways are part of the same relation. 98 boolean createSequenceCommand = true; 99 Set<Relation> allWayRefs = new HashSet<>(); 100 for (Way splitWay : splitWays.keySet()) { 101 for (Relation rel : OsmPrimitive.getFilteredList(splitWay.getReferrers(), Relation.class)) { 102 createSequenceCommand &= allWayRefs.add(rel); 94 for (Entry<Way, List<Node>> entry : splitWays.entrySet()) { 95 SplitWayCommand split = SplitWayCommand.split(entry.getKey(), entry.getValue(), selectedWays); 96 if (split != null) { 97 // execute, we need the result, see also #16006 98 UndoRedoHandler.getInstance().add(split); 99 selectedWays.remove(split.getOriginalWay()); 100 selectedWays.addAll(split.getNewWays()); 101 list.add(split); 103 102 } 104 }105 for (Entry<Way, List<Node>> entry : splitWays.entrySet()) {106 SplitWayCommand cmd = SplitWayCommand.split(entry.getKey(), entry.getValue(), selectedWays);107 if (!createSequenceCommand) {108 UndoRedoHandler.getInstance().add(cmd);109 }110 list.add(cmd);111 103 } 112 104 113 105 if (!list.isEmpty()) { 114 if (createSequenceCommand) { 115 UndoRedoHandler.getInstance().add(list.size() == 1 ? list.get(0) : new SequenceCommand(TITLE, list)); 116 } else { 117 new Notification( 118 tr("Affected ways are members of the same relation. {0} actions were created for this split.", 119 list.size())).setIcon(JOptionPane.WARNING_MESSAGE).show(); 106 if (list.size() > 1) { 107 // create a single command for the previously executed commands 108 SequenceCommand seq = new SequenceCommand(TITLE, list); 109 for (int i = 0; i < list.size(); i++) { 110 UndoRedoHandler.getInstance().undo(); 111 } 112 UndoRedoHandler.getInstance().add(seq); 120 113 } 121 114 getLayerManager().getEditDataSet().clearSelection();
Note:
See TracChangeset
for help on using the changeset viewer.