1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.data.DataPoint;
\r
5 import tim.prune.data.TrackInfo;
\r
8 * Operation to undo a delete of a single point
\r
10 public class UndoDeletePoint implements UndoOperation
\r
12 private int _pointIndex = -1;
\r
13 private DataPoint _point = null;
\r
14 private int _photoIndex = -1;
\r
19 * @param inPointIndex index number of point within track
\r
20 * @param inPoint data point
\r
21 * @param inPhotoIndex index number of photo within photo list
\r
23 public UndoDeletePoint(int inPointIndex, DataPoint inPoint, int inPhotoIndex)
\r
25 _pointIndex = inPointIndex;
\r
27 _photoIndex = inPhotoIndex;
\r
32 * @return description of operation including point name if any
\r
34 public String getDescription()
\r
36 String desc = I18nManager.getText("undo.deletepoint");
\r
37 String pointName = _point.getWaypointName();
\r
38 if (pointName != null && !pointName.equals(""))
\r
39 desc = desc + " " + pointName;
\r
45 * Perform the undo operation on the given Track
\r
46 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
48 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
50 // restore point into track
\r
51 if (!inTrackInfo.getTrack().insertPoint(_point, _pointIndex))
\r
53 throw new UndoException(getDescription());
\r
55 // Re-attach / Re-insert photo into list if necessary
\r
56 if (_point.getPhoto() != null && _photoIndex > -1)
\r
58 // Check if photo is still in list
\r
59 if (!inTrackInfo.getPhotoList().contains(_point.getPhoto()))
\r
61 // photo has been removed - need to reinsert
\r
62 inTrackInfo.getPhotoList().addPhoto(_point.getPhoto(), _photoIndex);
\r
64 // Ensure that photo is associated with point
\r
65 _point.getPhoto().setDataPoint(_point);
\r