Changeset 1169 in josm for trunk/src/org/openstreetmap/josm/data/conflict
- Timestamp:
- 2008-12-23T15:07:05+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/conflict
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/ConflictItem.java
r627 r1169 12 12 public abstract class ConflictItem { 13 13 14 15 14 public String my, their; 15 public Resolution resolution = null; 16 16 17 18 19 20 17 public final void initialize(Map<OsmPrimitive,OsmPrimitive> conflicts) { 18 my = collectStr(conflicts.keySet()); 19 their = collectStr(conflicts.values()); 20 } 21 21 22 23 24 25 22 abstract public boolean hasConflict(OsmPrimitive key, OsmPrimitive value); 23 abstract protected String str(OsmPrimitive osm); 24 abstract public String key(); 25 abstract public void apply(OsmPrimitive target, OsmPrimitive other); 26 26 27 28 29 30 31 32 33 34 35 36 37 38 39 27 protected final String collectStr(Collection<OsmPrimitive> c) { 28 String value = null; 29 for (OsmPrimitive osm : c) { 30 String v = str(osm); 31 if (value == null) 32 value = v; 33 else if (!value.equals(v)) { 34 value = "<html><i><"+tr("different")+"></i></html>"; 35 break; 36 } 37 } 38 return value == null ? "" : value; 39 } 40 40 } -
trunk/src/org/openstreetmap/josm/data/conflict/DeleteConflict.java
r627 r1169 8 8 public class DeleteConflict extends ConflictItem { 9 9 10 11 12 10 @Override public boolean hasConflict(OsmPrimitive key, OsmPrimitive value) { 11 return key.deleted != value.deleted; 12 } 13 13 14 15 16 14 @Override public String key() { 15 return "deleted|"+tr("deleted"); 16 } 17 17 18 19 20 18 @Override protected String str(OsmPrimitive osm) { 19 return osm.deleted ? tr("true") : tr("false"); 20 } 21 21 22 23 24 22 @Override public void apply(OsmPrimitive target, OsmPrimitive other) { 23 target.deleted = other.deleted; 24 } 25 25 } -
trunk/src/org/openstreetmap/josm/data/conflict/PositionConflict.java
r627 r1169 8 8 9 9 public class PositionConflict extends ConflictItem { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 10 11 @Override public boolean hasConflict(OsmPrimitive key, OsmPrimitive value) { 12 return key instanceof Node && !((Node)key).coor.equals(((Node)value).coor); 13 } 14 15 @Override protected String str(OsmPrimitive osm) { 16 return osm instanceof Node ? ((Node)osm).coor.lat()+", "+((Node)osm).coor.lon() : null; 17 } 18 19 @Override public String key() { 20 return "node|"+tr("position"); 21 } 22 23 @Override public void apply(OsmPrimitive target, OsmPrimitive other) { 24 if (target instanceof Node) { 25 ((Node)target).coor = ((Node)other).coor; 26 ((Node)target).eastNorth = ((Node)other).eastNorth; 27 } 28 28 } 29 29 } -
trunk/src/org/openstreetmap/josm/data/conflict/PropertyConflict.java
r627 r1169 5 5 6 6 public class PropertyConflict extends ConflictItem { 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 7 private String key; 8 9 public PropertyConflict(String key) { 10 this.key = key; 11 } 12 13 @Override public boolean hasConflict(OsmPrimitive key, OsmPrimitive value) { 14 String k = key.get(this.key); 15 String v = value.get(this.key); 16 return k == null ? v!=null : !k.equals(v); 17 } 18 19 @Override protected String str(OsmPrimitive osm) { 20 String v = osm.get(key); 21 return v == null ? "" : v; 22 } 23 24 @Override public String key() { 25 return "key|"+key; 26 } 27 28 @Override public void apply(OsmPrimitive target, OsmPrimitive other) { 29 target.put(key, other.get(key)); 30 30 } 31 31 }
Note:
See TracChangeset
for help on using the changeset viewer.