]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/undo/UndoConnectMedia.java
Version 13, August 2011
[GpsPrune.git] / tim / prune / undo / UndoConnectMedia.java
1 package tim.prune.undo;\r
2 \r
3 import tim.prune.I18nManager;\r
4 import tim.prune.UpdateMessageBroker;\r
5 import tim.prune.data.AudioClip;\r
6 import tim.prune.data.DataPoint;\r
7 import tim.prune.data.Photo;\r
8 import tim.prune.data.TrackInfo;\r
9 \r
10 /**\r
11  * Operation to undo the connection of a photo and/or audio to a point\r
12  */\r
13 public class UndoConnectMedia implements UndoOperation\r
14 {\r
15         private DataPoint _point = null;\r
16         private String _photoFilename = null;\r
17         private String _audioFilename = null;\r
18 \r
19 \r
20         /**\r
21          * Constructor\r
22          * @param inPoint data point\r
23          * @param inPhotoFilename filename of photo, or null if photo not connected\r
24          * @param inAudioFilename filename of audio, or null of audio not connected\r
25          */\r
26         public UndoConnectMedia(DataPoint inPoint, String inPhotoFilename, String inAudioFilename)\r
27         {\r
28                 _point = inPoint;\r
29                 _photoFilename = inPhotoFilename;\r
30                 _audioFilename = inAudioFilename;\r
31         }\r
32 \r
33 \r
34         /**\r
35          * @return description of operation including photo and/or audio filename(s)\r
36          */\r
37         public String getDescription()\r
38         {\r
39                 String desc = I18nManager.getText("undo.connect") + " " + (_photoFilename==null?"":_photoFilename)\r
40                  + (_photoFilename!=null && _audioFilename!=null?", ":"")\r
41                  + (_audioFilename==null?"":_audioFilename);\r
42                 return desc;\r
43         }\r
44 \r
45 \r
46         /**\r
47          * Perform the undo operation on the given Track\r
48          * @param inTrackInfo TrackInfo object on which to perform the operation\r
49          */\r
50         public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
51         {\r
52                 if (_photoFilename != null)\r
53                 {\r
54                         // Disconnect photo\r
55                         Photo photo = _point.getPhoto();\r
56                         if (photo != null)\r
57                         {\r
58                                 _point.setPhoto(null);\r
59                                 photo.setDataPoint(null);\r
60                         }\r
61                 }\r
62                 if (_audioFilename != null)\r
63                 {\r
64                         // Disconnect audio\r
65                         AudioClip audio = _point.getAudio();\r
66                         if (audio != null)\r
67                         {\r
68                                 _point.setAudio(null);\r
69                                 audio.setDataPoint(null);\r
70                         }\r
71                 }\r
72                 // inform subscribers\r
73                 UpdateMessageBroker.informSubscribers();\r
74         }\r
75 }