]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/App.java
Version 6, October 2008
[GpsPrune.git] / tim / prune / App.java
index 18a2e79a60fa737cde270045cb0d3b6263dc278f..ecde5481a1d269ed23028cb48208d4adcf6abb94 100644 (file)
@@ -7,10 +7,16 @@ import java.util.Stack;
 import javax.swing.JFrame;
 import javax.swing.JOptionPane;
 
+import tim.prune.browser.BrowserLauncher;
+import tim.prune.browser.UrlGenerator;
 import tim.prune.correlate.PhotoCorrelator;
 import tim.prune.correlate.PointPair;
+import tim.prune.data.Coordinate;
 import tim.prune.data.DataPoint;
 import tim.prune.data.Field;
+import tim.prune.data.LatLonRectangle;
+import tim.prune.data.Latitude;
+import tim.prune.data.Longitude;
 import tim.prune.data.Photo;
 import tim.prune.data.PhotoList;
 import tim.prune.data.Track;
@@ -19,8 +25,10 @@ import tim.prune.edit.FieldEditList;
 import tim.prune.edit.PointEditor;
 import tim.prune.edit.PointNameEditor;
 import tim.prune.gui.MenuManager;
+import tim.prune.gui.TimeOffsetDialog;
 import tim.prune.gui.UndoManager;
 import tim.prune.load.FileLoader;
+import tim.prune.load.GpsLoader;
 import tim.prune.load.JpegLoader;
 import tim.prune.save.ExifSaver;
 import tim.prune.save.FileSaver;
@@ -30,9 +38,13 @@ import tim.prune.save.PovExporter;
 import tim.prune.threedee.ThreeDException;
 import tim.prune.threedee.ThreeDWindow;
 import tim.prune.threedee.WindowFactory;
+import tim.prune.undo.UndoAddTimeOffset;
 import tim.prune.undo.UndoCompress;
 import tim.prune.undo.UndoConnectPhoto;
+import tim.prune.undo.UndoConnectPhotoWithClone;
 import tim.prune.undo.UndoCorrelatePhotos;
+import tim.prune.undo.UndoCreatePoint;
+import tim.prune.undo.UndoCutAndMove;
 import tim.prune.undo.UndoDeleteDuplicates;
 import tim.prune.undo.UndoDeletePhoto;
 import tim.prune.undo.UndoDeletePoint;
@@ -43,6 +55,7 @@ import tim.prune.undo.UndoException;
 import tim.prune.undo.UndoInsert;
 import tim.prune.undo.UndoLoad;
 import tim.prune.undo.UndoLoadPhotos;
+import tim.prune.undo.UndoMergeTrackSegments;
 import tim.prune.undo.UndoOperation;
 import tim.prune.undo.UndoRearrangeWaypoints;
 import tim.prune.undo.UndoReverseSection;
@@ -61,13 +74,14 @@ public class App
        private MenuManager _menuManager = null;
        private FileLoader _fileLoader = null;
        private JpegLoader _jpegLoader = null;
+       private GpsLoader _gpsLoader = null;
        private FileSaver _fileSaver = null;
        private KmlExporter _kmlExporter = null;
        private GpxExporter _gpxExporter = null;
        private PovExporter _povExporter = null;
+       private BrowserLauncher _browserLauncher = null;
        private Stack _undoStack = null;
-       private UpdateMessageBroker _broker = null;
-       private boolean _reversePointsConfirmed = false;
+       private boolean _mangleTimestampsConfirmed = false;
 
        // Constants
        public static final int REARRANGE_TO_START   = 0;
@@ -78,15 +92,13 @@ public class App
        /**
         * Constructor
         * @param inFrame frame object for application
-        * @param inBroker message broker
         */
-       public App(JFrame inFrame, UpdateMessageBroker inBroker)
+       public App(JFrame inFrame)
        {
                _frame = inFrame;
                _undoStack = new Stack();
-               _broker = inBroker;
-               _track = new Track(_broker);
-               _trackInfo = new TrackInfo(_track, _broker);
+               _track = new Track();
+               _trackInfo = new TrackInfo(_track);
        }
 
 
