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;

/**
 * @author Cedric
 */
public class AddCommandAction implements IAction {
    private final ExperimentCommand command;

    public AddCommandAction(ExperimentCommand command) {
        this.command = command;
    }

    @Override
    public boolean execute(TimelineModel model, TimelineComponent view) {
        model.addCommand(command);
        view.update(UpdateEvent.ADD_COMMAND, command);
        return true;
    }

    @Override
    public boolean undo(TimelineModel model, TimelineComponent view) {
        model.deleteCommand(command);
        view.update(UpdateEvent.DELETE_COMMAND, command);
        return true;
    }

}
