001package jmri.jmrit.operations.automation.actions;
002
003import jmri.jmrit.operations.automation.Automation;
004
005public class StopAutomationAction extends RunAutomationAction {
006
007    private static final int _code = ActionCodes.STOP_AUTOMATION;
008
009    @Override
010    public int getCode() {
011        return _code;
012    }
013
014    @Override
015    public String getName() {
016        return Bundle.getMessage("StopAutomation");
017    }
018
019    @Override
020    public void doAction() {
021        if (getAutomationItem() != null) {
022            Automation automation = getAutomationItem().getAutomationToRun();
023            if (automation != null) {
024                setRunning(true);
025                automation.stop();
026            }
027            finishAction(automation != null);
028        }
029    }
030}