]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoEditPoint.java
228795b6d5d5d34e0b15d9bf7e955fc5f3544345
[GpsPrune.git] / tim / prune / undo / UndoEditPoint.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.TrackInfo;\r
6 import tim.prune.function.edit.FieldEditList;\r
7 \r
8 /**\r
9  * Operation to undo the edit of a single point\r
10  */\r
11 public class UndoEditPoint implements UndoOperation\r
12 {\r
13         private DataPoint _originalPoint = null;\r
14         private FieldEditList _undoFieldList = null;\r
15 \r
16 \r
17         /**\r
18          * Constructor\r
19          * @param inPoint data point\r
20          * @param inUndoFieldList FieldEditList for undo operation\r
21          */\r
22         public UndoEditPoint(DataPoint inPoint, FieldEditList inUndoFieldList)\r
23         {\r
24                 _originalPoint = inPoint;\r
25                 _undoFieldList = inUndoFieldList;\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.editpoint");\r
35                 String newName = _undoFieldList.getEdit(0).getValue();\r
36                 String pointName = _originalPoint.getWaypointName();\r
37                 if (newName != null && !newName.equals(""))\r
38                         desc = desc + " " + newName;\r
39                 else if (pointName != null && !pointName.equals(""))\r
40                         desc = desc + " " + pointName;\r
41                 return desc;\r
42         }\r
43 \r
44 \r
45         /**\r
46          * Perform the undo operation on the given Track\r
47          * @param inTrackInfo TrackInfo object on which to perform the operation\r
48          */\r
49         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
50         {\r
51                 // Restore contents of point into track\r
52                 if (!inTrackInfo.getTrack().editPoint(_originalPoint, _undoFieldList, true))\r
53                 {\r
54                         // throw exception if failed\r
55                         throw new UndoException(getDescription());\r
56                 }\r
57         }\r
58 }