Search in sources :

Example 1 with SignalHeadManager

use of jmri.SignalHeadManager in project JMRI by JMRI.

the class AbstractSignalHeadManagerXml method store.

/**
     * Default implementation for storing the contents of a SignalHeadManager.
     * <P>
     * Unlike most other managers, the individual SignalHead objects are stored
     * separately via the configuration system so they can have separate type
     * information.
     *
     * @param o Object to store, of type SignalHeadManager
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    Element signalheads = new Element("signalheads");
    setStoreElementClass(signalheads);
    SignalHeadManager sm = (SignalHeadManager) o;
    if (sm != null) {
        java.util.Iterator<String> iter = sm.getSystemNameList().iterator();
        // don't return an element if there are not signalheads to include
        if (!iter.hasNext()) {
            return null;
        }
        // store the signalheads
        while (iter.hasNext()) {
            String sname = iter.next();
            if (sname == null) {
                log.error("System name null during store, skipped");
                continue;
            }
            log.debug("system name is " + sname);
            SignalHead sub = sm.getBySystemName(sname);
            try {
                Element e = jmri.configurexml.ConfigXmlManager.elementFromObject(sub);
                if (e != null) {
                    signalheads.addContent(e);
                }
            } catch (Exception e) {
                log.error("Error storing signalhead: {}", e, e);
            }
        }
    }
    return signalheads;
}
Also used : AbstractSignalHeadManager(jmri.managers.AbstractSignalHeadManager) SignalHeadManager(jmri.SignalHeadManager) Element(org.jdom2.Element) SignalHead(jmri.SignalHead)

Example 2 with SignalHeadManager

use of jmri.SignalHeadManager in project JMRI by JMRI.

the class JUnitUtil method initInternalSignalHeadManager.

public static void initInternalSignalHeadManager() {
    SignalHeadManager m = new AbstractSignalHeadManager();
    InstanceManager.setSignalHeadManager(m);
    if (InstanceManager.getNullableDefault(ConfigureManager.class) != null) {
        InstanceManager.getDefault(ConfigureManager.class).registerConfig(m, jmri.Manager.SIGNALHEADS);
    }
}
Also used : ConfigureManager(jmri.ConfigureManager) AbstractSignalHeadManager(jmri.managers.AbstractSignalHeadManager) SignalHeadManager(jmri.SignalHeadManager) AbstractSignalHeadManager(jmri.managers.AbstractSignalHeadManager)

Aggregations

SignalHeadManager (jmri.SignalHeadManager)2 AbstractSignalHeadManager (jmri.managers.AbstractSignalHeadManager)2 ConfigureManager (jmri.ConfigureManager)1 SignalHead (jmri.SignalHead)1 Element (org.jdom2.Element)1