]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoInsert.java
51da59577c25ceb0b57001aba3b8c463c0a41943
[GpsPrune.git] / tim / prune / undo / UndoInsert.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.TrackInfo;\r
5 \r
6 /**\r
7  * Operation to undo an insertion (eg interpolate)\r
8  */\r
9 public class UndoInsert implements UndoOperation\r
10 {\r
11         private int _startPosition = 0;\r
12         private int _numInserted = 0;\r
13 \r
14 \r
15         /**\r
16          * Constructor\r
17          * @param inStart start of insert\r
18          * @param inNumInserted number of points inserted\r
19          */\r
20         public UndoInsert(int inStart, int inNumInserted)\r
21         {\r
22                 _startPosition = inStart;\r
23                 _numInserted = inNumInserted;\r
24         }\r
25 \r
26 \r
27         /**\r
28          * @return description of operation including parameters\r
29          */\r
30         public String getDescription()\r
31         {\r
32                 return I18nManager.getText("undo.insert") + " (" + _numInserted + ")";\r
33         }\r
34 \r
35 \r
36         /**\r
37          * Perform the undo operation on the given TrackInfo\r
38          * @param inTrackInfo TrackInfo object on which to perform the operation\r
39          */\r
40         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
41         {\r
42                 // restore track to previous values\r
43                 inTrackInfo.getTrack().deleteRange(_startPosition, _startPosition + _numInserted - 1);\r
44                 // reset selection\r
45                 inTrackInfo.getSelection().select(_startPosition-1, _startPosition-1, _startPosition);\r
46         }\r
47 }