--- /dev/null
+package tim.prune.undo;\r
+\r
+import tim.prune.I18nManager;\r
+import tim.prune.UpdateMessageBroker;\r
+import tim.prune.data.AudioClip;\r
+import tim.prune.data.DataPoint;\r
+import tim.prune.data.Photo;\r
+import tim.prune.data.TrackInfo;\r
+\r
+/**\r
+ * Operation to undo the connection of a photo and/or audio to a point\r
+ */\r
+public class UndoConnectMedia implements UndoOperation\r
+{\r
+ private DataPoint _point = null;\r
+ private String _photoFilename = null;\r
+ private String _audioFilename = null;\r
+\r
+\r
+ /**\r
+ * Constructor\r
+ * @param inPoint data point\r
+ * @param inPhotoFilename filename of photo, or null if photo not connected\r
+ * @param inAudioFilename filename of audio, or null of audio not connected\r
+ */\r
+ public UndoConnectMedia(DataPoint inPoint, String inPhotoFilename, String inAudioFilename)\r
+ {\r
+ _point = inPoint;\r
+ _photoFilename = inPhotoFilename;\r
+ _audioFilename = inAudioFilename;\r
+ }\r
+\r
+\r
+ /**\r
+ * @return description of operation including photo and/or audio filename(s)\r
+ */\r
+ public String getDescription()\r
+ {\r
+ String desc = I18nManager.getText("undo.connect") + " " + (_photoFilename==null?"":_photoFilename)\r
+ + (_photoFilename!=null && _audioFilename!=null?", ":"")\r
+ + (_audioFilename==null?"":_audioFilename);\r
+ return desc;\r
+ }\r
+\r
+\r
+ /**\r
+ * Perform the undo operation on the given Track\r
+ * @param inTrackInfo TrackInfo object on which to perform the operation\r
+ */\r
+ public void performUndo(TrackInfo inTrackInfo) throws UndoException\r
+ {\r
+ if (_photoFilename != null)\r
+ {\r
+ // Disconnect photo\r
+ Photo photo = _point.getPhoto();\r
+ if (photo != null)\r
+ {\r
+ _point.setPhoto(null);\r
+ photo.setDataPoint(null);\r
+ }\r
+ }\r
+ if (_audioFilename != null)\r
+ {\r
+ // Disconnect audio\r
+ AudioClip audio = _point.getAudio();\r
+ if (audio != null)\r
+ {\r
+ _point.setAudio(null);\r
+ audio.setDataPoint(null);\r
+ }\r
+ }\r
+ // inform subscribers\r
+ UpdateMessageBroker.informSubscribers();\r
+ }\r
+}
\ No newline at end of file