package be.iminds.ilabt.jfed.experimenter_gui.timeline.controller.action;

import be.iminds.ilabt.jfed.experimenter_gui.timeline.model.TimelineModel;
import be.iminds.ilabt.jfed.experimenter_gui.timeline.view.TimelineComponent;
import be.iminds.ilabt.jfed.experimenter_gui.timeline.view.UpdateEvent;
import be.iminds.ilabt.jfed.rspec.model.controller.ExperimentCommand;

import java.util.List;

/**
 * @author Cedric
 */
public class InstantCommandAction implements IAction {
    private final List<ExperimentCommand> commands;

    public InstantCommandAction(List<ExperimentCommand> commands) {
        this.commands = commands;
    }

    @Override
    public boolean execute(TimelineModel model, TimelineComponent view) {
        for (ExperimentCommand command : commands) {
            view.update(UpdateEvent.INSTANT_COMMAND, command);
            model.instantCommand(command);
        }
        return true;
    }

    @Override
    public boolean undo(TimelineModel model, TimelineComponent view) {
        //Can't undo this type of command
        return false;
    }
}