Changeset 3336 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-06-19T14:23:54+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r2512 r3336 139 139 private boolean isDataSetEmpty(OsmDataLayer layer) { 140 140 for (OsmPrimitive osm : layer.data.allNonDeletedPrimitives()) 141 if (!osm.isDeleted() || !osm.isNew ())141 if (!osm.isDeleted() || !osm.isNewOrUndeleted()) 142 142 return false; 143 143 return true; -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r3206 r3336 78 78 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 79 79 for (OsmPrimitive p: primitives) { 80 if (p.isNew ()) {80 if (p.isNewOrUndeleted()) { 81 81 ret.add(p); 82 } else if (p.is Visible() && p.isModified() && !p.isIncomplete()) {82 } else if (p.isModified() && !p.isIncomplete()) { 83 83 ret.add(p); 84 84 } … … 171 171 * Computes the collection of primitives to upload, given a collection of candidate 172 172 * primitives. 173 * Some of the candidates are excluded, i.e. if they aren't modified or if they 174 * aren't visible. 173 * Some of the candidates are excluded, i.e. if they aren't modified. 175 174 * Other primitives are added. A typical case is a primitive which is new and and 176 175 * which is referred by a modified relation. In order to upload the relation the … … 187 186 188 187 public void visit(Node n) { 189 if (n.isNew () || ((n.isModified() || n.isDeleted()) && n.isVisible())) {188 if (n.isNewOrUndeleted() || n.isModified() || n.isDeleted()) { 190 189 // upload new nodes as well as modified and deleted ones 191 190 hull.add(n); … … 194 193 195 194 public void visit(Way w) { 196 if (w.isNew () || ((w.isModified() || w.isDeleted()) && w.isVisible())) {195 if (w.isNewOrUndeleted() || w.isModified() || w.isDeleted()) { 197 196 // upload new ways as well as modified and deleted ones 198 197 hull.add(w); … … 206 205 207 206 public void visit(Relation r) { 208 if (r.isNew () || ((r.isModified() || r.isDeleted()) && r.isVisible())) {207 if (r.isNewOrUndeleted() || r.isModified() || r.isDeleted()) { 209 208 hull.add(r); 210 209 for (OsmPrimitive p : r.getMemberPrimitives()) { … … 213 212 // so wont check here for deleted primitives here 214 213 // 215 if (p.isNew ()) {214 if (p.isNewOrUndeleted()) { 216 215 p.visit(this); 217 216 } … … 295 294 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 296 295 for (OsmPrimitive p: toUpload) { 297 if (p.isDeleted() && !p.isNew ()) {296 if (p.isDeleted() && !p.isNewOrUndeleted()) { 298 297 ret.add(p); 299 298 } -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r3317 r3336 562 562 private static class Modified extends Match { 563 563 @Override public boolean match(OsmPrimitive osm) { 564 return osm.isModified() || osm.isNew ();564 return osm.isModified() || osm.isNewOrUndeleted(); 565 565 } 566 566 @Override public String toString() {return "modified";} -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r3317 r3336 445 445 if (osm.isIncomplete()) 446 446 incomplete = true; 447 else if (osm instanceof Node && !osm.isNew ()447 else if (osm instanceof Node && !osm.isNewOrUndeleted() 448 448 && !a.contains(((Node) osm).getCoor())) 449 449 outside = true; -
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r3083 r3336 61 61 continue; 62 62 } 63 if (osm.isNew () && !osm.isDeleted()) {63 if (osm.isNewOrUndeleted() && !osm.isDeleted()) { 64 64 toAdd.add(osm); 65 65 } else if (osm.isModified() && !osm.isDeleted()) { 66 66 toUpdate.add(osm); 67 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() ) {67 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() && osm.isVisible()) { 68 68 toDelete.add(osm); 69 69 } … … 198 198 toDelete.clear(); 199 199 for (OsmPrimitive osm: primitives) { 200 if (osm.isNew () && !osm.isDeleted()) {200 if (osm.isNewOrUndeleted() && !osm.isDeleted()) { 201 201 toAdd.addLast(osm); 202 202 } else if (osm.isModified() && !osm.isDeleted()) { 203 203 toUpdate.addLast(osm); 204 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() ) {204 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() && osm.isVisible()) { 205 205 toDelete.addFirst(osm); 206 206 } … … 312 312 boolean refersToNewRelation = false; 313 313 for (RelationMember m : relation.getMembers()) { 314 if (m.isRelation() && m.getMember().isNew ()) {314 if (m.isRelation() && m.getMember().isNewOrUndeleted()) { 315 315 refersToNewRelation = true; 316 316 break; … … 350 350 this.relations = new HashSet<Relation>(); 351 351 for(Relation relation: relations) { 352 if (!relation.isNew () ) {352 if (!relation.isNewOrUndeleted() ) { 353 353 continue; 354 354 } 355 355 this.relations.add(relation); 356 356 for (RelationMember m: relation.getMembers()) { 357 if (m.isRelation() && m.getMember().isNew ()) {357 if (m.isRelation() && m.getMember().isNewOrUndeleted()) { 358 358 addDependency(relation, (Relation)m.getMember()); 359 359 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r3053 r3336 189 189 Node targetNode = (Node)getMergeTarget(sourceNode); 190 190 if (targetNode != null) { 191 if (targetNode.isVisible()) { 192 newNodes.add(targetNode); 193 if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) { 194 conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true)); 195 targetNode.setDeleted(false); 196 } 197 } else { 198 target.setModified(true); 191 newNodes.add(targetNode); 192 if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) { 193 conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true)); 194 targetNode.setDeleted(false); 199 195 } 200 196 } else … … 220 216 if (targetMember == null) 221 217 throw new IllegalStateException(tr("Missing merge target of type {0} with id {1}", sourceMember.getType(), sourceMember.getUniqueId())); 222 if (targetMember.isVisible()) { 223 RelationMember newMember = new RelationMember(sourceMember.getRole(), targetMember); 224 newMembers.add(newMember); 225 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) { 226 conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true)); 227 targetMember.setDeleted(false); 228 } 229 } else { 230 target.setModified(true); 218 RelationMember newMember = new RelationMember(sourceMember.getRole(), targetMember); 219 newMembers.add(newMember); 220 if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) { 221 conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true)); 222 targetMember.setDeleted(false); 231 223 } 232 224 } … … 252 244 // target.version > source.version => keep target version 253 245 return true; 254 if (! target.isVisible() && source.isVisible() ) {246 if (! target.isVisible() && source.isVisible() && target.getVersion() == source.getVersion()) { 255 247 // should not happen 256 // FIXME: this message does not make sense, source version can not be lower than 257 // target version at this point 258 logger.warning(tr("Target object with id {0} and version {1} is visible although " 259 + "source object with lower version {2} is not visible. " 260 + "Cannot deal with this inconsistency. Keeping target object. ", 261 Long.toString(target.getId()),Long.toString(target.getVersion()), Long.toString(source.getVersion()) 262 )); 248 conflicts.add(target,source); 263 249 } else if (target.isVisible() && ! source.isVisible()) { 264 250 // this is always a conflict because the user has to decide whether -
trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
r3274 r3336 127 127 public void checkZeroNodesWays() { 128 128 for (Way way:dataSet.getWays()) { 129 if (way.isUsable() && way. isVisible() && way.getNodesCount() == 0) {129 if (way.isUsable() && way.getNodesCount() == 0) { 130 130 printError("WARN - ZERO NODES", "Way %s has zero nodes", way); 131 131 } else if (way.isUsable() && way.getNodesCount() == 1) { -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r3300 r3336 392 392 393 393 /** 394 * Replies <code>true</code> if the object has been deleted on the server and was undeleted by the user. 395 * @return <code>true</code> if the object has been undeleted 396 */ 397 public boolean isUndeleted() { 398 return (flags & (FLAG_VISIBLE + FLAG_DELETED)) == 0; 399 } 400 401 /** 394 402 * Replies <code>true</code>, if the object is usable (i.e. complete 395 403 * and not deleted). … … 427 435 public static Predicate<OsmPrimitive> nonDeletedPredicate = new Predicate<OsmPrimitive>() { 428 436 public boolean evaluate(OsmPrimitive primitive) { 429 return primitive.isVisible() &&!primitive.isDeleted();437 return !primitive.isDeleted(); 430 438 } 431 439 }; … … 433 441 public static Predicate<OsmPrimitive> nonDeletedCompletePredicate = new Predicate<OsmPrimitive>() { 434 442 public boolean evaluate(OsmPrimitive primitive) { 435 return primitive.isVisible() &&!primitive.isDeleted() && !primitive.isIncomplete();443 return !primitive.isDeleted() && !primitive.isIncomplete(); 436 444 } 437 445 }; … … 439 447 public static Predicate<OsmPrimitive> nonDeletedPhysicalPredicate = new Predicate<OsmPrimitive>() { 440 448 public boolean evaluate(OsmPrimitive primitive) { 441 return primitive.isVisible() &&!primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation);449 return !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation); 442 450 } 443 451 }; … … 445 453 public static Predicate<OsmPrimitive> modifiedPredicate = new Predicate<OsmPrimitive>() { 446 454 public boolean evaluate(OsmPrimitive primitive) { 447 return primitive.is Visible() && primitive.isModified();455 return primitive.isModified(); 448 456 } 449 457 }; … … 537 545 public boolean isNew() { 538 546 return id <= 0; 547 } 548 549 /** 550 * 551 * @return True if primitive is new or undeleted 552 * @see #isNew() 553 * @see #isUndeleted() 554 */ 555 public boolean isNewOrUndeleted() { 556 return (id <= 0) || ((flags & (FLAG_VISIBLE + FLAG_DELETED)) == 0); 539 557 } 540 558 … … 722 740 flags &= ~FLAG_DELETED; 723 741 } 724 setModified(deleted );742 setModified(deleted ^ !isVisible()); 725 743 if (dataSet != null) { 726 744 if (deleted) { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r3327 r3336 420 420 final StringBuilder text = new StringBuilder(); 421 421 String name = osm.getDisplayName(DefaultNameFormatter.getInstance()); 422 if (osm.isNew () || osm.isModified()) {422 if (osm.isNewOrUndeleted() || osm.isModified()) { 423 423 name = "<i><b>"+ name + "*</b></i>"; 424 424 } -
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r3323 r3336 48 48 49 49 private ValidationListener validationListener = new ValidationListener() { 50 @Override51 50 public boolean validatePreferences() { 52 51 if (sources.hasActiveStylesChanged()) { -
trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
r3083 r3336 125 125 if (!p.isDeleted()) { 126 126 p.setOsmId(entry.new_id, entry.new_version); 127 p.setVisible(true); 127 128 } 128 129 if (cs != null && !cs.isNew()) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r3212 r3336 275 275 osm.setOsmId(osm.getId(), Integer.parseInt(ret.trim())); 276 276 osm.setChangesetId(getChangeset().getId()); 277 osm.setVisible(true); 277 278 } catch(NumberFormatException e) { 278 279 throw new OsmTransferException(tr("Unexpected format of new version of modified primitive ''{0}''. Got ''{1}''.", osm.getId(), ret)); -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r3321 r3336 98 98 99 99 private boolean shouldWrite(OsmPrimitive osm) { 100 return !osm.isNew () || !osm.isDeleted();100 return !osm.isNewOrUndeleted() || !osm.isDeleted(); 101 101 } 102 102
Note:
See TracChangeset
for help on using the changeset viewer.