]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoDisconnectMedia.java
Version 13, August 2011
[GpsPrune.git] / tim / prune / undo / UndoDisconnectMedia.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.data.AudioClip;\r
5 import tim.prune.data.DataPoint;\r
6 import tim.prune.data.Photo;\r
7 import tim.prune.data.TrackInfo;\r
8 \r
9 /**\r
10  * Operation to undo the disconnection of a photo or audio from a point\r
11  */\r
12 public class UndoDisconnectMedia implements UndoOperation\r
13 {\r
14         private DataPoint _point = null;\r
15         private Photo _photo = null;\r
16         private AudioClip _audio = null;\r
17         private String _filename = null;\r
18 \r
19 \r
20         /**\r
21          * Constructor\r
22          * @param inPoint data point\r
23          * @param inPhoto true if photo was disconnected\r
24          * @param inAudio true if audio was disconnected\r
25          * @param inFilename filename of photo / audio\r
26          */\r
27         public UndoDisconnectMedia(DataPoint inPoint, boolean inPhoto, boolean inAudio, String inFilename)\r
28         {\r
29                 _point = inPoint;\r
30                 if (inPhoto) {\r
31                         _photo = inPoint.getPhoto();\r
32                 }\r
33                 if (inAudio) {\r
34                         _audio = inPoint.getAudio();\r
35                 }\r
36                 _filename = inFilename;\r
37         }\r
38 \r
39 \r
40         /**\r
41          * @return description of operation including filename\r
42          */\r
43         public String getDescription()\r
44         {\r
45                 return I18nManager.getText("undo.disconnect") + " " + _filename;\r
46         }\r
47 \r
48 \r
49         /**\r
50          * Perform the undo operation on the given Track\r
51          * @param inTrackInfo TrackInfo object on which to perform the operation\r
52          */\r
53         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
54         {\r
55                 // Connect again\r
56                 if (_point != null && _photo != null)\r
57                 {\r
58                         _point.setPhoto(_photo);\r
59                         _photo.setDataPoint(_point);\r
60                 }\r
61                 else if (_point != null && _audio != null)\r
62                 {\r
63                         _point.setAudio(_audio);\r
64                         _audio.setDataPoint(_point);\r
65                 }\r
66                 else {\r
67                         // throw exception if failed\r
68                         throw new UndoException(getDescription());\r
69                 }\r
70                 // clear selection\r
71                 inTrackInfo.getSelection().clearAll();\r
72         }\r
73 }