Ticket #21491: 21491.patch
File 21491.patch, 3.6 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java
89 89 List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays()); 90 90 List<Relation> selectedRelations = new ArrayList<>(ds.getSelectedRelations()); 91 91 92 Relation selectedMultipolygon = null;93 92 Way selectedWay = null; 94 93 Way splitWay = null; 95 94 … … 118 117 } 119 118 120 119 if ((selectedRelations.size() == 1) && selectedRelations.get(0).isMultipolygon()) { 121 selectedMultipolygon = selectedRelations.get(0); 122 } 123 124 if (selectedMultipolygon != null) { 120 Relation selectedMultipolygon = selectedRelations.get(0); 125 121 if (splitWay == null) { 126 122 showWarningNotification(tr("Splitting multipolygons requires a split way to be selected")); 127 123 return; … … 260 256 } 261 257 SplitWayCommand result = SplitWayCommand.splitWay( 262 258 selectedWay, wayChunks, Collections.<OsmPrimitive>emptyList()); 263 UndoRedoHandler.getInstance().add(result); 264 if (splitWay != null) 265 UndoRedoHandler.getInstance().add(new DeleteCommand(splitWay)); 259 if (splitWay != null) { 260 result.executeCommand(); 261 DeleteCommand delCmd = new DeleteCommand(splitWay); 262 delCmd.executeCommand(); 263 UndoRedoHandler.getInstance().add(new SplitObjectCommand(Arrays.asList(result, delCmd)), false); 264 } else { 265 UndoRedoHandler.getInstance().add(result); 266 } 266 267 getLayerManager().getEditDataSet().setSelected(result.getNewSelection()); 267 268 } 269 268 270 } 269 271 270 272 /** … … 325 327 } 326 328 } 327 329 } 330 if (commands.size() > 1) 331 UndoRedoHandler.getInstance().add(new SplitObjectCommand(commands), false); 332 else 333 UndoRedoHandler.getInstance().add(commands.iterator().next(), false); 328 334 329 for (Command mpSplitCommand : commands) {330 UndoRedoHandler.getInstance().add(mpSplitCommand, false);331 }332 333 335 mpRelation.getDataSet().setSelected(mpRelations); 334 336 return splitResult; 335 337 … … 500 502 List<Command> mpCreationCommands = new ArrayList<>(); 501 503 mpCreationCommands.add(new ChangeMembersCommand(mpRelation, mpMembers)); 502 504 mpCreationCommands.add(new AddCommand(mpRelation.getDataSet(), newMpRelation)); 505 mpCreationCommands.forEach(Command::executeCommand); 506 commands.addAll(mpCreationCommands); 503 507 504 SequenceCommand sequenceCommand = new SequenceCommand(mpRelation.getDataSet(), "Split Multipolygon", mpCreationCommands, false);505 sequenceCommand.executeCommand();506 commands.add(sequenceCommand);507 508 508 mpRelations.add(newMpRelation); 509 509 } 510 510 } … … 594 594 new Notification(msg) 595 595 .setIcon(JOptionPane.WARNING_MESSAGE).show(); 596 596 } 597 598 private static class SplitObjectCommand extends SequenceCommand { 599 SplitObjectCommand(Collection<Command> sequenz) { 600 super(tr("Split Object"), sequenz, true); 601 setSequenceComplete(true); 602 } 603 } 597 604 }