@@ -138,15 +150,24 @@ public class App
 
 
        /**
-        * Add a photo or a directory of photos which are already correlated
+        * Add a photo or a directory of photos
         */
        public void addPhotos()
        {
                if (_jpegLoader == null)
                        _jpegLoader = new JpegLoader(this, _frame);
-               _jpegLoader.openFile();
+               _jpegLoader.openDialog(new LatLonRectangle(_track.getLatRange(), _track.getLonRange()));
        }
 
+       /**
+        * Start a load from Gps
+        */
+       public void beginLoadFromGps()
+       {
+               if (_gpsLoader == null)
+                       _gpsLoader = new GpsLoader(this, _frame);
+               _gpsLoader.openDialog();
+       }
 
        /**
         * Save the file in the selected format
@@ -163,7 +184,9 @@ public class App
                        if (_fileSaver == null) {
                                _fileSaver = new FileSaver(this, _frame, _track);
                        }
-                       _fileSaver.showDialog(_fileLoader.getLastUsedDelimiter());
+                       char delim = ',';
+                       if (_fileLoader != null) {delim = _fileLoader.getLastUsedDelimiter();}
+                       _fileSaver.showDialog(delim);
                }
        }
 
@@ -322,6 +345,8 @@ public class App
                        if (_track.editPoint(currentPoint, inEditList))
                        {
                                _undoStack.push(undo);
+                               // Confirm point edit
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.point.edit"));
                        }
                }
        }
@@ -350,50 +375,53 @@ public class App
         */
        public void deleteCurrentPoint()
        {
-               if (_track != null)
+               if (_track == null) {return;}
+               DataPoint currentPoint = _trackInfo.getCurrentPoint();
+               if (currentPoint != null)
                {
-                       DataPoint currentPoint = _trackInfo.getCurrentPoint();
-                       if (currentPoint != null)
+                       boolean deletePhoto = false;
+                       Photo currentPhoto = currentPoint.getPhoto();
+                       if (currentPhoto != null)
+                       {
+                               // Confirm deletion of photo or decoupling
+                               int response = JOptionPane.showConfirmDialog(_frame,
+                                       I18nManager.getText("dialog.deletepoint.deletephoto") + " " + currentPhoto.getFile().getName(),
+                                       I18nManager.getText("dialog.deletepoint.title"),
+                                       JOptionPane.YES_NO_CANCEL_OPTION);
+                               if (response == JOptionPane.CANCEL_OPTION || response == JOptionPane.CLOSED_OPTION)
+                               {
+                                       // cancel pressed- abort delete
+                                       return;
+                               }
+                               if (response == JOptionPane.YES_OPTION) {deletePhoto = true;}
+                       }
+                       // store necessary information to undo it later
+                       int pointIndex = _trackInfo.getSelection().getCurrentPointIndex();
+                       int photoIndex = _trackInfo.getPhotoList().getPhotoIndex(currentPhoto);
+                       DataPoint nextTrackPoint = _trackInfo.getTrack().getNextTrackPoint(pointIndex + 1);
+                       // Construct Undo object
+                       UndoOperation undo = new UndoDeletePoint(pointIndex, currentPoint, photoIndex,
+                               nextTrackPoint != null && nextTrackPoint.getSegmentStart());
+                       // call track to delete point
+                       if (_trackInfo.deletePoint())
                        {
-                               boolean deletePhoto = false;
-                               Photo currentPhoto = currentPoint.getPhoto();
+                               // Delete was successful so add undo info to stack
+                               _undoStack.push(undo);
                                if (currentPhoto != null)
                                {
-                                       // Confirm deletion of photo or decoupling
-                                       int response = JOptionPane.showConfirmDialog(_frame,
-                                               I18nManager.getText("dialog.deletepoint.deletephoto") + " " + currentPhoto.getFile().getName(),
-                                               I18nManager.getText("dialog.deletepoint.title"),
-                                               JOptionPane.YES_NO_CANCEL_OPTION);
-                                       if (response == JOptionPane.CANCEL_OPTION || response == JOptionPane.CLOSED_OPTION)
+                                       // delete photo if necessary
+                                       if (deletePhoto)
                                        {
-                                               // cancel pressed- abort delete
-                                               return;
+                                               _trackInfo.getPhotoList().deletePhoto(photoIndex);
                                        }
-                                       if (response == JOptionPane.YES_OPTION) {deletePhoto = true;}
-                               }
-                               // add information to undo stack
-                               int pointIndex = _trackInfo.getSelection().getCurrentPointIndex();
-                               int photoIndex = _trackInfo.getPhotoList().getPhotoIndex(currentPhoto);
-                               // Undo object needs to know index of photo in list (if any) to restore
-                               UndoOperation undo = new UndoDeletePoint(pointIndex, currentPoint, photoIndex);
-                               // call track to delete point
-                               if (_trackInfo.deletePoint())
-                               {
-                                       _undoStack.push(undo);
-                                       if (currentPhoto != null)
+                                       else
                                        {
-                                               // delete photo if necessary
-                                               if (deletePhoto)
-                                               {
-                                                       _trackInfo.getPhotoList().deletePhoto(photoIndex);
-                                               }
-                                               else
-                                               {
-                                                       // decouple photo from point
-                                                       currentPhoto.setDataPoint(null);
-                                               }
+                                               // decouple photo from point
+                                               currentPhoto.setDataPoint(null);
                                        }
                                }
+                               // Confirm
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.deletepoint.single"));
                        }
                }
        }
