This provides a convenient way for children of Command
to look up state from the original version of an object
before it had the Command run on it.  It might be
used to look up the original 'osm.modified' before the
command, for instance.

---

 core-dave/src/org/openstreetmap/josm/command/Command.java |   17 ++++++++++++++
 1 file changed, 17 insertions(+)

diff -puN src/org/openstreetmap/josm/command/Command.java~addGetOrig-to-Command 
src/org/openstreetmap/josm/command/Command.java
--- core/src/org/openstreetmap/josm/command/Command.java~addGetOrig-to-Command  
2008-05-03 12:08:40.000000000 -0700
+++ core-dave/src/org/openstreetmap/josm/command/Command.java   2008-05-03 
12:08:40.000000000 -0700
@@ -81,6 +81,23 @@ abstract public class Command {
        }
 
        /**
+        * Let's other commands access the original version
+        * of the object.  Usually for undoing.
+        */
+       public OsmPrimitive getOrig(OsmPrimitive osm) {
+               OsmPrimitive o = orig.orig.get(osm);
+               if (o != null)
+                       return o;
+               Main.debug("unable to find osm with id: " + osm.id + " 
hashCode: " + osm.hashCode());
+               for (OsmPrimitive t : orig.orig.keySet()) {
+                       OsmPrimitive to = orig.orig.get(t);
+                       Main.debug("now: " + t.id + " hashCode: " + 
t.hashCode());
+                       Main.debug("orig: " + to.id + " hashCode: " + 
to.hashCode());
+               }
+               return o;
+       }
+
+       /**
         * Called, when a layer has been removed to have the command remove 
itself from
         * any buffer if it is not longer applicable to the dataset (e.g. it 
was part of
         * the removed layer)
_

_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/josm-dev

Reply via email to