1 package tim.prune.undo;
3 import tim.prune.data.TrackInfo;
6 * Abstract class to hold the selection handling required by all
7 * Undo operations which have undeleted something
9 public abstract class UndoDeleteOperation implements UndoOperation
12 * Modify the current point/range selection after the delete operation is undone
13 * @param inTrackInfo track info object
14 * @param inStartIndex start index of reinserted range
15 * @param inEndIndex end index of reinserted range
17 protected static void modifySelection(TrackInfo inTrackInfo, int inStartIndex, int inEndIndex)
19 final int numPointsInserted = inEndIndex - inStartIndex + 1;
20 // See if there is a currently selected point, if so does it need to be modified
21 final int currentPoint = inTrackInfo.getSelection().getCurrentPointIndex();
22 if (currentPoint >= inStartIndex)
24 inTrackInfo.selectPoint(currentPoint + numPointsInserted);
26 // Same for currently selected range
27 int rangeStart = inTrackInfo.getSelection().getStart();
28 int rangeEnd = inTrackInfo.getSelection().getEnd();
29 if (rangeEnd >= inStartIndex && rangeEnd > rangeStart)
31 rangeEnd += numPointsInserted;
32 if (rangeStart >= inStartIndex) {
33 rangeStart += numPointsInserted;
35 inTrackInfo.getSelection().selectRange(rangeStart, rangeEnd);