]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/App.java
Version 16.3, July 2014
[GpsPrune.git] / tim / prune / App.java
index 1f223265b0aa929e9099a6d7aba71ea5b0a49a0d..e57dcf6d5d15364fd6c5ede5f509d28728531404 100644 (file)
@@ -41,6 +41,7 @@ import tim.prune.load.MediaLinkInfo;
 import tim.prune.load.TrackNameList;
 import tim.prune.save.ExifSaver;
 import tim.prune.save.FileSaver;
+import tim.prune.tips.TipManager;
 import tim.prune.undo.*;
 
 
@@ -59,7 +60,7 @@ public class App
        private FileLoader _fileLoader = null;
        private JpegLoader _jpegLoader = null;
        private FileSaver _fileSaver = null;
-       private Stack<UndoOperation> _undoStack = null;
+       private UndoStack _undoStack = null;
        private boolean _mangleTimestampsConfirmed = false;
        private Viewport _viewport = null;
        private ArrayList<File> _dataFiles = null;
@@ -78,7 +79,7 @@ public class App
        public App(JFrame inFrame)
        {
                _frame = inFrame;
-               _undoStack = new Stack<UndoOperation>();
+               _undoStack = new UndoStack();
                _track = new Track();
                _trackInfo = new TrackInfo(_track);
                FunctionLibrary.initialise(this);
@@ -119,6 +120,22 @@ public class App
                return _undoStack;
        }
 
+
+       /**
+        * Show the specified tip if appropriate
+        * @param inTipNumber tip number from TipManager
+        */
+       public void showTip(int inTipNumber)
+       {
+               String key = TipManager.fireTipTrigger(inTipNumber);
+               if (key != null && !key.equals(""))
+               {
+                       JOptionPane.showMessageDialog(_frame, I18nManager.getText(key),
+                               I18nManager.getText("tip.title"), JOptionPane.INFORMATION_MESSAGE);
+               }
+       }
+
+
        /**
         * Load the specified data files one by one
         * @param inDataFiles arraylist containing File objects to load
@@ -511,6 +528,13 @@ public class App
                // ensure track's field list contains point's fields
                _track.extendFieldList(inPoint.getFieldList());
                _trackInfo.selectPoint(inIndex);
+               final int selStart = _trackInfo.getSelection().getStart();
+               final int selEnd   = _trackInfo.getSelection().getEnd();
+               if (selStart < inIndex && selEnd > inIndex)
+               {
+                       // Extend end of selection by 1
+                       _trackInfo.getSelection().selectRange(selStart, selEnd+1);
+               }
                // update listeners
                UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.createpoint"));
        }
@@ -887,6 +911,12 @@ public class App
                UpdateMessageBroker.informSubscribers();
        }
 
+       /**
+        * @return the current data status, used for later comparison
+        */
+       public DataStatus getCurrentDataStatus() {
+               return new DataStatus(_undoStack.size(), _undoStack.getNumTimesDeleted());
+       }
 
        /**
         * Show a map url in an external browser