- Timestamp:
- 2009-11-08T15:19:50+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2381 r2410 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.event.ActionEvent; … … 157 157 cmds.add(new ChangeCommand(selectedNode, c)); 158 158 159 Node n = new Node(selectedNode); 160 n.clearOsmId(); 159 Node n = new Node(selectedNode, true); 161 160 162 161 // If this wasn't called from menu, place it where the cursor is/was … … 302 301 if (originalNode == pushNode) { 303 302 // clone the node for all other ways 304 pushNode = new Node(pushNode); 305 pushNode.clearOsmId(); 303 pushNode = new Node(pushNode, true); 306 304 newNodes.add(pushNode); 307 305 cmds.add(new AddCommand(pushNode)); -
trunk/src/org/openstreetmap/josm/command/UndeletePrimitivesCommand.java
r2070 r2410 6 6 import java.util.ArrayList; 7 7 import java.util.Collection; 8 import java.util.List; 8 9 import java.util.logging.Logger; 9 10 … … 25 26 26 27 /** the node to undelete */ 27 private ArrayList<OsmPrimitive> toUndelete;28 private final List<OsmPrimitive> toUndelete = new ArrayList<OsmPrimitive>(); 28 29 29 protected UndeletePrimitivesCommand() {30 toUndelete = new ArrayList<OsmPrimitive>();31 }32 30 /** 33 31 * constructor … … 35 33 */ 36 34 public UndeletePrimitivesCommand(OsmPrimitive node) { 37 this();38 35 toUndelete.add(node); 39 36 } … … 44 41 */ 45 42 public UndeletePrimitivesCommand(OsmPrimitive ... toUndelete) { 46 this();47 43 for (int i=0; i < toUndelete.length; i++) { 48 44 this.toUndelete.add(toUndelete[i]); -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r2405 r2410 68 68 69 69 /** 70 * 71 * @param clone 72 * @param clearId If true, set version to 0 and id to new unique value 73 */ 74 public Node(Node clone, boolean clearId) { 75 super(clone.getUniqueId(), true); 76 cloneFrom(clone); 77 if (clearId) { 78 clearOsmId(); 79 } 80 } 81 82 /** 70 83 * Create an identical clone of the argument (including the id) 71 84 */ 72 85 public Node(Node clone) { 73 super(clone.getUniqueId(), true); 74 cloneFrom(clone); 86 this(clone, false); 75 87 } 76 88 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2407 r2410 378 378 * @throws IllegalArgumentException thrown if id <= 0 379 379 * @throws IllegalArgumentException thrown if version <= 0 380 * @throws DataIntegrityProblemException If id is changed and primitive was already added to the dataset 380 381 */ 381 382 public void setOsmId(long id, int version) { … … 384 385 if (version <= 0) 385 386 throw new IllegalArgumentException(tr("Version > 0 expected. Got {0}.", version)); 387 if (dataSet != null && id != this.id) 388 throw new DataIntegrityProblemException("Id cannot be changed after primitive was added to the dataset"); 386 389 this.id = id; 387 390 this.version = version; … … 391 394 /** 392 395 * Clears the id and version known to the OSM API. The id and the version is set to 0. 393 * incomplete is set to false. 396 * incomplete is set to false. It's preferred to use copy constructor with clearId set to true instead 397 * of calling this method. 394 398 * 395 399 * <strong>Caution</strong>: Do not use this method on primitives which are already added to a {@see DataSet}. 396 * Ways and relations might already refer to the primitive and clearing the OSM ID 397 * result in corrupt data. 398 * 399 * Here's an example use case: 400 * <pre> 401 * // create a clone of an already existing node 402 * Node copy = new Node(otherExistingNode); 403 * 404 * // reset the clones OSM id 405 * copy.clearOsmId(); 406 * </pre> 407 * 400 * 401 * @throws DataIntegrityProblemException If primitive was already added to the dataset 408 402 */ 409 403 public void clearOsmId() { 404 if (dataSet != null) 405 throw new DataIntegrityProblemException("Method cannot be called after primitive was added to the dataset"); 410 406 this.id = generateUniqueId(); 411 407 this.version = 0; -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2407 r2410 140 140 } 141 141 142 /** 143 * Create an identical clone of the argument (including the id) 144 */ 145 public Relation(Relation clone) { 142 public Relation(Relation clone, boolean clearId) { 146 143 super(clone.getUniqueId(), true); 147 144 cloneFrom(clone); 145 if (clearId) { 146 clearOsmId(); 147 } 148 } 149 150 /** 151 * Create an identical clone of the argument (including the id) 152 */ 153 public Relation(Relation clone) { 154 this(clone, false); 148 155 } 149 156 -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2407 r2410 149 149 150 150 /** 151 * Create an identical clone of the argument (including the id).152 * 153 * @param original the original way. Must not be null.154 */ 155 public Way(Way original ) {151 * 152 * @param original 153 * @param clearId 154 */ 155 public Way(Way original, boolean clearId) { 156 156 super(original.getUniqueId(), true); 157 157 cloneFrom(original); 158 if (clearId) { 159 clearOsmId(); 160 } 161 } 162 163 /** 164 * Create an identical clone of the argument (including the id). 165 * 166 * @param original the original way. Must not be null. 167 */ 168 public Way(Way original) { 169 this(original, false); 158 170 } 159 171 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2402 r2410 471 471 472 472 public void launchEditorForDuplicate(Relation original) { 473 Relation copy = new Relation(original.getId()); 474 copy.cloneFrom(original); 475 copy.clearOsmId(); 473 Relation copy = new Relation(original, true); 476 474 copy.setModified(true); 477 475 RelationEditor editor = RelationEditor.getEditor( -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r2398 r2410 92 92 93 93 public void copyTo(OsmPrimitive osm) { 94 // id < 0 possible if read from a file 95 if (id <= 0) { 96 osm.clearOsmId(); 97 } else { 94 // It's not necessary to call clearOsmId for id < 0. The same thing is done by parameterless constructor 95 if (id > 0) { 98 96 osm.setOsmId(id, version); 99 97 }
Note:
See TracChangeset
for help on using the changeset viewer.