001package jmri.jmrit.logixng.actions.configurexml; 002 003import jmri.*; 004import jmri.configurexml.JmriConfigureXmlException; 005import jmri.jmrit.entryexit.DestinationPoints; 006import jmri.jmrit.logixng.DigitalActionManager; 007import jmri.jmrit.logixng.actions.ActionEntryExit; 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 EntryExit objects. 014 * 015 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 016 * @author Daniel Bergqvist Copyright (C) 2021 017 */ 018public class ActionEntryExitXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML { 019 020 public ActionEntryExitXml() { 021 } 022 023 /** 024 * Default implementation for storing the contents of a EntryExit 025 * 026 * @param o Object to store, of type TriggerEntryExit 027 * @return Element containing the complete info 028 */ 029 @Override 030 public Element store(Object o) { 031 ActionEntryExit p = (ActionEntryExit) o; 032 033 Element element = new Element("ActionEntryExit"); 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<DestinationPoints>(); 040 var selectEnumXml = new LogixNG_SelectEnumXml<ActionEntryExit.Operation>(); 041 042 element.addContent(selectNamedBeanXml.store( 043 p.getSelectNamedBean(), 044 "namedBean", 045 LogixNG_SelectNamedBeanXml.StoreNamedBean.SystemName)); 046 element.addContent(selectEnumXml.store(p.getSelectEnum(), "operation")); 047 048 return element; 049 } 050 051 @Override 052 public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException { // Test class that inherits this class throws exception 053 String sys = getSystemName(shared); 054 String uname = getUserName(shared); 055 ActionEntryExit h = new ActionEntryExit(sys, uname); 056 057 loadCommon(h, shared); 058 059 var selectEnumXml = new LogixNG_SelectEnumXml<ActionEntryExit.Operation>(); 060 061 var selectNamedBeanXml = new LogixNG_SelectNamedBeanXml<DestinationPoints>(); 062 selectNamedBeanXml.load(shared.getChild("namedBean"), h.getSelectNamedBean(), true); 063 selectNamedBeanXml.loadLegacy(shared, h.getSelectNamedBean(), "destinationPoints"); 064 065 selectEnumXml.load(shared.getChild("operation"), h.getSelectEnum()); 066 selectEnumXml.loadLegacy( 067 shared, h.getSelectEnum(), 068 "operationAddressing", 069 "operationDirect", 070 "operationReference", 071 "operationLocalVariable", 072 "operationFormula"); 073 074 InstanceManager.getDefault(DigitalActionManager.class).registerAction(h); 075 return true; 076 } 077 078// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TriggerEntryExitXml.class); 079}