@@ -453,7 +481,7 @@ public class App
                                        }
                                }
                                // add information to undo stack
-                               UndoOperation undo = new UndoDeleteRange(_trackInfo);
+                               UndoDeleteRange undo = new UndoDeleteRange(_trackInfo);
                                // delete requested photos
                                for (int i=0; i<numToDelete; i++)
                                {
@@ -476,6 +504,9 @@ public class App
                                if (_trackInfo.deleteRange())
                                {
                                        _undoStack.push(undo);
+                                       // Confirm
+                                       UpdateMessageBroker.informSubscribers("" + numToDelete + " "
+                                               + I18nManager.getText("confirm.deletepoint.multi"));
                                }
                        }
                }
@@ -499,17 +530,18 @@ public class App
                                String message = null;
                                if (numDeleted == 1)
                                {
-                                       message = "1 " + I18nManager.getText("dialog.deleteduplicates.single.text");
+                                       message = "1 " + I18nManager.getText("confirm.deleteduplicates.single");
                                }
                                else
                                {
-                                       message = "" + numDeleted + " " + I18nManager.getText("dialog.deleteduplicates.multi.text");
+                                       message = "" + numDeleted + " " + I18nManager.getText("confirm.deleteduplicates.multi");
                                }
-                               JOptionPane.showMessageDialog(_frame, message,
-                                       I18nManager.getText("dialog.deleteduplicates.title"), JOptionPane.INFORMATION_MESSAGE);
+                               // Pass message to broker
+                               UpdateMessageBroker.informSubscribers(message);
                        }
                        else
                        {
+                               // No duplicates found to delete
                                JOptionPane.showMessageDialog(_frame,
                                        I18nManager.getText("dialog.deleteduplicates.nonefound"),
                                        I18nManager.getText("dialog.deleteduplicates.title"), JOptionPane.INFORMATION_MESSAGE);
@@ -538,11 +570,8 @@ public class App
                {
                        undo.setNumPointsDeleted(numPointsDeleted);
                        _undoStack.add(undo);
-                       JOptionPane.showMessageDialog(_frame,
-                               I18nManager.getText("dialog.compresstrack.text") + " - "
-                                + numPointsDeleted + " "
-                                + (numPointsDeleted==1?I18nManager.getText("dialog.compresstrack.single.text"):I18nManager.getText("dialog.compresstrack.multi.text")),
-                               I18nManager.getText("dialog.compresstrack.title"), JOptionPane.INFORMATION_MESSAGE);
+                       UpdateMessageBroker.informSubscribers("" + numPointsDeleted + " "
+                                + (numPointsDeleted==1?I18nManager.getText("confirm.deletepoint.single"):I18nManager.getText("confirm.deletepoint.multi")));
                }
                else
                {
@@ -553,7 +582,7 @@ public class App
 
 
        /**
-        * Reverse a section of the track
+        * Reverse the currently selected section of the track
         */
        public void reverseRange()
        {
@@ -561,17 +590,78 @@ public class App
                int selStart = _trackInfo.getSelection().getStart();
                int selEnd = _trackInfo.getSelection().getEnd();
                if (!_track.hasData(Field.TIMESTAMP, selStart, selEnd)
-                       || _reversePointsConfirmed
+                       || _mangleTimestampsConfirmed
                        || (JOptionPane.showConfirmDialog(_frame,
                                 I18nManager.getText("dialog.confirmreversetrack.text"),
                                 I18nManager.getText("dialog.confirmreversetrack.title"),
-                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION && (_reversePointsConfirmed = true)))
+                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION && (_mangleTimestampsConfirmed = true)))
                {
-                       UndoReverseSection undo = new UndoReverseSection(selStart, selEnd);
+                       UndoReverseSection undo = new UndoReverseSection(_track, selStart, selEnd);
                        // call track to reverse range
                        if (_track.reverseRange(selStart, selEnd))
                        {
                                _undoStack.add(undo);
+                               // Confirm
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.reverserange"));
+                       }
+               }
+       }
+
+       /**
+        * Trigger the dialog to add a time offset to the current selection
+        */
+       public void beginAddTimeOffset()
+       {
+               int selStart = _trackInfo.getSelection().getStart();
+               int selEnd = _trackInfo.getSelection().getEnd();
+               if (!_track.hasData(Field.TIMESTAMP, selStart, selEnd)) {
+                       JOptionPane.showMessageDialog(_frame,
+                               I18nManager.getText("dialog.addtimeoffset.notimestamps"),
+                               I18nManager.getText("dialog.addtimeoffset.title"), JOptionPane.ERROR_MESSAGE);
+               }
+               else {
+                       TimeOffsetDialog timeDialog = new TimeOffsetDialog(this, _frame);
+                       timeDialog.showDialog();
+               }
+       }
+
+       /**
+        * Complete the add time offset function with the specified offset
+        * @param inTimeOffset time offset to add (+ve for add, -ve for subtract)
+        */
+       public void finishAddTimeOffset(long inTimeOffset)
+       {
+               // Construct undo information
+               int selStart = _trackInfo.getSelection().getStart();
+               int selEnd = _trackInfo.getSelection().getEnd();
+               UndoAddTimeOffset undo = new UndoAddTimeOffset(selStart, selEnd, inTimeOffset);
+               if (_trackInfo.getTrack().addTimeOffset(selStart, selEnd, inTimeOffset))
+               {
+                       _undoStack.add(undo);
+                       UpdateMessageBroker.informSubscribers(DataSubscriber.DATA_EDITED);
+                       UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.addtimeoffset"));
+               }
+       }
+
+
+       /**
+        * Merge the track segments within the current selection
+        */
+       public void mergeTrackSegments()
+       {
+               if (_trackInfo.getSelection().hasRangeSelected())
+               {
+                       // Maybe could check segment start flags to see if it's worth merging
+                       // If first track point is already start and no other seg starts then do nothing
+
+                       int selStart = _trackInfo.getSelection().getStart();
+                       int selEnd = _trackInfo.getSelection().getEnd();
+                       // Make undo object
+                       UndoMergeTrackSegments undo = new UndoMergeTrackSegments(_track, selStart, selEnd);
+                       // Call track to merge segments
+                       if (_track.mergeTrackSegments(selStart, selEnd)) {
+                               _undoStack.add(undo);
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.mergetracksegments"));
                        }
                }
        }
@@ -600,6 +690,27 @@ public class App
        }
 
 
