]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoDeletePoint.java
Version 3, August 2007
[GpsPrune.git] / tim / prune / undo / UndoDeletePoint.java
index 4cc09b47f23aa752b1b362f515d1c27acb562bf5..daab9fd574c89d177737f9adaf2a34636d09e6bf 100644 (file)
@@ -11,17 +11,20 @@ public class UndoDeletePoint implements UndoOperation
 {\r
        private int _pointIndex = -1;\r
        private DataPoint _point = null;\r
+       private int _photoIndex = -1;\r
 \r
 \r
        /**\r
         * Constructor\r
-        * @param inIndex index number of point within track\r
+        * @param inPointIndex index number of point within track\r
         * @param inPoint data point\r
+        * @param inPhotoIndex index number of photo within photo list\r
         */\r
-       public UndoDeletePoint(int inIndex, DataPoint inPoint)\r
+       public UndoDeletePoint(int inPointIndex, DataPoint inPoint, int inPhotoIndex)\r
        {\r
-               _pointIndex = inIndex;\r
+               _pointIndex = inPointIndex;\r
                _point = inPoint;\r
+               _photoIndex = inPhotoIndex;\r
        }\r
 \r
 \r
@@ -40,7 +43,7 @@ public class UndoDeletePoint implements UndoOperation
 \r
        /**\r
         * Perform the undo operation on the given Track\r
-        * @param inTrack Track object on which to perform the operation\r
+        * @param inTrackInfo TrackInfo object on which to perform the operation\r
         */\r
        public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
        {\r
@@ -49,6 +52,17 @@ public class UndoDeletePoint implements UndoOperation
                {\r
                        throw new UndoException(getDescription());\r
                }\r
-               // TODO: Reinsert photo into list if necessary\r
+               // Re-attach / Re-insert photo into list if necessary\r
+               if (_point.getPhoto() != null && _photoIndex > -1)\r
+               {\r
+                       // Check if photo is still in list\r
+                       if (!inTrackInfo.getPhotoList().contains(_point.getPhoto()))\r
+                       {\r
+                               // photo has been removed - need to reinsert\r
+                               inTrackInfo.getPhotoList().addPhoto(_point.getPhoto(), _photoIndex);\r
+                       }\r
+                       // Ensure that photo is associated with point\r
+                       _point.getPhoto().setDataPoint(_point);\r
+               }\r
        }\r
-}
\ No newline at end of file
+}\r