- /**
- * Delete the currently selected range
- */
- public void deleteSelectedRange()
- {
- if (_track != null)
- {
- // 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<numToDelete; i++)
- {
- point = _trackInfo.getTrack().getPoint(i + selStart);
- if (point != null && point.getPhoto() != null)
- {
- if (deleteAll)
- {
- deletePhotos[i] = true;
- photosToDelete[i] = point.getPhoto();
- }
- else if (deleteNone) {deletePhotos[i] = false;}
- else
- {
- int response = JOptionPane.showOptionDialog(_frame,
- I18nManager.getText("dialog.deletepoint.deletephoto") + " " + point.getPhoto().getFile().getName(),
- I18nManager.getText("dialog.deletepoint.title"),
- JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
- questionOptions, questionOptions[1]);
- // check for cancel or close
- if (response == 4 || response == -1) {return;}
- // check for yes or yes to all
- if (response == 0 || response == 2)
- {
- deletePhotos[i] = true;
- photosToDelete[i] = point.getPhoto();
- if (response == 2) {deleteAll = true;}
- }
- // check for no to all
- if (response == 3) {deleteNone = true;}
- }
- }
- }
- // add information to undo stack
- UndoDeleteRange undo = new UndoDeleteRange(_trackInfo);
- // delete requested photos
- for (int i=0; i<numToDelete; i++)
- {
- point = _trackInfo.getTrack().getPoint(i + selStart);
- if (point != null && point.getPhoto() != null)
- {
- if (deletePhotos[i])
- {
- // delete photo from list
- _trackInfo.getPhotoList().deletePhoto(_trackInfo.getPhotoList().getPhotoIndex(point.getPhoto()));
- }
- else
- {
- // decouple from point
- point.getPhoto().setDataPoint(null);
- }
- }
- }
- // call track to delete range
- if (_trackInfo.deleteRange())
- {
- _undoStack.push(undo);
- // Confirm
- UpdateMessageBroker.informSubscribers("" + numToDelete + " "
- + I18nManager.getText("confirm.deletepoint.multi"));
- }
- }
- }
- }
-
-
- /**
- * Finish the compression by deleting the marked points
- */
- public void finishCompressTrack()
- {
- UndoCompress undo = new UndoCompress(_track);
- // call track to do compress
- int numPointsDeleted = _trackInfo.deleteMarkedPoints();
- // add to undo stack if successful
- if (numPointsDeleted > 0)
- {
- undo.setNumPointsDeleted(numPointsDeleted);
- _undoStack.add(undo);
- UpdateMessageBroker.informSubscribers("" + numPointsDeleted + " "
- + (numPointsDeleted==1?I18nManager.getText("confirm.deletepoint.single"):I18nManager.getText("confirm.deletepoint.multi")));
- }
- else {
- showErrorMessage("function.compress", "dialog.compress.nonefound");
- }
- }
-