Changeset 35842 in osm
- Timestamp:
- 2021-11-02T07:40:02+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java
r35841 r35842 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; … … 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")); … … 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 … … 326 328 } 327 329 } 328 329 for (Command mpSplitCommand:commands){330 UndoRedoHandler.getInstance().add(mpSplitCommand, false);331 }330 if (commands.size() > 1) 331 UndoRedoHandler.getInstance().add(new SplitObjectCommand(commands), false); 332 else 333 UndoRedoHandler.getInstance().add(commands.iterator().next(), false); 332 334 333 335 mpRelation.getDataSet().setSelected(mpRelations); … … 501 503 mpCreationCommands.add(new ChangeMembersCommand(mpRelation, mpMembers)); 502 504 mpCreationCommands.add(new AddCommand(mpRelation.getDataSet(), newMpRelation)); 503 504 SequenceCommand sequenceCommand = new SequenceCommand(mpRelation.getDataSet(), "Split Multipolygon", mpCreationCommands, false); 505 sequenceCommand.executeCommand(); 506 commands.add(sequenceCommand); 505 mpCreationCommands.forEach(Command::executeCommand); 506 commands.addAll(mpCreationCommands); 507 507 508 508 mpRelations.add(newMpRelation); … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.