+++ /dev/null
-package tim.prune.undo;\r
-\r
-import tim.prune.I18nManager;\r
-import tim.prune.data.AudioClip;\r
-import tim.prune.data.DataPoint;\r
-import tim.prune.data.TrackInfo;\r
-\r
-/**\r
- * Operation to undo an auto-correlation of audios with points\r
- * (very similar to UndoCorrelatePhotos)\r
- */\r
-public class UndoCorrelateAudios implements UndoOperation\r
-{\r
- private DataPoint[] _contents = null;\r
- private DataPoint[] _audioPoints = null;\r
- private int _numCorrelated = -1;\r
-\r
-\r
- /**\r
- * Constructor\r
- * @param inTrackInfo track information\r
- */\r
- public UndoCorrelateAudios(TrackInfo inTrackInfo)\r
- {\r
- // Copy track contents\r
- _contents = inTrackInfo.getTrack().cloneContents();\r
- // Copy points associated with audios before correlation\r
- int numAudios = inTrackInfo.getAudioList().getNumAudios();\r
- _audioPoints = new DataPoint[numAudios];\r
- for (int i=0; i<numAudios; i++) {\r
- _audioPoints[i] = inTrackInfo.getAudioList().getAudio(i).getDataPoint();\r
- }\r
- }\r
-\r
- /**\r
- * @param inNumCorrelated number of audios correlated\r
- */\r
- public void setNumAudiosCorrelated(int inNumCorrelated)\r
- {\r
- _numCorrelated = inNumCorrelated;\r
- }\r
-\r
- /**\r
- * @return description of operation including parameters\r
- */\r
- public String getDescription()\r
- {\r
- return I18nManager.getText("undo.correlateaudios") + " (" + _numCorrelated + ")";\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
- // restore track to previous values\r
- inTrackInfo.getTrack().replaceContents(_contents);\r
- // restore audio association\r
- for (int i=0; i<_audioPoints.length; i++)\r
- {\r
- AudioClip audio = inTrackInfo.getAudioList().getAudio(i);\r
- // Only need to look at connected ones, since correlation wouldn't disconnect\r
- if (audio.getCurrentStatus() == AudioClip.Status.CONNECTED)\r
- {\r
- DataPoint prevPoint = _audioPoints[i];\r
- DataPoint currPoint = audio.getDataPoint();\r
- audio.setDataPoint(prevPoint);\r
- if (currPoint != null) {\r
- currPoint.setAudio(null); // disconnect\r
- }\r
- if (prevPoint != null) {\r
- prevPoint.setAudio(audio); // reconnect to prev point\r
- }\r
- }\r
- }\r
- // clear selection\r
- inTrackInfo.getSelection().clearAll();\r
- }\r
-}\r