Changeset 2284 in josm for trunk/src/org/openstreetmap/josm/command
- Timestamp:
- 2009-10-13T19:40:21+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/Command.java
r2025 r2284 13 13 import org.openstreetmap.josm.data.osm.Node; 14 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 import org.openstreetmap.josm.data.osm.PrimitiveData; 15 16 import org.openstreetmap.josm.data.osm.Relation; 16 17 import org.openstreetmap.josm.data.osm.Way; … … 25 26 * 26 27 * The command remembers the {@see OsmDataLayer} it is operating on. 27 * 28 * 28 29 * @author imi 29 30 */ … … 31 32 32 33 private static final class CloneVisitor extends AbstractVisitor { 33 public Map<OsmPrimitive, OsmPrimitive> orig = new HashMap<OsmPrimitive, OsmPrimitive>();34 public Map<OsmPrimitive, PrimitiveData> orig = new HashMap<OsmPrimitive, PrimitiveData>(); 34 35 35 36 public void visit(Node n) { 36 orig.put(n, n ew Node(n));37 orig.put(n, n.save()); 37 38 } 38 39 public void visit(Way w) { 39 orig.put(w, new Way(w));40 orig.put(w, w.save()); 40 41 } 41 42 public void visit(Relation e) { 42 orig.put(e, new Relation(e));43 orig.put(e, e.save()); 43 44 } 44 45 } 45 46 46 47 /** the map of OsmPrimitives in the original state to OsmPrimitives in cloned state */ 47 private Map<OsmPrimitive, OsmPrimitive> cloneMap = new HashMap<OsmPrimitive, OsmPrimitive>();48 private Map<OsmPrimitive, PrimitiveData> cloneMap = new HashMap<OsmPrimitive, PrimitiveData>(); 48 49 49 50 /** the layer which this command is applied to */ … … 56 57 /** 57 58 * Creates a new command in the context of a specific data layer 58 * 59 * 59 60 * @param layer the data layer 60 61 */ … … 86 87 */ 87 88 public void undoCommand() { 88 for (Entry<OsmPrimitive, OsmPrimitive> e : cloneMap.entrySet()) {89 e.getKey(). cloneFrom(e.getValue());89 for (Entry<OsmPrimitive, PrimitiveData> e : cloneMap.entrySet()) { 90 e.getKey().load(e.getValue(), layer.data); 90 91 } 91 92 } … … 95 96 * any buffer if it is not longer applicable to the dataset (e.g. it was part of 96 97 * the removed layer) 97 * 98 * 98 99 * @param oldLayer the old layer 99 100 * @return true if this command … … 109 110 * of the object. Usually for undoing. 110 111 */ 111 public OsmPrimitivegetOrig(OsmPrimitive osm) {112 OsmPrimitiveo = cloneMap.get(osm);112 public PrimitiveData getOrig(OsmPrimitive osm) { 113 PrimitiveData o = cloneMap.get(osm); 113 114 if (o != null) 114 115 return o; 115 116 Main.debug("unable to find osm with id: " + osm.getId() + " hashCode: " + osm.hashCode()); 116 117 for (OsmPrimitive t : cloneMap.keySet()) { 117 OsmPrimitiveto = cloneMap.get(t);118 PrimitiveData to = cloneMap.get(t); 118 119 Main.debug("now: " + t.getId() + " hashCode: " + t.hashCode()); 119 120 Main.debug("orig: " + to.getId() + " hashCode: " + to.hashCode()); … … 124 125 /** 125 126 * Replies the layer this command is (or was) applied to. 126 * 127 * 127 128 * @return 128 129 */
Note:
See TracChangeset
for help on using the changeset viewer.