001package jmri.jmrit.logixng.actions.configurexml; 002 003import jmri.*; 004import jmri.configurexml.JmriConfigureXmlException; 005import jmri.jmrit.logixng.LogixNG; 006import jmri.jmrit.logixng.DigitalActionManager; 007import jmri.jmrit.logixng.actions.EnableLogixNG; 008import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectEnumXml; 009import jmri.jmrit.logixng.util.configurexml.LogixNG_SelectNamedBeanXml; 010import org.jdom2.Element; 011 012/** 013 * Handle XML configuration for EnableLogixNG objects. 014 * 015 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 016 * @author Daniel Bergqvist Copyright (C) 2024 017 */ 018public class EnableLogixNGXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML { 019 020 public EnableLogixNGXml() { 021 } 022 023 /** 024 * Default implementation for storing the contents of a EnableLogixNG 025 * 026 * @param o Object to store, of type EnableLogixNG 027 * @return Element containing the complete info 028 */ 029 @Override 030 public Element store(Object o) { 031 EnableLogixNG p = (EnableLogixNG) o; 032 033 Element element = new Element("EnableLogixNG"); 034 element.setAttribute("class", this.getClass().getName()); 035 element.addContent(new Element("systemName").addContent(p.getSystemName())); 036 037 storeCommon(p, element); 038 039 var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<LogixNG>(); 040 var selectEnumXml = new LogixNG_SelectEnumXml<EnableLogixNG.Operation>(); 041 042 element.addContent(selectNamedBeanXml.store(p.getSelectNamedBean(), "namedBean")); 043 element.addContent(selectEnumXml.store(p.getSelectEnum(), "operation")); 044 045 return element; 046 } 047 048 @Override 049 public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException { // Test class that inherits this class throws exception 050 String sys = getSystemName(shared); 051 String uname = getUserName(shared); 052 EnableLogixNG h = new EnableLogixNG(sys, uname); 053 054 loadCommon(h, shared); 055 056 var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<LogixNG>(); 057 var selectEnumXml = new LogixNG_SelectEnumXml<EnableLogixNG.Operation>(); 058 059 selectNamedBeanXml.load(shared.getChild("namedBean"), h.getSelectNamedBean()); 060 selectEnumXml.load(shared.getChild("operation"), h.getSelectEnum()); 061 062 InstanceManager.getDefault(DigitalActionManager.class).registerAction(h); 063 return true; 064 } 065 066// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(EnableLogixXml.class); 067}