]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoEditPoint.java
Version 2, March 2007
[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.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 pointName = _originalPoint.getWaypointName();\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 contents of point into track\r
49                 if (!inTrackInfo.getTrack().editPoint(_originalPoint, _undoFieldList))\r
50                 {\r
51                         // throw exception if failed\r
52                         throw new UndoException(getDescription());\r
53                 }\r
54                 // TODO: Deal with photo if necessary\r
55         }\r
56 }