use of blue.ui.core.score.undo.ReplaceScoreObjectEdit in project blue by kunstmusik.
the class ReplaceWithBufferSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
List<Layer> layers = scorePath.getAllLayers();
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
List<Instance> instances = new ArrayList<>();
ReplaceScoreObjectEdit top = null;
for (SoundObject sObj : soundObjects) {
SoundObject replacement = getReplacementObject(buffer, instances);
replacement.setStartTime(sObj.getStartTime());
replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
layer.remove(sObj);
layer.add(replacement);
ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
if (top == null) {
top = edit;
} else {
top.addEdit(edit);
}
}
// FIXME - this part is not undoable...
sObjLib.checkAndAddInstanceSoundObjects(instances);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(top);
}
Aggregations