1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.data.DataPoint;
\r
5 import tim.prune.data.Photo;
\r
6 import tim.prune.data.TrackInfo;
\r
9 * Operation to undo a load photos operation
\r
11 public class UndoLoadPhotos implements UndoOperation
\r
13 private int _numPhotos = -1;
\r
14 private int _numPoints = -1;
\r
19 * @param inNumPhotos number of photos loaded
\r
20 * @param inNumPoints number of points loaded
\r
22 public UndoLoadPhotos(int inNumPhotos, int inNumPoints)
\r
24 _numPhotos = inNumPhotos;
\r
25 _numPoints = inNumPoints;
\r
30 * @return description of operation including number of photos loaded
\r
32 public String getDescription()
\r
34 String desc = I18nManager.getText("undo.loadphotos");
\r
36 desc = desc + " (" + _numPhotos + ")";
\r
42 * Perform the undo operation on the given Track
\r
43 * Delete both track points and Photo objects
\r
44 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
46 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
49 // crop track to previous size
\r
52 cropIndex = inTrackInfo.getTrack().getNumPoints() - _numPoints;
\r
53 inTrackInfo.getTrack().cropTo(cropIndex);
\r
57 // Loop through the points (if any) and detach them
\r
58 for (int i=0; i<_numPhotos; i++)
\r
60 Photo photo = inTrackInfo.getPhotoList().getPhoto(inTrackInfo.getPhotoList().getNumPhotos() - 1 - i);
\r
61 if (photo.isConnected()) {
\r
62 DataPoint point = photo.getDataPoint();
\r
63 if (point != null) {point.setPhoto(null);}
\r
67 // crop photo list to previous size
\r
68 cropIndex = inTrackInfo.getPhotoList().getNumPhotos() - _numPhotos;
\r
69 inTrackInfo.getPhotoList().cropTo(cropIndex);
\r
71 inTrackInfo.getSelection().clearAll();
\r