+       /**
+        * Create a new point at the given lat/long coordinates
+        * @param inLat latitude
+        * @param inLong longitude
+        */
+       public void createPoint(double inLat, double inLong)
+       {
+               // create undo object
+               UndoCreatePoint undo = new UndoCreatePoint();
+               // create point and add to track
+               DataPoint point = new DataPoint(new Latitude(inLat, Coordinate.FORMAT_NONE), new Longitude(inLong, Coordinate.FORMAT_NONE), null);
+               point.setSegmentStart(true);
+               _track.appendPoints(new DataPoint[] {point});
+               _trackInfo.getSelection().selectPoint(_trackInfo.getTrack().getNumPoints()-1);
+               // add undo object to stack
+               _undoStack.add(undo);
+               // update listeners
+               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.createpoint"));
+       }
+
+
        /**
         * Rearrange the waypoints into track order
         * @param inFunction nearest point, all to end or all to start
@@ -621,6 +732,7 @@ public class App
                if (success)
                {
                        _undoStack.add(undo);
+                       UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.rearrangewaypoints"));
                }
                else
                {
@@ -630,6 +742,46 @@ public class App
        }
 
 
+       /**
+        * Cut the current selection and move it to before the currently selected point
+        */
+       public void cutAndMoveSelection()
+       {
+               int startIndex = _trackInfo.getSelection().getStart();
+               int endIndex = _trackInfo.getSelection().getEnd();
+               int pointIndex = _trackInfo.getSelection().getCurrentPointIndex();
+               // If timestamps would be mangled by cut/move, confirm
+               if (!_track.hasData(Field.TIMESTAMP, startIndex, endIndex)
+                       || _mangleTimestampsConfirmed
+                       || (JOptionPane.showConfirmDialog(_frame,
+                                I18nManager.getText("dialog.confirmcutandmove.text"),
+                                I18nManager.getText("dialog.confirmcutandmove.title"),
+                                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION && (_mangleTimestampsConfirmed = true)))
+               {
+                       // Find points to set segment flags
+                       DataPoint firstTrackPoint = _track.getNextTrackPoint(startIndex, endIndex);
+                       DataPoint nextTrackPoint = _track.getNextTrackPoint(endIndex+1);
+                       DataPoint moveToTrackPoint = _track.getNextTrackPoint(pointIndex);
+                       // Make undo object
+                       UndoCutAndMove undo = new UndoCutAndMove(_track, startIndex, endIndex, pointIndex);
+                       // Call track info to move track section
+                       if (_track.cutAndMoveSection(startIndex, endIndex, pointIndex))
+                       {
+                               // Set segment start flags (first track point, next track point, move to point)
+                               if (firstTrackPoint != null) {firstTrackPoint.setSegmentStart(true);}
+                               if (nextTrackPoint != null) {nextTrackPoint.setSegmentStart(true);}
+                               if (moveToTrackPoint != null) {moveToTrackPoint.setSegmentStart(true);}
+
+                               // Add undo object to stack, set confirm message
+                               _undoStack.add(undo);
+                               _trackInfo.getSelection().deselectRange();
+                               UpdateMessageBroker.informSubscribers();
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.cutandmove"));
+                       }
+               }
+       }
+
+
        /**
         * Open a new window with the 3d view
         */
@@ -684,9 +836,23 @@ public class App
         * @param inFilename filename used
         */
        public void informDataLoaded(Field[] inFieldArray, Object[][] inDataArray, int inAltFormat, String inFilename)
+       {
+               informDataLoaded(inFieldArray, inDataArray, inAltFormat, inFilename, false);
+       }
+
+       /**
+        * Receive loaded data and optionally merge with current Track
+        * @param inFieldArray array of fields
+        * @param inDataArray array of data
+        * @param inAltFormat altitude format
+        * @param inFilename filename used
+        * @param inOverrideAppend true to override append question and always append
+        */
+       public void informDataLoaded(Field[] inFieldArray, Object[][] inDataArray, int inAltFormat,
+               String inFilename, boolean inOverrideAppend)
        {
                // Check whether loaded array can be properly parsed into a Track
-               Track loadedTrack = new Track(_broker);
+               Track loadedTrack = new Track();
                loadedTrack.load(inFieldArray, inDataArray, inAltFormat);
                if (loadedTrack.getNumPoints() <= 0)
                {
@@ -700,10 +866,13 @@ public class App
                if (_track != null && _track.getNumPoints() > 0)
                {
                        // ask whether to replace or append
-                       int answer = JOptionPane.showConfirmDialog(_frame,
-                               I18nManager.getText("dialog.openappend.text"),
-                               I18nManager.getText("dialog.openappend.title"),
-                               JOptionPane.YES_NO_CANCEL_OPTION);
+                       int answer = JOptionPane.YES_OPTION;
+                       if (!inOverrideAppend) {
+                               answer = JOptionPane.showConfirmDialog(_frame,
+                                       I18nManager.getText("dialog.openappend.text"),
+                                       I18nManager.getText("dialog.openappend.title"),
+                                       JOptionPane.YES_NO_CANCEL_OPTION);
+                       }
                        if (answer == JOptionPane.YES_OPTION)
                        {
                                // append data to current Track
@@ -747,7 +916,9 @@ public class App
                        _trackInfo.loadTrack(inFieldArray, inDataArray, inAltFormat);
                        _trackInfo.getFileInfo().setFile(inFilename);
                }
-               _broker.informSubscribers();
+               UpdateMessageBroker.informSubscribers();
+               // Update status bar
+               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.loadfile") + " '" + inFilename + "'");
                // update menu
                _menuManager.informFileLoaded();
        }
@@ -771,18 +942,14 @@ public class App
                        }
                        if (numPhotosAdded == 1)
                        {
-                               JOptionPane.showMessageDialog(_frame,
-                                       "" + numPhotosAdded + " " + I18nManager.getText("dialog.jpegload.photoadded"),
-                                       I18nManager.getText("dialog.jpegload.title"), JOptionPane.INFORMATION_MESSAGE);
+                               UpdateMessageBroker.informSubscribers("" + numPhotosAdded + " " + I18nManager.getText("confirm.jpegload.single"));
                        }
                        else
                        {
-                               JOptionPane.showMessageDialog(_frame,
-                                       "" + numPhotosAdded + " " + I18nManager.getText("dialog.jpegload.photosadded"),
-                                       I18nManager.getText("dialog.jpegload.title"), JOptionPane.INFORMATION_MESSAGE);
+                               UpdateMessageBroker.informSubscribers("" + numPhotosAdded + " " + I18nManager.getText("confirm.jpegload.multi"));
                        }
                        // TODO: Improve message when photo(s) fail to load (eg already added)
-                       _broker.informSubscribers();
+                       UpdateMessageBroker.informSubscribers();
                        // update menu
                        _menuManager.informFileLoaded();
                }
@@ -796,13 +963,39 @@ public class App
        {
                Photo photo = _trackInfo.getCurrentPhoto();
                DataPoint point = _trackInfo.getCurrentPoint();
-               if (photo != null && point != null && point.getPhoto() == null)
+               if (photo != null && point != null)
                {
-                       // connect
-                       _undoStack.add(new UndoConnectPhoto(point, photo.getFile().getName()));
-                       photo.setDataPoint(point);
-                       point.setPhoto(photo);
-                       _broker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+                       if (point.getPhoto() != null)
+                       {
+                               // point already has a photo, confirm cloning of new point
+                               if (JOptionPane.showConfirmDialog(_frame,
+                                       I18nManager.getText("dialog.connectphoto.clonepoint"),
+                                       I18nManager.getText("dialog.connect.title"),
+                                       JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
+                               {
+                                       // Create undo, clone point and attach
+                                       int pointIndex = _trackInfo.getSelection().getCurrentPointIndex() + 1;
+                                       // insert new point after current one
+                                       point = point.clonePoint();
+                                       UndoConnectPhotoWithClone undo = new UndoConnectPhotoWithClone(
+                                               point, photo.getFile().getName(), pointIndex);
+                                       _track.insertPoint(point, pointIndex);
+                                       photo.setDataPoint(point);
+                                       point.setPhoto(photo);
+                                       _undoStack.add(undo);
+                                       UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+                                       UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.photo.connect"));
+                               }
+                       }
+                       else
+                       {
+                               // point doesn't currently have a photo, so just connect it
+                               _undoStack.add(new UndoConnectPhoto(point, photo.getFile().getName()));
+                               photo.setDataPoint(point);
+                               point.setPhoto(photo);
+                               UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+                               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.photo.connect"));
+                       }
                }
        }
 
@@ -820,7 +1013,8 @@ public class App
                        // disconnect
                        photo.setDataPoint(null);
                        point.setPhoto(null);
-                       _broker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+                       UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+                       UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.photo.disconnect"));
                }
        }
 
@@ -875,7 +1069,7 @@ public class App
        public void beginCorrelatePhotos()
        {
                PhotoCorrelator correlator = new PhotoCorrelator(this, _frame);
-               // TODO: Do we need to keep a reference to this object to reuse it later?
+               // TODO: Do we need to keep a reference to this Photo Correlator object to reuse it later?
                correlator.begin();
        }
 
@@ -958,6 +1152,8 @@ public class App
                                                        // link photo to point
                                                        pointToAdd.setPhoto(pair.getPhoto());
                                                        pair.getPhoto().setDataPoint(pointToAdd);
+                                                       // set to start of segment so not joined in track
+                                                       pointToAdd.setSegmentStart(true);
                                                        // add to point array
                                                        addedPoints[pointNum] = pointToAdd;
                                                        pointNum++;
@@ -971,10 +1167,8 @@ public class App
                        undo.setNumPhotosCorrelated(numPhotos);
                        _undoStack.add(undo);
                        // confirm correlation
-                       JOptionPane.showMessageDialog(_frame, "" + numPhotos + " "
-                                + (numPhotos==1?I18nManager.getText("dialog.correlate.confirmsingle.text"):I18nManager.getText("dialog.correlate.confirmmultiple.text")),
-                               I18nManager.getText("dialog.correlate.title"),
-                               JOptionPane.INFORMATION_MESSAGE);
+                       UpdateMessageBroker.informSubscribers("" + numPhotos + " "
+                                + (numPhotos==1?I18nManager.getText("confirm.correlate.single"):I18nManager.getText("confirm.correlate.multi")));
                        // observers already informed by track update
                }
        }
