X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2FApp.java;h=1f223265b0aa929e9099a6d7aba71ea5b0a49a0d;hb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;hp=770fd2089aaac23518ecd687bec0f0d8878ee738;hpb=f1b92378a792131ac8fb33a869405851d5b2d1f7;p=GpsPrune.git diff --git a/tim/prune/App.java b/tim/prune/App.java index 770fd20..1f22326 100644 --- a/tim/prune/App.java +++ b/tim/prune/App.java @@ -10,7 +10,6 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import tim.prune.config.Config; -import tim.prune.data.Altitude; import tim.prune.data.Checker; import tim.prune.data.DataPoint; import tim.prune.data.Field; @@ -18,11 +17,13 @@ import tim.prune.data.LatLonRectangle; import tim.prune.data.NumberUtils; import tim.prune.data.Photo; import tim.prune.data.PhotoList; +import tim.prune.data.PointCreateOptions; import tim.prune.data.RecentFile; import tim.prune.data.SourceInfo; import tim.prune.data.Track; import tim.prune.data.TrackInfo; import tim.prune.data.SourceInfo.FILE_TYPE; +import tim.prune.data.Unit; import tim.prune.function.AsyncMediaLoader; import tim.prune.function.SaveConfig; import tim.prune.function.SelectTracksFunction; @@ -62,8 +63,12 @@ public class App private boolean _mangleTimestampsConfirmed = false; private Viewport _viewport = null; private ArrayList _dataFiles = null; - private boolean _firstDataFile = true; + private boolean _autoAppendNextFile = false; private boolean _busyLoading = false; + private AppMode _appMode = AppMode.NORMAL; + + /** Enum for the app mode - currently only two options but may expand later */ + public enum AppMode {NORMAL, DRAWRECT}; /** @@ -103,7 +108,7 @@ public class App public boolean hasDataUnsaved() { return (_undoStack.size() > _lastSavePosition - && (_track.getNumPoints() > 0 || _trackInfo.getPhotoList().getNumPhotos() > 0)); + && (_track.getNumPoints() > 0 || _trackInfo.getPhotoList().hasModifiedMedia())); } /** @@ -123,14 +128,15 @@ public class App if (inDataFiles == null || inDataFiles.size() == 0) { _dataFiles = null; } - else { + else + { _dataFiles = inDataFiles; File f = _dataFiles.get(0); _dataFiles.remove(0); // Start load of specified file if (_fileLoader == null) _fileLoader = new FileLoader(this, _frame); - _firstDataFile = true; + _autoAppendNextFile = false; // prompt for append _fileLoader.openFile(f); } } @@ -144,6 +150,7 @@ public class App { _undoStack.add(inUndo); UpdateMessageBroker.informSubscribers(inConfirmText); + setCurrentMode(AppMode.NORMAL); } /** @@ -272,6 +279,7 @@ public class App DataPoint currentPoint = _trackInfo.getCurrentPoint(); if (currentPoint != null) { + // Check for photo boolean deletePhoto = false; Photo currentPhoto = currentPoint.getPhoto(); if (currentPhoto != null) @@ -291,10 +299,11 @@ public class App // store necessary information to undo it later int pointIndex = _trackInfo.getSelection().getCurrentPointIndex(); int photoIndex = _trackInfo.getPhotoList().getPhotoIndex(currentPhoto); + int audioIndex = _trackInfo.getAudioList().getAudioIndex(currentPoint.getAudio()); DataPoint nextTrackPoint = _trackInfo.getTrack().getNextTrackPoint(pointIndex + 1); // Construct Undo object UndoOperation undo = new UndoDeletePoint(pointIndex, currentPoint, photoIndex, - nextTrackPoint != null && nextTrackPoint.getSegmentStart()); + audioIndex, nextTrackPoint != null && nextTrackPoint.getSegmentStart()); // call track to delete point if (_trackInfo.deletePoint()) { @@ -312,94 +321,15 @@ public class App // decouple photo from point currentPhoto.setDataPoint(null); } - UpdateMessageBroker.informSubscribers(); + UpdateMessageBroker.informSubscribers(DataSubscriber.PHOTOS_MODIFIED); } - // Confirm - UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.deletepoint.single")); - } - } - } - - - /** - * Delete the currently selected range - */ - public void deleteSelectedRange() - { - if (_track == null) return; - // Find out if photos should be deleted or not - int selStart = _trackInfo.getSelection().getStart(); - int selEnd = _trackInfo.getSelection().getEnd(); - if (selStart >= 0 && selEnd >= selStart) - { - int numToDelete = selEnd - selStart + 1; - boolean[] deletePhotos = new boolean[numToDelete]; - Photo[] photosToDelete = new Photo[numToDelete]; - boolean deleteAll = false; - boolean deleteNone = false; - String[] questionOptions = {I18nManager.getText("button.yes"), I18nManager.getText("button.no"), - I18nManager.getText("button.yestoall"), I18nManager.getText("button.notoall"), - I18nManager.getText("button.cancel")}; - DataPoint point = null; - for (int i=0; i -1) { + _trackInfo.getAudioList().deleteAudio(audioIndex); } - } - // add information to undo stack - UndoDeleteRange undo = new UndoDeleteRange(_trackInfo); - // delete requested photos - for (int i=0; i