001package jmri.jmrit.display.configurexml; 002 003import jmri.configurexml.JmriConfigureXmlException; 004import jmri.jmrit.display.*; 005 006import org.jdom2.Element; 007 008/** 009 * Handle configuration for display.GlobalVariableSpinnerIcon objects. 010 * 011 * @author Bob Jacobsen Copyright: Copyright (c) 2009 012 * @author Daniel Bergqvist Copyright (C) 2022 013 */ 014public class GlobalVariableSpinnerIconXml extends PositionableLabelXml { 015 016 public GlobalVariableSpinnerIconXml() { 017 } 018 019 /** 020 * Default implementation for storing the contents of a GlobalVariableSpinnerIcon 021 * 022 * @param o Object to store, of type GlobalVariableSpinnerIcon 023 * @return Element containing the complete info 024 */ 025 @Override 026 public Element store(Object o) { 027 028 GlobalVariableSpinnerIcon p = (GlobalVariableSpinnerIcon) o; 029 030 Element element = new Element("globalVariableIcon"); 031 032 // include attributes 033 element.setAttribute("globalVariable", p.getNamedGlobalVariable().getName()); 034 storeCommonAttributes(p, element); 035 storeTextInfo(p, element); 036 037 storeLogixNG_Data(p, element); 038 039 element.setAttribute("class", "jmri.jmrit.display.configurexml.GlobalVariableSpinnerIconXml"); 040 return element; 041 } 042 043 /** 044 * Load, starting with the globalVariableIcon element, then all the value-icon pairs 045 * 046 * @param element Top level Element to unpack. 047 * @param o Editor as an Object 048 * @throws JmriConfigureXmlException when a error prevents creating the objects as as 049 * required by the input XML 050 */ 051 @Override 052 public void load(Element element, Object o) throws JmriConfigureXmlException { 053 // create the objects 054 Editor p = (Editor) o; 055 GlobalVariableSpinnerIcon l = new GlobalVariableSpinnerIcon(p); 056 057 l.setGlobalVariable(element.getAttribute("globalVariable").getValue()); 058 059 loadTextInfo(l, element); 060 try { 061 p.putItem(l); 062 } catch (Positionable.DuplicateIdException e) { 063 throw new JmriConfigureXmlException("Positionable id is not unique", e); 064 } 065 066 loadLogixNG_Data(l, element); 067 068 // load individual item's option settings after editor has set its global settings 069 loadCommonAttributes(l, Editor.MEMORIES, element); 070 } 071}