@@ -1006,6 +1200,7 @@ public class App
        {
                if (_undoStack.isEmpty())
                {
+                       // Nothing to undo
                        JOptionPane.showMessageDialog(_frame, I18nManager.getText("dialog.undo.none.text"),
                                I18nManager.getText("dialog.undo.none.title"), JOptionPane.INFORMATION_MESSAGE);
                }
@@ -1036,7 +1231,7 @@ public class App
                        _undoStack.clear();
                        _lastSavePosition = 0;
                        if (unsaved) _lastSavePosition = -1;
-                       _broker.informSubscribers();
+                       UpdateMessageBroker.informSubscribers();
                }
        }
 
@@ -1053,10 +1248,9 @@ public class App
                        {
                                ((UndoOperation) _undoStack.pop()).performUndo(_trackInfo);
                        }
-                       JOptionPane.showMessageDialog(_frame, "" + inNumUndos + " "
-                                + (inNumUndos==1?I18nManager.getText("dialog.confirmundo.single.text"):I18nManager.getText("dialog.confirmundo.multiple.text")),
-                               I18nManager.getText("dialog.confirmundo.title"),
-                               JOptionPane.INFORMATION_MESSAGE);
+                       String message = "" + inNumUndos + " "
+                                + (inNumUndos==1?I18nManager.getText("confirm.undo.single"):I18nManager.getText("confirm.undo.multi"));
+                       UpdateMessageBroker.informSubscribers(message);
                }
                catch (UndoException ue)
                {
@@ -1065,7 +1259,7 @@ public class App
                                I18nManager.getText("error.undofailed.title"),
                                JOptionPane.ERROR_MESSAGE);
                        _undoStack.clear();
