1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.data.DataPoint;
\r
5 import tim.prune.data.FileInfo;
\r
6 import tim.prune.data.PhotoList;
\r
7 import tim.prune.data.TrackInfo;
\r
10 * Operation to undo a load operation
\r
12 public class UndoLoad implements UndoOperation
\r
14 private int _cropIndex = -1;
\r
15 private int _numLoaded = -1;
\r
16 private DataPoint[] _contents = null;
\r
17 private PhotoList _photoList = null;
\r
18 private FileInfo _oldFileInfo = null;
\r
22 * Constructor for appending
\r
23 * @param inIndex index number of crop point
\r
24 * @param inNumLoaded number of points loaded
\r
26 public UndoLoad(int inIndex, int inNumLoaded)
\r
28 _cropIndex = inIndex;
\r
29 _numLoaded = inNumLoaded;
\r
35 * Constructor for replacing
\r
36 * @param inOldTrackInfo track info being replaced
\r
37 * @param inNumLoaded number of points loaded
\r
38 * @param inPhotoList photo list, if any
\r
40 public UndoLoad(TrackInfo inOldTrackInfo, int inNumLoaded, PhotoList inPhotoList)
\r
43 _numLoaded = inNumLoaded;
\r
44 _contents = inOldTrackInfo.getTrack().cloneContents();
\r
45 _oldFileInfo = inOldTrackInfo.getFileInfo().clone();
\r
46 _photoList = inPhotoList;
\r
51 * @return description of operation including number of points loaded
\r
53 public String getDescription()
\r
55 String desc = I18nManager.getText("undo.load");
\r
57 desc = desc + " (" + _numLoaded + ")";
\r
63 * Perform the undo operation on the given Track
\r
64 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
66 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
68 // remove source from fileinfo
\r
69 if (_oldFileInfo == null) {
\r
70 inTrackInfo.getFileInfo().removeSource();
\r
73 inTrackInfo.setFileInfo(_oldFileInfo);
\r
76 if (_contents == null)
\r
78 // crop track to previous size
\r
79 inTrackInfo.getTrack().cropTo(_cropIndex);
\r
83 // replace photos how they were
\r
84 if (_photoList != null)
\r
86 inTrackInfo.getPhotoList().restore(_photoList);
\r
88 // replace track contents with old
\r
89 if (!inTrackInfo.getTrack().replaceContents(_contents))
\r
91 throw new UndoException(getDescription());
\r
95 inTrackInfo.getSelection().clearAll();
\r