use of blue.ui.core.score.undo.RemoveScoreObjectEdit in project blue by kunstmusik.
the class ScoreController method deleteScoreObjects.
public void deleteScoreObjects() {
if (lookup == null || content == null) {
return;
}
Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
Score score = lookup.lookup(Score.class);
if (score == null) {
throw new RuntimeException("Score object not set in ScoreController: internal error");
}
if (scoreObjects.isEmpty()) {
return;
}
List<Layer> layers = getScorePath().getAllLayers();
RemoveScoreObjectEdit top = null;
for (ScoreObject scoreObj : scoreObjects) {
RemoveScoreObjectEdit edit = null;
for (Layer layer : layers) {
if (layer.remove(scoreObj)) {
edit = new RemoveScoreObjectEdit((ScoreObjectLayer) layer, scoreObj);
break;
}
}
if (edit == null) {
throw new RuntimeException("Error: Unable to find Layer to remove ScoreObject: Internal Error");
}
if (top == null) {
top = edit;
} else {
top.appendNextEdit(edit);
}
content.remove(scoreObj);
}
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(top);
}
Aggregations