-                       _broker.informSubscribers();
+                       UpdateMessageBroker.informSubscribers();
                }
                catch (EmptyStackException empty) {}
        }
@@ -1096,8 +1290,25 @@ public class App
         */
        public void showHelp()
        {
-               JOptionPane.showMessageDialog(_frame, I18nManager.getText("dialog.help.help"),
-                       I18nManager.getText("menu.help"),
-                       JOptionPane.INFORMATION_MESSAGE);
+               // show the dialog and offer to open home page
+               Object[] buttonTexts = {I18nManager.getText("button.showwebpage"), I18nManager.getText("button.cancel")};
+               if (JOptionPane.showOptionDialog(_frame, I18nManager.getText("dialog.help.help"),
+                               I18nManager.getText("menu.help"), JOptionPane.YES_NO_OPTION,
+                               JOptionPane.INFORMATION_MESSAGE, null, buttonTexts, buttonTexts[1])
+                       == JOptionPane.YES_OPTION)
+               {
+                       // User selected to launch home page
+                       if (_browserLauncher == null) {_browserLauncher = new BrowserLauncher();}
+                       _browserLauncher.launchBrowser("http://activityworkshop.net/software/prune/index.html");
+               }
+       }
+
+       /**
+        * Show a map url in an external browser
+        */
+       public void showExternalMap(int inSourceIndex)
+       {
+               if (_browserLauncher == null) {_browserLauncher = new BrowserLauncher();}
+               _browserLauncher.launchBrowser(UrlGenerator.generateUrl(inSourceIndex, _trackInfo));
        }
 }