Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java
r14143 r18610 62 62 protected static void commitCommands(Collection<? extends OsmPrimitive> selection, List<Command> commands) { 63 63 if (!commands.isEmpty()) { 64 String title1 = trn("Pasting {0} tag", "Pasting {0} tags", commands.size(), commands.size()); 64 final int changedTags = commands.stream() 65 .filter(ChangePropertyCommand.class::isInstance) 66 .map(ChangePropertyCommand.class::cast) 67 .mapToInt(p -> p.getTags().size()) 68 .sum(); 69 String title1 = trn("Pasting {0} tag", "Pasting {0} tags", changedTags, changedTags); 65 70 String title2 = trn("to {0} object", "to {0} objects", selection.size(), selection.size()); 66 71 @I18n.QuirkyPluralString -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java
r18464 r18610 2 2 package org.openstreetmap.josm.gui.datatransfer; 3 3 4 import static org.junit.jupiter.api.Assertions.assertAll; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 7 8 import java.util.Collections; 9 import java.util.stream.Stream; 8 10 9 11 import org.junit.jupiter.api.extension.RegisterExtension; 10 12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.params.ParameterizedTest; 14 import org.junit.jupiter.params.provider.Arguments; 15 import org.junit.jupiter.params.provider.MethodSource; 11 16 import org.openstreetmap.josm.actions.CopyAction; 17 import org.openstreetmap.josm.command.ChangePropertyCommand; 18 import org.openstreetmap.josm.command.Command; 19 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.data.UndoRedoHandler; 12 21 import org.openstreetmap.josm.data.coor.LatLon; 13 22 import org.openstreetmap.josm.data.osm.DataSet; … … 15 24 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 25 import org.openstreetmap.josm.gui.MainApplication; 26 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 17 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 28 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 72 82 assertEquals("ok", n.get("test")); 73 83 } 84 85 static Stream<Arguments> testNonRegression21324() { 86 return Stream.of( 87 Arguments.of((Runnable) () -> ClipboardUtils.copyString("test=ok\rsomething=else\nnew=line")), 88 Arguments.of((Runnable) () -> { 89 Node nData = new Node(); 90 nData.put("test", "ok"); 91 nData.put("something", "else"); 92 nData.put("new", "line"); 93 ClipboardUtils.copy(new PrimitiveTransferable( 94 PrimitiveTransferData.getDataWithReferences(Collections.singletonList(nData)), null)); 95 }) 96 ); 97 } 98 99 /** 100 * Non-regression test for #21324: Command stack says "pasting 1 tag to [number] objects" regardless of how many tags are pasted 101 */ 102 @ParameterizedTest 103 @MethodSource 104 void testNonRegression21324(Runnable clipboardCopy) { 105 clipboardCopy.run(); 106 Node n = new Node(LatLon.ZERO); 107 MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(n), "testNonRegression21324", null)); 108 109 transferHandler.pasteTags(Collections.singleton(n)); 110 Command command = UndoRedoHandler.getInstance().getLastCommand(); 111 112 assertAll(() -> assertEquals("ok", n.get("test")), 113 () -> assertEquals("else", n.get("something")), 114 () -> assertEquals("line", n.get("new")), 115 () -> assertEquals(1, UndoRedoHandler.getInstance().getUndoCommands().size()), 116 () -> assertTrue((command instanceof SequenceCommand 117 && command.getChildren().stream().allMatch(ChangePropertyCommand.class::isInstance)) 118 || command instanceof ChangePropertyCommand), 119 () -> assertEquals("Sequence: Pasting 3 tags to 1 object", command.getDescriptionText())); 120 } 74 121 }
Note:
See TracChangeset
for help on using the changeset viewer.