001package apps.startup.configurexml;
002
003import jmri.util.startup.StartupActionsManager;
004import jmri.util.startup.StartupModel;
005import jmri.ConfigureManager;
006import jmri.InstanceManager;
007import jmri.configurexml.AbstractXmlAdapter;
008import org.jdom2.Element;
009import org.slf4j.Logger;
010import org.slf4j.LoggerFactory;
011
012/**
013 *
014 * @author Randall Wood (C) 2016
015 */
016public class StartupActionsPreferencesPanelXml extends AbstractXmlAdapter {
017
018    private final static Logger log = LoggerFactory.getLogger(StartupActionsPreferencesPanelXml.class);
019
020    /**
021     * Arrange for all {@link jmri.util.startup.StartupModel} objects to be stored.
022     *
023     * @param o Object to store, of type
024     *          {@link apps.startup.StartupActionsPreferencesPanel}
025     * @return null
026     */
027    @Override
028    public Element store(Object o) {
029        ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
030        if (cm == null) {
031            log.error("Failed to get default configure manager, can not store.");
032        } else {
033            for (StartupModel model : InstanceManager.getDefault(StartupActionsManager.class).getActions()) {
034                cm.registerPref(model);
035            }
036        }
037        return null;
038    }
039}