X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fundo%2FUndoDeletePoint.java;h=adb2ea397d0baffcb3d5f410c850c8d3cc3b3cd1;hb=649c5da6ee1bbc590699e11a92316ece2ea8512d;hp=ebc4d89c9fcdf236448ea78caac40540f1b652c0;hpb=312fec956e43f5d0a38617da5d0add9c62563e2c;p=GpsPrune.git diff --git a/tim/prune/undo/UndoDeletePoint.java b/tim/prune/undo/UndoDeletePoint.java index ebc4d89..adb2ea3 100644 --- a/tim/prune/undo/UndoDeletePoint.java +++ b/tim/prune/undo/UndoDeletePoint.java @@ -2,7 +2,6 @@ package tim.prune.undo; import tim.prune.I18nManager; import tim.prune.data.DataPoint; -import tim.prune.data.Field; import tim.prune.data.TrackInfo; /** @@ -12,17 +11,23 @@ public class UndoDeletePoint implements UndoOperation { private int _pointIndex = -1; private DataPoint _point = null; + private int _photoIndex = -1; + private boolean _segmentStart = false; /** * Constructor - * @param inIndex index number of point within track + * @param inPointIndex index number of point within track * @param inPoint data point + * @param inPhotoIndex index number of photo within photo list + * @param inSegmentStart true if following track point starts new segment */ - public UndoDeletePoint(int inIndex, DataPoint inPoint) + public UndoDeletePoint(int inPointIndex, DataPoint inPoint, int inPhotoIndex, boolean inSegmentStart) { - _pointIndex = inIndex; + _pointIndex = inPointIndex; _point = inPoint; + _photoIndex = inPhotoIndex; + _segmentStart = inSegmentStart; } @@ -32,7 +37,7 @@ public class UndoDeletePoint implements UndoOperation public String getDescription() { String desc = I18nManager.getText("undo.deletepoint"); - String pointName = _point.getFieldValue(Field.WAYPT_NAME); + String pointName = _point.getWaypointName(); if (pointName != null && !pointName.equals("")) desc = desc + " " + pointName; return desc; @@ -41,7 +46,7 @@ public class UndoDeletePoint implements UndoOperation /** * Perform the undo operation on the given Track - * @param inTrack Track object on which to perform the operation + * @param inTrackInfo TrackInfo object on which to perform the operation */ public void performUndo(TrackInfo inTrackInfo) throws UndoException { @@ -50,5 +55,28 @@ public class UndoDeletePoint implements UndoOperation { throw new UndoException(getDescription()); } + // Re-attach / Re-insert photo into list if necessary + if (_point.getPhoto() != null && _photoIndex > -1) + { + // Check if photo is still in list + if (!inTrackInfo.getPhotoList().contains(_point.getPhoto())) + { + // photo has been removed - need to reinsert + inTrackInfo.getPhotoList().addPhoto(_point.getPhoto(), _photoIndex); + } + // Ensure that photo is associated with point + if (_point.getPhoto().getDataPoint() != _point) { + _point.getPhoto().setDataPoint(_point); + } + } + // Restore previous status of following track point if necessary + if (!_segmentStart) + { + // Deletion of point can only set following point to true, so only need to set it back to false + DataPoint nextTrackPoint = inTrackInfo.getTrack().getNextTrackPoint(_pointIndex + 1); + if (nextTrackPoint != null) { + nextTrackPoint.setSegmentStart(false); + } + } } -} \ No newline at end of file +}