]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoLoadPhotos.java
Version 2, March 2007
[GpsPrune.git] / tim / prune / undo / UndoLoadPhotos.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.TrackInfo;\r
5 \r
6 /**\r
7  * Operation to undo a load photos operation\r
8  */\r
9 public class UndoLoadPhotos implements UndoOperation\r
10 {\r
11         private int _numLoaded = -1;\r
12 \r
13         // TODO: Handle possibility of photos not having datapoints (yet)\r
14 \r
15         /**\r
16          * Constructor\r
17          * @param inNumLoaded number of photos loaded\r
18          */\r
19         public UndoLoadPhotos(int inNumLoaded)\r
20         {\r
21                 _numLoaded = inNumLoaded;\r
22         }\r
23 \r
24 \r
25         /**\r
26          * @return description of operation including number of photos loaded\r
27          */\r
28         public String getDescription()\r
29         {\r
30                 String desc = I18nManager.getText("undo.loadphotos");\r
31                 if (_numLoaded > 0)\r
32                         desc = desc + " (" + _numLoaded + ")";\r
33                 return desc;\r
34         }\r
35 \r
36 \r
37         /**\r
38          * Perform the undo operation on the given Track\r
39          * Delete both track points and Photo objects\r
40          * @param inTrackInfo TrackInfo object on which to perform the operation\r
41          */\r
42         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
43         {\r
44                 // crop track to previous size\r
45                 int cropIndex = inTrackInfo.getTrack().getNumPoints() - _numLoaded;\r
46                 inTrackInfo.getTrack().cropTo(cropIndex);\r
47                 // crop photo list to previous size\r
48                 // (currently it is assumed that the number of points is the same as number of photos)\r
49                 cropIndex = inTrackInfo.getPhotoList().getNumPhotos() - _numLoaded;\r
50                 inTrackInfo.getPhotoList().cropTo(cropIndex);\r
51                 // clear selection\r
52                 inTrackInfo.getSelection().clearAll();\r
53         }\r
54 }