]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoLoadPhotos.java
Version 3, August 2007
[GpsPrune.git] / tim / prune / undo / UndoLoadPhotos.java
index c08532d9ab9e01f9b4b819b5ccca88cf90f016ff..bb6a21176c48673f3a293115a97e6969fd98255e 100644 (file)
@@ -8,17 +8,19 @@ import tim.prune.data.TrackInfo;
  */\r
 public class UndoLoadPhotos implements UndoOperation\r
 {\r
-       private int _numLoaded = -1;\r
+       private int _numPhotos = -1;\r
+       private int _numPoints = -1;\r
 \r
-       // TODO: Handle possibility of photos not having datapoints (yet)\r
 \r
        /**\r
         * Constructor\r
-        * @param inNumLoaded number of photos loaded\r
+        * @param inNumPhotos number of photos loaded\r
+        * @param inNumPoints number of points loaded\r
         */\r
-       public UndoLoadPhotos(int inNumLoaded)\r
+       public UndoLoadPhotos(int inNumPhotos, int inNumPoints)\r
        {\r
-               _numLoaded = inNumLoaded;\r
+               _numPhotos = inNumPhotos;\r
+               _numPoints = inNumPoints;\r
        }\r
 \r
 \r
@@ -28,8 +30,8 @@ public class UndoLoadPhotos implements UndoOperation
        public String getDescription()\r
        {\r
                String desc = I18nManager.getText("undo.loadphotos");\r
-               if (_numLoaded > 0)\r
-                       desc = desc + " (" + _numLoaded + ")";\r
+               if (_numPhotos > 0)\r
+                       desc = desc + " (" + _numPhotos + ")";\r
                return desc;\r
        }\r
 \r
@@ -41,12 +43,15 @@ public class UndoLoadPhotos implements UndoOperation
         */\r
        public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
        {\r
+               int cropIndex;\r
                // crop track to previous size\r
-               int cropIndex = inTrackInfo.getTrack().getNumPoints() - _numLoaded;\r
-               inTrackInfo.getTrack().cropTo(cropIndex);\r
+               if (_numPoints > 0)\r
+               {\r
+                       cropIndex = inTrackInfo.getTrack().getNumPoints() - _numPoints;\r
+                       inTrackInfo.getTrack().cropTo(cropIndex);\r
+               }\r
                // crop photo list to previous size\r
-               // (currently it is assumed that the number of points is the same as number of photos)\r
-               cropIndex = inTrackInfo.getPhotoList().getNumPhotos() - _numLoaded;\r
+               cropIndex = inTrackInfo.getPhotoList().getNumPhotos() - _numPhotos;\r
                inTrackInfo.getPhotoList().cropTo(cropIndex);\r
                // clear selection\r
                inTrackInfo.getSelection().clearAll();\r