001package jmri.jmrit.operations.automation.actions; 002 003import java.util.List; 004 005import jmri.InstanceManager; 006import jmri.jmrit.operations.locations.Location; 007import jmri.jmrit.operations.locations.LocationManager; 008import jmri.jmrit.operations.trains.Train; 009import jmri.jmrit.operations.trains.TrainManager; 010 011public class ResetSwitchListsAction extends Action { 012 013 private static final int _code = ActionCodes.RESET_SWITCHLIST; 014 015 @Override 016 public int getCode() { 017 return _code; 018 } 019 020 @Override 021 public String getName() { 022 return Bundle.getMessage("ResetSwitchLists"); 023 } 024 025 @Override 026 public void doAction() { 027 List<Location> locations = InstanceManager.getDefault(LocationManager.class).getUniqueLocationsByNameList(); 028 for (Location location : locations) { 029 if (location.isSwitchListEnabled()) { 030 // new switch lists will now be created for the location 031 location.setSwitchListState(Location.SW_CREATE); 032 location.setStatus(Location.MODIFIED); 033 } 034 } 035 // set trains switch lists unknown, any built trains should remain on the switch 036 // lists 037 InstanceManager.getDefault(TrainManager.class).setTrainsSwitchListStatus(Train.UNKNOWN); 038 finishAction(true); 039 } 040 041 @Override 042 public void cancelAction() { 043 // no cancel for this action 044 } 045}