--- /dev/null
+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