]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/undo/UndoLoadPhotos.java
Version 2, March 2007
[GpsPrune.git] / tim / prune / undo / UndoLoadPhotos.java
diff --git a/tim/prune/undo/UndoLoadPhotos.java b/tim/prune/undo/UndoLoadPhotos.java
new file mode 100644 (file)
index 0000000..c08532d
--- /dev/null
@@ -0,0 +1,54 @@
+package tim.prune.undo;\r
+\r
+import tim.prune.I18nManager;\r
+import tim.prune.data.TrackInfo;\r
+\r
+/**\r
+ * Operation to undo a load photos operation\r
+ */\r
+public class UndoLoadPhotos implements UndoOperation\r
+{\r
+       private int _numLoaded = -1;\r
+\r
+       // TODO: Handle possibility of photos not having datapoints (yet)\r
+\r
+       /**\r
+        * Constructor\r
+        * @param inNumLoaded number of photos loaded\r
+        */\r
+       public UndoLoadPhotos(int inNumLoaded)\r
+       {\r
+               _numLoaded = inNumLoaded;\r
+       }\r
+\r
+\r
+       /**\r
+        * @return description of operation including number of photos loaded\r
+        */\r
+       public String getDescription()\r
+       {\r
+               String desc = I18nManager.getText("undo.loadphotos");\r
+               if (_numLoaded > 0)\r
+                       desc = desc + " (" + _numLoaded + ")";\r
+               return desc;\r
+       }\r
+\r
+\r
+       /**\r
+        * Perform the undo operation on the given Track\r
+        * Delete both track points and Photo objects\r
+        * @param inTrackInfo TrackInfo object on which to perform the operation\r
+        */\r
+       public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
+       {\r
+               // crop track to previous size\r
+               int cropIndex = inTrackInfo.getTrack().getNumPoints() - _numLoaded;\r
+               inTrackInfo.getTrack().cropTo(cropIndex);\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
+               inTrackInfo.getPhotoList().cropTo(cropIndex);\r
+               // clear selection\r
+               inTrackInfo.getSelection().clearAll();\r
+       }\r
+}
\ No newline at end of file