1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.data.DataPoint;
\r
5 import tim.prune.data.PhotoList;
\r
6 import tim.prune.data.TrackInfo;
\r
9 * Operation to undo a delete of a range of points
\r
11 public class UndoDeleteRange implements UndoOperation
\r
13 private int _startIndex = -1;
\r
14 private DataPoint[] _points = null;
\r
15 private PhotoList _photoList = null;
\r
20 * @param inIndex index number of point within track
\r
21 * @param inPoint data point
\r
23 public UndoDeleteRange(TrackInfo inTrackInfo)
\r
25 _startIndex = inTrackInfo.getSelection().getStart();
\r
26 _points = inTrackInfo.cloneSelectedRange();
\r
27 _photoList = inTrackInfo.getPhotoList().cloneList();
\r
32 * @return description of operation including range length
\r
34 public String getDescription()
\r
36 return I18nManager.getText("undo.deleterange")
\r
37 + " (" + _points.length + ")";
\r
42 * Perform the undo operation on the given Track
\r
43 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
45 public void performUndo(TrackInfo inTrackInfo)
\r
47 // restore photos to how they were before
\r
48 inTrackInfo.getPhotoList().restore(_photoList);
\r
49 // reconnect photos to points
\r
50 for (int i=0; i<_points.length; i++)
\r
52 DataPoint point = _points[i];
\r
53 if (point != null && point.getPhoto() != null)
\r
55 point.getPhoto().setDataPoint(point);
\r
58 // restore point array into track
\r
59 inTrackInfo.getTrack().insertRange(_points, _startIndex);
\r