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