Search in sources :

Example 1 with RemoveScoreObjectEdit

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);
}
Also used : Score(blue.score.Score) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) RemoveScoreObjectEdit(blue.ui.core.score.undo.RemoveScoreObjectEdit) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Aggregations

Score (blue.score.Score)1 ScoreObject (blue.score.ScoreObject)1 Layer (blue.score.layers.Layer)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1 RemoveScoreObjectEdit (blue.ui.core.score.undo.RemoveScoreObjectEdit)1