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