1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.UpdateMessageBroker;
\r
5 import tim.prune.data.DataPoint;
\r
6 import tim.prune.data.Photo;
\r
7 import tim.prune.data.TrackInfo;
\r
10 * Operation to undo a delete of a single photo, either with or without point
\r
12 public class UndoDeletePhoto extends UndoDeleteOperation
\r
14 private int _photoIndex = -1;
\r
15 private Photo _photo = null;
\r
16 private int _pointIndex = -1;
\r
17 private DataPoint _point = null;
\r
22 * @param inPhoto photo
\r
23 * @param inPhotoIndex index number of photo within photo list
\r
24 * @param inPoint data point
\r
25 * @param inPointIndex index number of point within track
\r
27 public UndoDeletePhoto(Photo inPhoto, int inPhotoIndex, DataPoint inPoint, int inPointIndex)
\r
30 _photoIndex = inPhotoIndex;
\r
32 _pointIndex = inPointIndex;
\r
37 * @return description of operation including photo name
\r
39 public String getDescription()
\r
41 String desc = I18nManager.getText("undo.removephoto") + " " + _photo.getName();
\r
47 * Perform the undo operation on the given Track
\r
48 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
50 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
53 inTrackInfo.getPhotoList().addPhoto(_photo, _photoIndex);
\r
54 // if there's a point to restore, restore it
\r
57 if (!inTrackInfo.getTrack().insertPoint(_point, _pointIndex))
\r
59 throw new UndoException(getDescription());
\r
61 // Change the current point/range selection if required
\r
62 modifySelection(inTrackInfo, _pointIndex, _pointIndex);
\r
66 // update needed if not already triggered by track update
\r
67 UpdateMessageBroker.informSubscribers();
\r
69 // Ensure that photo is associated with point and vice versa
\r
70 _photo.setDataPoint(_point);
\r
71 if (_point != null) {
\r
72 _point.setPhoto(_photo);
\r