X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fundo%2FUndoLoad.java;h=377f21c22f93f7b0a95f7c73378a30a09d5276c7;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=8bf22183c5162c787fa8c7350f602a1da2c5f4df;hpb=312fec956e43f5d0a38617da5d0add9c62563e2c;p=GpsPrune.git diff --git a/tim/prune/undo/UndoLoad.java b/tim/prune/undo/UndoLoad.java index 8bf2218..377f21c 100644 --- a/tim/prune/undo/UndoLoad.java +++ b/tim/prune/undo/UndoLoad.java @@ -2,6 +2,8 @@ package tim.prune.undo; import tim.prune.I18nManager; import tim.prune.data.DataPoint; +import tim.prune.data.FileInfo; +import tim.prune.data.PhotoList; import tim.prune.data.TrackInfo; /** @@ -12,7 +14,10 @@ public class UndoLoad implements UndoOperation private int _cropIndex = -1; private int _numLoaded = -1; private DataPoint[] _contents = null; - private String _previousFilename = null; + private PhotoList _photoList = null; + private FileInfo _oldFileInfo = null; + // Numbers of each media before operation + private int _numPhotos = -1, _numAudios = -1; /** @@ -25,22 +30,22 @@ public class UndoLoad implements UndoOperation _cropIndex = inIndex; _numLoaded = inNumLoaded; _contents = null; - _previousFilename = null; } /** * Constructor for replacing - * @param inOldTrack track being replaced + * @param inOldTrackInfo track info being replaced * @param inNumLoaded number of points loaded + * @param inPhotoList photo list, if any */ - public UndoLoad(TrackInfo inOldTrackInfo, int inNumLoaded) + public UndoLoad(TrackInfo inOldTrackInfo, int inNumLoaded, PhotoList inPhotoList) { _cropIndex = -1; _numLoaded = inNumLoaded; _contents = inOldTrackInfo.getTrack().cloneContents(); - if (inOldTrackInfo.getFileInfo().getNumFiles() == 1) - _previousFilename = inOldTrackInfo.getFileInfo().getFilename(); + _oldFileInfo = inOldTrackInfo.getFileInfo().clone(); + _photoList = inPhotoList; } @@ -55,6 +60,16 @@ public class UndoLoad implements UndoOperation return desc; } + /** + * Set the number of photos and audios before the load operation + * @param inNumPhotos number of photos + * @param inNumAudios number of audios + */ + public void setNumPhotosAudios(int inNumPhotos, int inNumAudios) + { + _numPhotos = inNumPhotos; + _numAudios = inNumAudios; + } /** * Perform the undo operation on the given Track @@ -62,11 +77,12 @@ public class UndoLoad implements UndoOperation */ public void performUndo(TrackInfo inTrackInfo) throws UndoException { - // remove file from fileinfo - inTrackInfo.getFileInfo().removeFile(); - if (_previousFilename != null) - { - inTrackInfo.getFileInfo().setFile(_previousFilename); + // remove source from fileinfo + if (_oldFileInfo == null) { + inTrackInfo.getFileInfo().removeSource(); + } + else { + inTrackInfo.setFileInfo(_oldFileInfo); } // Crop / replace if (_contents == null) @@ -76,6 +92,13 @@ public class UndoLoad implements UndoOperation } else { + // replace photos how they were + if (_photoList != null) { + inTrackInfo.getPhotoList().restore(_photoList); + } + // Crop media lists to previous size (if specified) + if (_numPhotos > -1) {inTrackInfo.getPhotoList().cropTo(_numPhotos);} + if (_numAudios > -1) {inTrackInfo.getAudioList().cropTo(_numAudios);} // replace track contents with old if (!inTrackInfo.getTrack().replaceContents(_contents)) { @@ -85,4 +108,4 @@ public class UndoLoad implements UndoOperation // clear selection inTrackInfo.getSelection().clearAll(); } -} \ No newline at end of file +}