001package jmri.jmrit.logixng.actions.configurexml; 002 003import jmri.InstanceManager; 004import jmri.jmrit.logixng.DigitalActionManager; 005import jmri.jmrit.logixng.actions.LogLocalVariables; 006 007import org.jdom2.Element; 008 009/** 010 * Handle XML configuration for ActionLightXml objects. 011 * 012 * @author Bob Jacobsen Copyright: Copyright (c) 2004, 2008, 2010 013 * @author Daniel Bergqvist Copyright (C) 2019 014 */ 015public class LogLocalVariablesXml extends jmri.managers.configurexml.AbstractNamedBeanManagerConfigXML { 016 017 public LogLocalVariablesXml() { 018 } 019 020 /** 021 * Default implementation for storing the contents of a SE8cSignalHead 022 * 023 * @param o Object to store, of type TripleSensorSignalHead 024 * @return Element containing the complete info 025 */ 026 @Override 027 public Element store(Object o) { 028 LogLocalVariables p = (LogLocalVariables) o; 029 030 Element element = new Element("LogLocalVariables"); 031 element.setAttribute("class", this.getClass().getName()); 032 element.addContent(new Element("systemName").addContent(p.getSystemName())); 033 034 storeCommon(p, element); 035 036 element.addContent(new Element("includeGlobalVariables").addContent(p.isIncludeGlobalVariables()? "yes" : "no")); 037 element.addContent(new Element("expandArraysAndMaps").addContent(p.isExpandArraysAndMaps()? "yes" : "no")); 038 if (p.isShowClassName()) { 039 element.addContent(new Element("showClassName").addContent("yes")); 040 } 041 042 return element; 043 } 044 045 @Override 046 public boolean load(Element shared, Element perNode) { 047 String sys = getSystemName(shared); 048 String uname = getUserName(shared); 049 050 LogLocalVariables h = new LogLocalVariables(sys, uname); 051 052 loadCommon(h, shared); 053 054 Element includeGlobalVariables = shared.getChild("includeGlobalVariables"); 055 if (includeGlobalVariables != null) { 056 h.setIncludeGlobalVariables("yes".equals(includeGlobalVariables.getTextTrim())); 057 } else { 058 h.setIncludeGlobalVariables(true); 059 } 060 061 Element _expand = shared.getChild("expandArraysAndMaps"); 062 if (_expand != null) { 063 h.setExpandArraysAndMaps("yes".equals(_expand.getTextTrim())); 064 } else { 065 h.setExpandArraysAndMaps(false); 066 } 067 068 Element _showClassName = shared.getChild("showClassName"); 069 if (_showClassName != null) { 070 h.setShowClassName("yes".equals(_showClassName.getTextTrim())); 071 } else { 072 h.setShowClassName(false); 073 } 074 075 InstanceManager.getDefault(DigitalActionManager.class).registerAction(h); 076 return true; 077 } 078 079// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogLocalVariablesXml.class); 080}