+ // load next file if there's a queue
+ loadNextFile();
+ }
+
+ /**
+ * Inform the app that NO data was loaded, eg cancel pressed
+ * Only needed if there's another file waiting in the queue
+ */
+ public void informNoDataLoaded()
+ {
+ // Load next file if there's a queue
+ loadNextFile();
+ }
+
+ /**
+ * Load the next file in the waiting list, if any
+ */
+ private void loadNextFile()
+ {
+ _firstDataFile = false;
+ if (_dataFiles == null || _dataFiles.size() == 0) {
+ _dataFiles = null;
+ }
+ else {
+ new Thread(new Runnable() {
+ public void run() {
+ File f = _dataFiles.get(0);
+ _dataFiles.remove(0);
+ _fileLoader.openFile(f);
+ }
+ }).start();
+ }
+ }
+
+
+ /**
+ * Accept a list of loaded photos
+ * @param inPhotoSet Set of Photo objects
+ */
+ public void informPhotosLoaded(Set<Photo> inPhotoSet)
+ {
+ if (inPhotoSet != null && !inPhotoSet.isEmpty())
+ {
+ int[] numsAdded = _trackInfo.addPhotos(inPhotoSet);
+ int numPhotosAdded = numsAdded[0];
+ int numPointsAdded = numsAdded[1];
+ if (numPhotosAdded > 0)
+ {
+ // Save numbers so load can be undone
+ _undoStack.add(new UndoLoadPhotos(numPhotosAdded, numPointsAdded));
+ }
+ if (numPhotosAdded == 1)
+ {
+ UpdateMessageBroker.informSubscribers("" + numPhotosAdded + " " + I18nManager.getText("confirm.jpegload.single"));
+ }
+ else
+ {
+ UpdateMessageBroker.informSubscribers("" + numPhotosAdded + " " + I18nManager.getText("confirm.jpegload.multi"));
+ }
+ // MAYBE: Improve message when photo(s) fail to load (eg already added)
+ UpdateMessageBroker.informSubscribers();
+ // update menu
+ _menuManager.informFileLoaded();
+ }
+ }
+
+
+ /**
+ * Connect the current photo to the current point
+ */
+ public void connectPhotoToPoint()
+ {
+ Photo photo = _trackInfo.getCurrentPhoto();
+ DataPoint point = _trackInfo.getCurrentPoint();
+ if (photo != null && point != null)
+ {
+ if (point.getPhoto() == null)
+ {
+ // 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"));
+ }
+ }
+ }
+
+
+ /**
+ * Disconnect the current photo from its point
+ */
+ public void disconnectPhotoFromPoint()
+ {
+ Photo photo = _trackInfo.getCurrentPhoto();
+ if (photo != null && photo.getDataPoint() != null)
+ {
+ DataPoint point = photo.getDataPoint();
+ _undoStack.add(new UndoDisconnectPhoto(point, photo.getFile().getName()));
+ // disconnect
+ photo.setDataPoint(null);
+ point.setPhoto(null);
+ UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
+ UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.photo.disconnect"));
+ }
+ }
+
+
+ /**
+ * Remove the current photo, if any
+ */
+ public void deleteCurrentPhoto()
+ {
+ // Delete the current photo, and optionally its point too, keeping undo information
+ Photo currentPhoto = _trackInfo.getCurrentPhoto();
+ if (currentPhoto != null)
+ {
+ // Photo is selected, see if it has a point or not
+ boolean photoDeleted = false;
+ UndoDeletePhoto undoAction = null;
+ if (currentPhoto.getDataPoint() == null)
+ {
+ // no point attached, so just delete photo
+ undoAction = new UndoDeletePhoto(currentPhoto, _trackInfo.getSelection().getCurrentPhotoIndex(),
+ null, -1);
+ photoDeleted = _trackInfo.deleteCurrentPhoto(false);
+ }
+ else
+ {
+ // point is attached, so need to confirm point deletion
+ undoAction = new UndoDeletePhoto(currentPhoto, _trackInfo.getSelection().getCurrentPhotoIndex(),
+ currentPhoto.getDataPoint(), _trackInfo.getTrack().getPointIndex(currentPhoto.getDataPoint()));
+ int response = JOptionPane.showConfirmDialog(_frame,
+ I18nManager.getText("dialog.deletephoto.deletepoint"),
+ I18nManager.getText("dialog.deletephoto.title"),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ boolean deletePointToo = (response == JOptionPane.YES_OPTION);
+ // Cancel delete if cancel pressed or dialog closed
+ if (response == JOptionPane.YES_OPTION || response == JOptionPane.NO_OPTION)
+ {
+ photoDeleted = _trackInfo.deleteCurrentPhoto(deletePointToo);
+ }
+ }
+ // Add undo information to stack if necessary
+ if (photoDeleted)
+ {
+ _undoStack.add(undoAction);
+ }
+ }
+ }
+
+
+ /**
+ * Save the coordinates of photos in their exif data
+ */
+ public void saveExif()
+ {
+ ExifSaver saver = new ExifSaver(_frame);
+ saver.saveExifInformation(_trackInfo.getPhotoList());