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 delete of a single photo, either with or without point
\r
11 public class UndoDeletePhoto implements UndoOperation
\r
13 private int _photoIndex = -1;
\r
14 private Photo _photo = null;
\r
15 private int _pointIndex = -1;
\r
16 private DataPoint _point = null;
\r
21 * @param inPhoto photo
\r
22 * @param inPhotoIndex index number of photo within photo list
\r
23 * @param inPoint data point
\r
24 * @param inPointIndex index number of point within track
\r
26 public UndoDeletePhoto(Photo inPhoto, int inPhotoIndex, DataPoint inPoint, int inPointIndex)
\r
29 _photoIndex = inPhotoIndex;
\r
31 _pointIndex = inPointIndex;
\r
36 * @return description of operation including photo name
\r
38 public String getDescription()
\r
40 String desc = I18nManager.getText("undo.deletephoto") + " " + _photo.getFile().getName();
\r
46 * Perform the undo operation on the given Track
\r
47 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
49 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
52 inTrackInfo.getPhotoList().addPhoto(_photo, _photoIndex);
\r
53 // if there's a point to restore, restore it
\r
56 if (!inTrackInfo.getTrack().insertPoint(_point, _pointIndex))
\r
58 throw new UndoException(getDescription());
\r
63 // update needed if not already triggered by track update
\r
64 inTrackInfo.triggerUpdate();
\r
66 // Ensure that photo is associated with point and vice versa
\r
67 _photo.setDataPoint(_point);
\r
70 _point.setPhoto(_photo);
\r