]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoDeletePoint.java
Version 1, September 2006
[GpsPrune.git] / tim / prune / undo / UndoDeletePoint.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.DataPoint;\r
5 import tim.prune.data.Field;\r
6 import tim.prune.data.TrackInfo;\r
7 \r
8 /**\r
9  * Operation to undo a delete of a single point\r
10  */\r
11 public class UndoDeletePoint implements UndoOperation\r
12 {\r
13         private int _pointIndex = -1;\r
14         private DataPoint _point = null;\r
15 \r
16 \r
17         /**\r
18          * Constructor\r
19          * @param inIndex index number of point within track\r
20          * @param inPoint data point\r
21          */\r
22         public UndoDeletePoint(int inIndex, DataPoint inPoint)\r
23         {\r
24                 _pointIndex = inIndex;\r
25                 _point = inPoint;\r
26         }\r
27 \r
28 \r
29         /**\r
30          * @return description of operation including point name if any\r
31          */\r
32         public String getDescription()\r
33         {\r
34                 String desc = I18nManager.getText("undo.deletepoint");\r
35                 String pointName = _point.getFieldValue(Field.WAYPT_NAME);\r
36                 if (pointName != null && !pointName.equals(""))\r
37                         desc = desc + " " + pointName;\r
38                 return desc;\r
39         }\r
40 \r
41 \r
42         /**\r
43          * Perform the undo operation on the given Track\r
44          * @param inTrack Track object on which to perform the operation\r
45          */\r
46         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
47         {\r
48                 // restore point into track\r
49                 if (!inTrackInfo.getTrack().insertPoint(_point, _pointIndex))\r
50                 {\r
51                         throw new UndoException(getDescription());\r
52                 }\r
53         }\r
54 }