package ctbrec.ui.action;

import ctbrec.Model;
import ctbrec.recorder.Recorder;
import ctbrec.ui.controls.Dialogs;
import javafx.application.Platform;
import javafx.scene.Node;

import java.util.List;

public class StartRecordingAction extends ModelMassEditAction {

    public StartRecordingAction(Node source, List<? extends Model> models, Recorder recorder) {
        super(source, models);
        action = (m) -> {
            try {
                recorder.addModel(m);
            } catch (Exception e) {
                Platform.runLater(() ->
                Dialogs.showError(source.getScene(), "Couldn't start recording", "Starting recording of " + m.getName() + " failed", e));
            }
        };
    }
}
