]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoConnectPhoto.java
Version 4, January 2008
[GpsPrune.git] / tim / prune / undo / UndoConnectPhoto.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.Photo;\r
6 import tim.prune.data.TrackInfo;\r
7 \r
8 /**\r
9  * Operation to undo the connection of a photo to a point\r
10  */\r
11 public class UndoConnectPhoto implements UndoOperation\r
12 {\r
13         private DataPoint _point = null;\r
14         private String _filename = null;\r
15 \r
16 \r
17         /**\r
18          * Constructor\r
19          * @param inPoint data point\r
20          * @param inFilename filename of photo\r
21          */\r
22         public UndoConnectPhoto(DataPoint inPoint, String inFilename)\r
23         {\r
24                 _point = inPoint;\r
25                 _filename = inFilename;\r
26         }\r
27 \r
28 \r
29         /**\r
30          * @return description of operation including photo filename\r
31          */\r
32         public String getDescription()\r
33         {\r
34                 String desc = I18nManager.getText("undo.connectphoto") + " " + _filename;\r
35                 return desc;\r
36         }\r
37 \r
38 \r
39         /**\r
40          * Perform the undo operation on the given Track\r
41          * @param inTrackInfo TrackInfo object on which to perform the operation\r
42          */\r
43         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
44         {\r
45                 // Disconnect again\r
46                 Photo photo = _point.getPhoto();\r
47                 if (photo != null)\r
48                 {\r
49                         _point.setPhoto(null);\r
50                         photo.setDataPoint(null);\r
51                         // inform subscribers\r
52                         inTrackInfo.triggerUpdate();\r
53                 }\r
54                 else\r
55                 {\r
56                         // throw exception if failed\r
57                         throw new UndoException(getDescription());\r
58                 }\r
59         }\r
60 }