Changeset 12726 in josm for trunk/src/org
- Timestamp:
- 2017-09-04T23:45:49+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r12641 r12726 12 12 import org.openstreetmap.josm.command.AddCommand; 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 66 67 67 68 // add the node 68 MainApplication.undoRedo.add(new AddCommand(nnew)); 69 getLayerManager().getEditDataSet().setSelected(nnew); 69 DataSet ds = getLayerManager().getEditDataSet(); 70 MainApplication.undoRedo.add(new AddCommand(ds, nnew)); 71 ds.setSelected(nnew); 70 72 MapView mapView = MainApplication.getMap().mapView; 71 73 if (mapView != null && !mapView.getRealBounds().contains(nnew.getCoor())) { -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r12641 r12726 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.Node; 28 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 137 138 } 138 139 139 Collection<OsmPrimitive> sel = getLayerManager().getEditDataSet().getSelected(); 140 DataSet ds = getLayerManager().getEditDataSet(); 141 Collection<OsmPrimitive> sel = ds.getSelected(); 140 142 List<Node> nodes = OsmPrimitive.getFilteredList(sel, Node.class); 141 143 List<Way> ways = OsmPrimitive.getFilteredList(sel, Way.class); … … 222 224 Node n = new Node(ll); 223 225 nodesToAdd.add(n); 224 cmds.add(new AddCommand( n));226 cmds.add(new AddCommand(ds, n)); 225 227 } 226 228 } … … 234 236 Way newWay = new Way(); 235 237 newWay.setNodes(nodesToAdd); 236 cmds.add(new AddCommand( newWay));238 cmds.add(new AddCommand(ds, newWay)); 237 239 } else { 238 240 Way newWay = new Way(existingWay); 239 241 newWay.setNodes(nodesToAdd); 240 cmds.add(new ChangeCommand( existingWay, newWay));242 cmds.add(new ChangeCommand(ds, existingWay, newWay)); 241 243 } 242 244 -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r12641 r12726 248 248 final String commandName; 249 249 if (existingRelation == null) { 250 list.add(new AddCommand( relation));250 list.add(new AddCommand(selectedWays.iterator().next().getDataSet(), relation)); 251 251 commandName = getName(false); 252 252 } else { -
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r12641 r12726 15 15 import org.openstreetmap.josm.command.SelectCommand; 16 16 import org.openstreetmap.josm.command.SequenceCommand; 17 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import org.openstreetmap.josm.data.osm.Node; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 20 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.MapFrame; 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer;23 23 import org.openstreetmap.josm.tools.Shortcut; 24 24 import org.openstreetmap.josm.tools.Utils; … … 61 61 @Override 62 62 public void actionPerformed(ActionEvent evt) { 63 OsmDataLayer osmLayer = getLayerManager().getEditLayer();64 if ( osmLayer== null)63 DataSet ds = getLayerManager().getEditDataSet(); 64 if (ds == null) 65 65 return; 66 66 MapFrame map = MainApplication.getMap(); 67 67 if (!(map.mapMode instanceof DrawAction)) return; // We are not on draw mode 68 68 69 Collection<Node> selectedPoints = osmLayer.data.getSelectedNodes();70 Collection<Way> selectedLines = osmLayer.data.getSelectedWays();69 Collection<Node> selectedPoints = ds.getSelectedNodes(); 70 Collection<Way> selectedLines = ds.getSelectedWays(); 71 71 if ((selectedPoints.size() > 1) || (selectedLines.size() != 1)) // Unsuitable selection 72 72 return; … … 115 115 } 116 116 MainApplication.undoRedo.add(new SequenceCommand(tr("Follow line"), 117 new ChangeCommand( follower, newFollower),118 new SelectCommand( newFollower.isClosed() // see #10028 - unselect last node when closing a way117 new ChangeCommand(ds, follower, newFollower), 118 new SelectCommand(ds, newFollower.isClosed() // see #10028 - unselect last node when closing a way 119 119 ? Arrays.<OsmPrimitive>asList(follower) 120 120 : Arrays.<OsmPrimitive>asList(follower, newPoint) -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r12641 r12726 24 24 import org.openstreetmap.josm.command.SequenceCommand; 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 import org.openstreetmap.josm.data.osm.DataSet; 26 27 import org.openstreetmap.josm.data.osm.Node; 27 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 84 85 if (!isEnabled()) 85 86 return; 86 Collection<Node> selectedNodes = getLayerManager().getEditDataSet().getSelectedNodes(); 87 DataSet ds = getLayerManager().getEditDataSet(); 88 Collection<Node> selectedNodes = ds.getSelectedNodes(); 87 89 Collection<Command> cmds = new LinkedList<>(); 88 90 Map<Way, MultiMap<Integer, Node>> data = new HashMap<>(); 89 91 90 92 // If the user has selected some ways, only join the node to these. 91 boolean restrictToSelectedWays = 92 !getLayerManager().getEditDataSet().getSelectedWays().isEmpty(); 93 boolean restrictToSelectedWays = !ds.getSelectedWays().isEmpty(); 93 94 94 95 // Planning phase: decide where we'll insert the nodes and put it all in "data" … … 155 156 Way wnew = new Way(w); 156 157 wnew.setNodes(wayNodes); 157 cmds.add(new ChangeCommand( w, wnew));158 cmds.add(new ChangeCommand(ds, w, wnew)); 158 159 } 159 160 -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r12641 r12726 157 157 corrCmds = (new ReverseWayTagCorrector()).execute(w, wnew); 158 158 } 159 return new ReverseWayResult(wnew, corrCmds, new ChangeCommand(w .getDataSet(), w, wnew));159 return new ReverseWayResult(wnew, corrCmds, new ChangeCommand(w, wnew)); 160 160 } 161 161 -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r12718 r12726 593 593 final Way changedWay = new Way(way); 594 594 changedWay.setNodes(wayToKeep.getNodes()); 595 commandList.add(new ChangeCommand(way .getDataSet(), way, changedWay));595 commandList.add(new ChangeCommand(way, changedWay)); 596 596 if (!isMapModeDraw && !newSelection.contains(way)) { 597 597 newSelection.add(way); -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r12663 r12726 303 303 304 304 List<Command> cmds = new LinkedList<>(); 305 cmds.add(new AddCommand( n));305 cmds.add(new AddCommand(selectedNode.getDataSet(), n)); 306 306 if (dialog != null) { 307 307 dialog.update(selectedNode, Collections.singletonList(n), cmds); … … 440 440 Node newNode = new Node(originalNode, true /* clear OSM ID */); 441 441 newNodes.add(newNode); 442 cmds.add(new AddCommand( newNode));442 cmds.add(new AddCommand(originalNode.getDataSet(), newNode)); 443 443 444 444 List<Node> nn = new ArrayList<>(); … … 583 583 if (seen) { 584 584 Node newNode = new Node(n, true /* clear OSM ID */); 585 cmds.add(new AddCommand( newNode));585 cmds.add(new AddCommand(selectedNode.getDataSet(), newNode)); 586 586 newNodes.add(newNode); 587 587 addNodes.add(newNode); -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r12643 r12726 487 487 return; 488 488 } 489 cmds.add(new AddCommand( n));489 cmds.add(new AddCommand(ds, n)); 490 490 491 491 if (!ctrl) { … … 576 576 way = new Way(); 577 577 way.addNode(n0); 578 cmds.add(new AddCommand( way));578 cmds.add(new AddCommand(ds, way)); 579 579 wayToSelect = way; 580 580 } else { -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r12689 r12726 40 40 import org.openstreetmap.josm.data.coor.EastNorth; 41 41 import org.openstreetmap.josm.data.osm.DataIntegrityProblemException; 42 import org.openstreetmap.josm.data.osm.DataSet; 42 43 import org.openstreetmap.josm.data.osm.Node; 43 44 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 592 593 Way wnew = new Way(ws.way); 593 594 wnew.addNode(ws.lowerIndex+1, n); 594 SequenceCommand cmds = new SequenceCommand(tr("Add a new node to an existing way"),595 new AddCommand(n), new ChangeCommand(ws.way, wnew));596 MainApplication.undoRedo.add(cmds);595 DataSet ds = ws.way.getDataSet(); 596 MainApplication.undoRedo.add(new SequenceCommand(tr("Add a new node to an existing way"), 597 new AddCommand(ds, n), new ChangeCommand(ds, ws.way, wnew))); 597 598 } 598 599 } … … 603 604 private void createNewRectangle() { 604 605 if (selectedSegment == null) return; 605 // crete a new rectangle 606 DataSet ds = getLayerManager().getEditDataSet(); 607 // create a new rectangle 606 608 Collection<Command> cmds = new LinkedList<>(); 607 609 Node third = new Node(newN2en); … … 618 620 wnew.addNode(selectedSegment.getFirstNode()); 619 621 // undo support 620 cmds.add(new AddCommand( third));622 cmds.add(new AddCommand(ds, third)); 621 623 if (!dualAlignSegmentCollapsed) { 622 cmds.add(new AddCommand( fourth));623 } 624 cmds.add(new AddCommand( wnew));624 cmds.add(new AddCommand(ds, fourth)); 625 } 626 cmds.add(new AddCommand(ds, wnew)); 625 627 Command c = new SequenceCommand(tr("Extrude Way"), cmds); 626 628 MainApplication.undoRedo.add(c); 627 getLayerManager().getEditDataSet().setSelected(wnew);629 ds.setSelected(wnew); 628 630 } 629 631 … … 634 636 */ 635 637 private void performExtrusion() { 638 DataSet ds = getLayerManager().getEditDataSet(); 636 639 // create extrusion 637 640 Collection<Command> cmds = new LinkedList<>(); … … 661 664 wnew.removeNode(n1Old); 662 665 wayWasModified = true; 663 cmds.add(new AddCommand( n1New));666 cmds.add(new AddCommand(ds, n1New)); 664 667 changedNodes.add(n1New); 665 668 } else { … … 669 672 wayWasModified = true; 670 673 insertionPoint++; 671 cmds.add(new AddCommand( n1New));674 cmds.add(new AddCommand(ds, n1New)); 672 675 changedNodes.add(n1New); 673 676 } … … 691 694 wnew.removeNode(n2Old); 692 695 wayWasModified = true; 693 cmds.add(new AddCommand( n2New));696 cmds.add(new AddCommand(ds, n2New)); 694 697 changedNodes.add(n2New); 695 698 } else { … … 698 701 wnew.addNode(insertionPoint, n2New); 699 702 wayWasModified = true; 700 cmds.add(new AddCommand( n2New));703 cmds.add(new AddCommand(ds, n2New)); 701 704 changedNodes.add(n2New); 702 705 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r12718 r12726 399 399 } 400 400 401 DataSet ds = getLayerManager().getEditDataSet(); 401 402 updateKeyModifiers(e); 402 403 mousePos = e.getPoint(); … … 404 405 if (state == State.SELECTING) { 405 406 if (targetWay != null) { 406 getLayerManager().getEditDataSet().setSelected(targetWay.getPrimitiveId());407 ds.setSelected(targetWay.getPrimitiveId()); 407 408 updateStateByCurrentSelection(); 408 409 } … … 425 426 Node virtualNode = new Node(mv.getEastNorth(mousePos.x, 426 427 mousePos.y)); 427 virtualCmds.add(new AddCommand( virtualNode));428 virtualCmds.add(new AddCommand(ds, virtualNode)); 428 429 429 430 // Looking for candidateSegment copies in ways that are -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java
r12641 r12726 11 11 import java.util.Set; 12 12 13 import org.openstreetmap.josm.Main; 13 14 import org.openstreetmap.josm.command.AddCommand; 14 15 import org.openstreetmap.josm.command.Command; 15 16 import org.openstreetmap.josm.command.SequenceCommand; 16 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 import org.openstreetmap.josm.data.osm.DataSet; 17 19 import org.openstreetmap.josm.data.osm.Node; 18 20 import org.openstreetmap.josm.data.osm.NodeGraph; … … 186 188 187 189 private List<Command> makeAddWayAndNodesCommandList() { 190 DataSet ds = Main.main.getEditDataSet(); 188 191 List<Command> commands = new ArrayList<>(sortedNodes.size() + ways.size()); 189 192 for (int i = 0; i < sortedNodes.size() - (isClosedPath() ? 1 : 0); i++) { 190 commands.add(new AddCommand( sortedNodes.get(i)));193 commands.add(new AddCommand(ds, sortedNodes.get(i))); 191 194 } 192 195 for (Way w : ways) { 193 commands.add(new AddCommand( w));196 commands.add(new AddCommand(ds, w)); 194 197 } 195 198 return commands; -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12641 r12726 1235 1235 1236 1236 private void createMiddleNodeFromVirtual(EastNorth currentEN) { 1237 DataSet ds = getLayerManager().getEditDataSet(); 1237 1238 Collection<Command> virtualCmds = new LinkedList<>(); 1238 virtualCmds.add(new AddCommand( virtualNode));1239 virtualCmds.add(new AddCommand(ds, virtualNode)); 1239 1240 for (WaySegment virtualWay : virtualWays) { 1240 1241 Way w = virtualWay.way; 1241 1242 Way wnew = new Way(w); 1242 1243 wnew.addNode(virtualWay.lowerIndex + 1, virtualNode); 1243 virtualCmds.add(new ChangeCommand( w, wnew));1244 virtualCmds.add(new ChangeCommand(ds, w, wnew)); 1244 1245 } 1245 1246 virtualCmds.add(new MoveCommand(virtualNode, startEN, currentEN)); … … 1248 1249 virtualWays.size()); 1249 1250 MainApplication.undoRedo.add(new SequenceCommand(text, virtualCmds)); 1250 getLayerManager().getEditDataSet().setSelected(Collections.singleton((OsmPrimitive) virtualNode));1251 ds.setSelected(Collections.singleton((OsmPrimitive) virtualNode)); 1251 1252 clear(); 1252 1253 } -
trunk/src/org/openstreetmap/josm/command/AddCommand.java
r12718 r12726 36 36 * Creates the command and specify the element to add in the context of the current edit layer, if any. 37 37 * @param osm The primitive to add 38 * @deprecated to be removed end of 2017. Use {@link #AddCommand(DataSet, OsmPrimitive)} instead 38 39 */ 40 @Deprecated 39 41 public AddCommand(OsmPrimitive osm) { 40 42 this.osm = Objects.requireNonNull(osm, "osm"); -
trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
r12718 r12726 39 39 * Constructs a new {@code AddPrimitivesCommand} to add data to the current edit layer. 40 40 * @param data The OSM primitives data to add. Must not be {@code null} 41 */ 41 * @deprecated to be removed end of 2017. Use {@link #AddPrimitivesCommand(List, DataSet)} instead 42 */ 43 @Deprecated 42 44 public AddPrimitivesCommand(List<PrimitiveData> data) { 43 45 this(data, data); … … 49 51 * @param toSelect The OSM primitives to select at the end. Can be {@code null} 50 52 * @since 5953 51 */ 53 * @deprecated to be removed end of 2017. Use {@link #AddPrimitivesCommand(List, List, DataSet)} instead 54 */ 55 @Deprecated 52 56 public AddPrimitivesCommand(List<PrimitiveData> data, List<PrimitiveData> toSelect) { 53 57 init(data, toSelect); … … 77 81 super(ds); 78 82 init(data, toSelect); 83 } 84 85 /** 86 * Constructs a new {@code AddPrimitivesCommand} to add data to the given data set. 87 * @param data The OSM primitives data to add and select. Must not be {@code null} 88 * @param ds The target data set. Must not be {@code null} 89 * @since 12726 90 */ 91 public AddPrimitivesCommand(List<PrimitiveData> data, DataSet ds) { 92 this(data, data, ds); 79 93 } 80 94 -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r12718 r12726 30 30 31 31 /** 32 * Constructs a new {@code ChangeCommand} in the context of the current edit layer, if any.33 * @param osm The existing primitive to modify 32 * Constructs a new {@code ChangeCommand} in the context of {@code osm} data set. 33 * @param osm The existing primitive to modify. It must belong to a data set 34 34 * @param newOsm The new primitive 35 35 */ 36 36 public ChangeCommand(OsmPrimitive osm, OsmPrimitive newOsm) { 37 this.osm = osm; 38 this.newOsm = newOsm; 39 sanityChecks(); 37 this(osm.getDataSet(), osm, newOsm); 40 38 } 41 39 -
trunk/src/org/openstreetmap/josm/command/ChangeNodesCommand.java
r12663 r12726 10 10 import javax.swing.Icon; 11 11 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 13 14 import org.openstreetmap.josm.data.osm.Node; … … 36 37 */ 37 38 public ChangeNodesCommand(Way way, List<Node> newNodes) { 39 this(way.getDataSet(), way, newNodes); 40 } 41 42 /** 43 * Constructs a new {@code ChangeNodesCommand}. 44 * @param ds The target data set. Must not be {@code null} 45 * @param way The way to modify 46 * @param newNodes The new list of nodes for the given way 47 * @since 12726 48 */ 49 public ChangeNodesCommand(DataSet ds, Way way, List<Node> newNodes) { 50 super(ds); 38 51 this.way = way; 39 52 this.newNodes = newNodes; -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r12663 r12726 13 13 import java.util.List; 14 14 import java.util.Map; 15 import java.util.NoSuchElementException; 15 16 import java.util.Objects; 16 17 import java.util.stream.Collectors; … … 72 73 * Creates a command to change multiple tags of multiple objects 73 74 * 74 * @param objects the objects to modify 75 * @param ds The target data set. Must not be {@code null} 76 * @param objects the objects to modify. Must not be empty 75 77 * @param tags the tags to set 76 */ 77 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, Map<String, String> tags) { 78 * @since 12726 79 */ 80 public ChangePropertyCommand(DataSet ds, Collection<? extends OsmPrimitive> objects, Map<String, String> tags) { 81 super(ds); 78 82 this.tags = tags; 79 83 init(objects); … … 81 85 82 86 /** 87 * Creates a command to change multiple tags of multiple objects 88 * 89 * @param objects the objects to modify. Must not be empty, and objects must belong to a data set 90 * @param tags the tags to set 91 * @throws NullPointerException if objects is null or contain null item 92 * @throws NoSuchElementException if objects is empty 93 */ 94 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, Map<String, String> tags) { 95 this(objects.iterator().next().getDataSet(), objects, tags); 96 } 97 98 /** 83 99 * Creates a command to change one tag of multiple objects 84 100 * 85 * @param objects the objects to modify 101 * @param objects the objects to modify. Must not be empty, and objects must belong to a data set 86 102 * @param key the key of the tag to set 87 103 * @param value the value of the key to set 104 * @throws NullPointerException if objects is null or contain null item 105 * @throws NoSuchElementException if objects is empty 88 106 */ 89 107 public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, String key, String value) { 108 super(objects.iterator().next().getDataSet()); 90 109 this.tags = new HashMap<>(1); 91 110 this.tags.put(key, value); … … 96 115 * Creates a command to change one tag of one object 97 116 * 98 * @param object the object to modify 117 * @param object the object to modify. Must belong to a data set 99 118 * @param key the key of the tag to set 100 119 * @param value the value of the key to set 120 * @throws NullPointerException if object is null 101 121 */ 102 122 public ChangePropertyCommand(OsmPrimitive object, String key, String value) { … … 134 154 @Override 135 155 public boolean executeCommand() { 136 if (objects.isEmpty())137 return true;138 156 final DataSet dataSet = objects.get(0).getDataSet(); 139 157 if (dataSet != null) { -
trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java
r11608 r12726 10 10 import java.util.LinkedList; 11 11 import java.util.List; 12 import java.util.NoSuchElementException; 12 13 import java.util.Objects; 13 14 14 15 import javax.swing.Icon; 15 16 17 import org.openstreetmap.josm.data.osm.DataSet; 16 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 19 import org.openstreetmap.josm.data.validation.util.NameVisitor; … … 66 68 * Constructs a new {@code ChangePropertyKeyCommand}. 67 69 * 68 * @param object the object subject to change replacement 70 * @param object the object subject to change replacement. Must not be null, and belong to a data set 69 71 * @param key The key to replace 70 72 * @param newKey the new value of the key … … 78 80 * Constructs a new {@code ChangePropertyKeyCommand}. 79 81 * 80 * @param objects all objects subject to change replacement 82 * @param objects all objects subject to change replacement. Must not be null or empty, and objects must belong to a data set 81 83 * @param key The key to replace 82 84 * @param newKey the new value of the key 85 * @throws NullPointerException if objects is null or contain null item 86 * @throws NoSuchElementException if objects is empty 83 87 */ 84 88 public ChangePropertyKeyCommand(Collection<? extends OsmPrimitive> objects, String key, String newKey) { 89 this(objects.iterator().next().getDataSet(), objects, key, newKey); 90 } 91 92 /** 93 * Constructs a new {@code ChangePropertyKeyCommand}. 94 * 95 * @param ds The target data set. Must not be {@code null} 96 * @param objects all objects subject to change replacement. 97 * @param key The key to replace 98 * @param newKey the new value of the key 99 * @since 12726 100 */ 101 public ChangePropertyKeyCommand(DataSet ds, Collection<? extends OsmPrimitive> objects, String key, String newKey) { 102 super(ds); 85 103 this.objects = new LinkedList<>(objects); 86 104 this.key = key; -
trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java
r12663 r12726 37 37 /** 38 38 * Constructs a new {@code ChangeRelationMemberRoleCommand}. 39 * @param relation The relation to be changed 39 * @param relation The relation to be changed. Must not be null, and belong to a data set 40 40 * @param position Member position 41 41 * @param newRole New role 42 42 */ 43 43 public ChangeRelationMemberRoleCommand(Relation relation, int position, String newRole) { 44 this.relation = relation; 45 this.position = position; 46 this.newRole = newRole; 44 this(relation.getDataSet(), relation, position, newRole); 47 45 } 48 46 49 47 /** 50 48 * Constructs a new {@code ChangeRelationMemberRoleCommand}. 51 * @param dataSet The data set the role is in 49 * @param dataSet The data set the role is in. Must not be {@code null} 52 50 * @param relation The relation to be changed 53 51 * @param position Member position -
trunk/src/org/openstreetmap/josm/command/Command.java
r12718 r12726 147 147 /** 148 148 * Creates a new command in the context of the current edit layer, if any 149 */ 149 * @deprecated to be removed end of 2017. Use {@link #Command(DataSet)} instead 150 */ 151 @Deprecated 150 152 public Command() { 151 153 this.layer = MainApplication.getLayerManager().getEditLayer(); -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r12718 r12726 75 75 @Override 76 76 public String toString() { 77 return "DeleteChildCommand [osm=" + osm + "]";77 return "DeleteChildCommand [osm=" + osm + ']'; 78 78 } 79 79 } … … 88 88 * Constructor. Deletes a collection of primitives in the current edit layer. 89 89 * 90 * @param data the primitives to delete. Must neither be null nor empty .90 * @param data the primitives to delete. Must neither be null nor empty, and belong to a data set 91 91 * @throws IllegalArgumentException if data is null or empty 92 92 */ 93 93 public DeleteCommand(Collection<? extends OsmPrimitive> data) { 94 CheckParameterUtil.ensureParameterNotNull(data, "data"); 95 this.toDelete = data; 96 checkConsistency(); 94 this(data.iterator().next().getDataSet(), data); 97 95 } 98 96 -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r12348 r12726 9 9 import java.util.LinkedList; 10 10 import java.util.List; 11 import java.util.NoSuchElementException; 11 12 import java.util.Objects; 12 13 … … 84 85 /** 85 86 * Constructs a new {@code MoveCommand} and assign the initial object set and movement vector. 86 * @param objects The primitives to move 87 * @param objects The primitives to move. Must neither be null nor empty. Objects must belong to a data set 87 88 * @param x X difference movement. Coordinates are in northern/eastern 88 89 * @param y Y difference movement. Coordinates are in northern/eastern 90 * @throws NullPointerException if objects is null or contain null item 91 * @throws NoSuchElementException if objects is empty 89 92 */ 90 93 public MoveCommand(Collection<OsmPrimitive> objects, double x, double y) { 94 super(objects.iterator().next().getDataSet()); 91 95 startEN = null; 92 96 saveCheckpoint(); // (0,0) displacement will be saved -
trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java
r12663 r12726 33 33 /** 34 34 * Constructs a new {@code RemoveNodesCommand}. 35 * @param way The way to modify 35 * @param way The way to modify. Must not be null, and belong to a data set 36 36 * @param rmNodes The list of nodes to remove 37 37 */ 38 38 public RemoveNodesCommand(Way way, List<Node> rmNodes) { 39 super(way.getDataSet()); 39 40 this.way = way; 40 41 this.rmNodes = new HashSet<>(rmNodes); -
trunk/src/org/openstreetmap/josm/command/SelectCommand.java
r12350 r12726 28 28 * Constructs a new select command. 29 29 * @param newSelection the primitives to select when executing the command. 30 * @deprecated to be removed end of 2017. Use {@link #SelectCommand(DataSet, Collection)} instead 30 31 */ 32 @Deprecated 31 33 public SelectCommand(Collection<OsmPrimitive> newSelection) { 32 34 if (newSelection == null || newSelection.isEmpty()) { -
trunk/src/org/openstreetmap/josm/command/SequenceCommand.java
r12721 r12726 11 11 import javax.swing.Icon; 12 12 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.gui.layer.Layer; … … 33 34 /** 34 35 * Create the command by specifying the list of commands to execute. 36 * @param ds The target data set. Must not be {@code null} 37 * @param name The description text 38 * @param sequenz The sequence that should be executed 39 * @param continueOnError Determines if the sequence execution should continue after one of its commands fails 40 * @since 12726 41 */ 42 public SequenceCommand(DataSet ds, String name, Collection<Command> sequenz, boolean continueOnError) { 43 super(ds); 44 this.name = name; 45 this.sequence = sequenz.toArray(new Command[sequenz.size()]); 46 this.continueOnError = continueOnError; 47 } 48 49 /** 50 * Create the command by specifying the list of commands to execute. 35 51 * @param name The description text 36 52 * @param sequenz The sequence that should be executed. Must not be null or empty … … 39 55 */ 40 56 public SequenceCommand(String name, Collection<Command> sequenz, boolean continueOnError) { 41 super(sequenz.iterator().next().getAffectedDataSet()); 42 this.name = name; 43 this.sequence = sequenz.toArray(new Command[sequenz.size()]); 44 this.continueOnError = continueOnError; 57 this(sequenz.iterator().next().getAffectedDataSet(), name, sequenz, continueOnError); 45 58 } 46 59 -
trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java
r10663 r12726 6 6 import java.util.Collection; 7 7 import java.util.HashMap; 8 import java.util.LinkedList;9 8 import java.util.Map; 9 import java.util.NoSuchElementException; 10 10 import java.util.Objects; 11 11 … … 28 28 * The nodes to transform. 29 29 */ 30 protected Collection<Node> nodes = new LinkedList<>();30 protected final Collection<Node> nodes; 31 31 32 32 /** 33 33 * List of all old states of the nodes. 34 34 */ 35 protected Map<Node, OldNodeState> oldStates = new HashMap<>();35 protected final Map<Node, OldNodeState> oldStates = new HashMap<>(); 36 36 37 37 /** … … 47 47 * Creates a TransformNodesObject. 48 48 * Find out the impacted nodes and store their initial state. 49 * @param objects objects to fetch nodes from 49 * @param objects objects to fetch nodes from. Must neither be null nor empty. Items must belong to a data set 50 * @throws NullPointerException if objects is null or contain null item 51 * @throws NoSuchElementException if objects is empty 50 52 */ 51 53 public TransformNodesCommand(Collection<? extends OsmPrimitive> objects) { 54 super(objects.iterator().next().getDataSet()); 52 55 this.nodes = AllNodesVisitor.getAllNodes(objects); 53 56 storeOldState(); -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictAddCommand.java
r12718 r12726 79 79 public void undoCommand() { 80 80 DataSet ds = getAffectedDataSet(); 81 if ( !Main.main.containsDataSet(ds)) {81 if (Main.main != null && !Main.main.containsDataSet(ds)) { 82 82 Logging.warn(tr("Layer ''{0}'' does not exist any more. Cannot remove conflict for object ''{1}''.", 83 83 ds.getName(), -
trunk/src/org/openstreetmap/josm/command/conflict/ConflictResolveCommand.java
r12718 r12726 28 28 /** 29 29 * Constructs a new {@code ConflictResolveCommand} in the context of the current edit layer, if any. 30 * @deprecated to be removed end of 2017. Use {@link #ConflictResolveCommand(DataSet)} instead 30 31 */ 32 @Deprecated 31 33 public ConflictResolveCommand() { 32 // Do nothing34 this(Main.main.getEditDataSet()); 33 35 } 34 36 … … 81 83 82 84 DataSet ds = getAffectedDataSet(); 83 if (!Main.main.containsDataSet(ds)) { 84 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", 85 this.toString(), 86 ds.getName() 87 )); 88 return; 85 if (Main.main != null) { 86 if (!Main.main.containsDataSet(ds)) { 87 Logging.warn(tr("Cannot undo command ''{0}'' because layer ''{1}'' is not present any more", 88 this.toString(), 89 ds.getName() 90 )); 91 return; 92 } 93 94 Main.main.setEditDataSet(ds); 89 95 } 90 91 Main.main.setEditDataSet(ds);92 96 reconstituteConflicts(); 93 97 } -
trunk/src/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommand.java
r11452 r12726 34 34 */ 35 35 public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) { 36 super(conflict.getMy().getDataSet()); 36 37 this.conflict = conflict; 37 38 this.decision = decision; -
trunk/src/org/openstreetmap/josm/command/conflict/DeletedStateConflictResolveCommand.java
r11452 r12726 34 34 */ 35 35 public DeletedStateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) { 36 super(conflict.getMy().getDataSet()); 36 37 this.conflict = conflict; 37 38 this.decision = decision; -
trunk/src/org/openstreetmap/josm/command/conflict/ModifiedConflictResolveCommand.java
r12672 r12726 29 29 */ 30 30 public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 31 super(conflict.getMy().getDataSet()); 31 32 this.conflict = conflict; 32 33 } -
trunk/src/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommand.java
r12718 r12726 36 36 @SuppressWarnings("unchecked") 37 37 public RelationMemberConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<RelationMember> mergedMembers) { 38 super(conflict.getMy().getDataSet()); 38 39 this.conflict = (Conflict<Relation>) conflict; 39 40 this.mergedMembers = mergedMembers; -
trunk/src/org/openstreetmap/josm/command/conflict/TagConflictResolveCommand.java
r10671 r12726 50 50 */ 51 51 public TagConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, List<TagMergeItem> mergeItems) { 52 super(conflict.getMy().getDataSet()); 52 53 this.conflict = conflict; 53 54 this.mergeItems = mergeItems; -
trunk/src/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommand.java
r12672 r12726 29 29 */ 30 30 public VersionConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) { 31 super(conflict.getMy().getDataSet()); 31 32 this.conflict = conflict; 32 33 } -
trunk/src/org/openstreetmap/josm/command/conflict/WayNodesConflictResolverCommand.java
r12620 r12726 36 36 @SuppressWarnings("unchecked") 37 37 public WayNodesConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<Node> mergedNodeList) { 38 super(conflict.getMy().getDataSet()); 38 39 this.conflict = (Conflict<Way>) conflict; 39 40 this.mergedNodeList = mergedNodeList; -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r12718 r12726 263 263 264 264 /** 265 * Constructs a new {@code DataSet} initially filled with the given primitives. 266 * @param osmPrimitives primitives to add to this data set 267 * @since 12726 268 */ 269 public DataSet(OsmPrimitive... osmPrimitives) { 270 this(); 271 beginUpdate(); 272 try { 273 for (OsmPrimitive o : osmPrimitives) { 274 addPrimitive(o); 275 } 276 } finally { 277 endUpdate(); 278 } 279 } 280 281 /** 265 282 * Adds a new data source. 266 283 * @param source data source to add -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r12725 r12726 106 106 * @return the east north coordinates or {@code null} if #is 107 107 */ 108 @Override 108 109 public EastNorth getEastNorth() { 109 110 return getEastNorth(Main.getProjection()); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r12691 r12726 168 168 mindist = Main.pref.getDouble(PREFIX + ".node_way_distance", 10.0); 169 169 minmiddledist = Main.pref.getDouble(PREFIX + ".way_way_distance", 0.0); 170 DataSet dataSet = Main.main .getEditDataSet();170 DataSet dataSet = Main.main != null ? Main.main.getEditDataSet() : null; 171 171 dsArea = dataSet == null ? null : dataSet.getDataSourceArea(); 172 172 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12718 r12726 197 197 public static UndoRedoHandler undoRedo; 198 198 199 private static final LayerChangeListener undoRedoCleaner = new LayerChangeListener() { 200 @Override 201 public void layerRemoving(LayerRemoveEvent e) { 202 Layer layer = e.getRemovedLayer(); 203 if (layer instanceof OsmDataLayer) { 204 undoRedo.clean(((OsmDataLayer) layer).data); 205 } 206 } 207 208 @Override 209 public void layerOrderChanged(LayerOrderChangeEvent e) { 210 // Do nothing 211 } 212 213 @Override 214 public void layerAdded(LayerAddEvent e) { 215 // Do nothing 216 } 217 }; 218 199 219 /** 200 220 * Listener that sets the enabled state of undo/redo menu entries. … … 220 240 this.mainFrame = mainFrame; 221 241 undoRedo = super.undoRedo; 222 getLayerManager().addLayerChangeListener(new LayerChangeListener() { 223 @Override 224 public void layerRemoving(LayerRemoveEvent e) { 225 Layer layer = e.getRemovedLayer(); 226 if (layer instanceof OsmDataLayer) { 227 undoRedo.clean(((OsmDataLayer) layer).data); 228 } 229 } 230 231 @Override 232 public void layerOrderChanged(LayerOrderChangeEvent e) { 233 // Do nothing 234 } 235 236 @Override 237 public void layerAdded(LayerAddEvent e) { 238 // Do nothing 239 } 240 }); 242 getLayerManager().addLayerChangeListener(undoRedoCleaner); 241 243 } 242 244 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r12663 r12726 77 77 import org.openstreetmap.josm.data.osm.event.DatasetEventManager; 78 78 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 79 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 79 80 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 80 81 import org.openstreetmap.josm.data.osm.search.SearchSetting; 81 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;82 82 import org.openstreetmap.josm.data.preferences.StringProperty; 83 83 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java
r12718 r12726 103 103 */ 104 104 protected void applyExistingNonConflictingRelation(TagEditorModel tagEditorModel) { 105 Relation editedRelation = new Relation(editor.getRelation()); 105 Relation originRelation = editor.getRelation(); 106 Relation editedRelation = new Relation(originRelation); 106 107 tagEditorModel.applyToPrimitive(editedRelation); 107 108 memberTableModel.applyToRelation(editedRelation); 108 if (!editedRelation.hasEqualSemanticAttributes( editor.getRelation(), false)) {109 MainApplication.undoRedo.add(new ChangeCommand( editor.getRelation(), editedRelation));109 if (!editedRelation.hasEqualSemanticAttributes(originRelation, false)) { 110 MainApplication.undoRedo.add(new ChangeCommand(originRelation, editedRelation)); 110 111 } 111 112 } -
trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
r12719 r12726 158 158 class ChangesetReviewChangeListener implements ChangeListener { 159 159 160 private final String key= "review_requested";160 private static final String KEY = "review_requested"; 161 161 162 162 @Override … … 164 164 if (e.getSource() instanceof ChangesetReviewModel) { 165 165 boolean newState = ((ChangesetReviewModel) e.getSource()).isReviewRequested(); 166 boolean oldState = "yes".equals(Optional.ofNullable(getTagEditorValue( key)).orElse(""));166 boolean oldState = "yes".equals(Optional.ofNullable(getTagEditorValue(KEY)).orElse("")); 167 167 if (oldState != newState) { 168 setProperty( key, newState ? "yes" : null);168 setProperty(KEY, newState ? "yes" : null); 169 169 } 170 170 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r12641 r12726 12 12 import org.openstreetmap.josm.command.AddCommand; 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 96 97 } 97 98 99 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 98 100 if (node == null) { 99 101 node = new Node(ll); 100 102 // Now execute the commands to add this node. 101 MainApplication.undoRedo.add(new AddCommand( node));103 MainApplication.undoRedo.add(new AddCommand(ds, node)); 102 104 } 103 105 104 MainApplication.getLayerManager().getEditDataSet().setSelected(node);106 ds.setSelected(node); 105 107 if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 106 108 AutoScaleAction.autoScale("selection"); -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r12641 r12726 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 import org.openstreetmap.josm.data.osm.DataSet; 21 22 import org.openstreetmap.josm.data.osm.Node; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 148 149 nd = new Node(ll); 149 150 // Now execute the commands to add this node. 150 commands.add(new AddCommand( nd));151 commands.add(new AddCommand(Main.main.getEditDataSet(), nd)); 151 152 addedNodes.put(ll, nd); 152 153 } … … 166 167 } 167 168 allCoordinates.clear(); 168 commands.add(new AddCommand(way)); 169 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 170 commands.add(new AddCommand(ds, way)); 169 171 MainApplication.undoRedo.add(new SequenceCommand(tr("Add way"), commands)); 170 MainApplication.getLayerManager().getEditDataSet().setSelected(way);172 ds.setSelected(way); 171 173 if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { 172 174 AutoScaleAction.autoScale("selection"); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r12718 r12726 228 228 newWay.setNodes(newNodes[pos]); 229 229 230 cmds.add(new ChangeCommand( way, newWay));230 cmds.add(new ChangeCommand(dataset, way, newWay)); 231 231 } 232 232
Note:
See TracChangeset
for help on using the changeset viewer.