001package jmri.jmrix.can.adapters.gridconnect.can2usbino.serialdriver.configurexml; 002 003import org.jdom2.Element; 004 005import jmri.jmrix.PortAdapter; 006import jmri.jmrix.can.adapters.gridconnect.can2usbino.serialdriver.ConnectionConfig; 007import jmri.jmrix.can.adapters.gridconnect.can2usbino.serialdriver.SerialDriverAdapter; 008import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml; 009 010/** 011 * Handle XML persistance of layout connections by persistening the 012 * SerialDriverAdapter (and connections). Note this is named as the XML version 013 * of a ConnectionConfig object, but it's actually persisting the 014 * SerialDriverAdapter. 015 * <p> 016 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class 017 * is the one actually registered. Reads are brought here directly via the class 018 * attribute in the XML. 019 * 020 * @author Bob Jacobsen Copyright: Copyright (c) 2003, 2012 021 * @author Andrew Crosland 2008 022 */ 023public class ConnectionConfigXml extends AbstractSerialConnectionConfigXml { 024 025 public ConnectionConfigXml() { 026 super(); 027 } 028 029 @Override 030 protected void getInstance() { 031 adapter = new SerialDriverAdapter(); 032 } 033 034 @Override 035 protected void getInstance(Object object) { 036 adapter = ((ConnectionConfig) object).getAdapter(); 037 } 038 039 @Override 040 protected void register() { 041 this.register(new ConnectionConfig(adapter)); 042 } 043 044 @Override 045 protected void loadOptions(Element shared, Element perNode, PortAdapter adapter) { 046 super.loadOptions(shared, perNode, adapter); 047 048 jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeLoadOlcbProfileSettings( 049 shared.getParentElement(), perNode.getParentElement(), adapter); 050 } 051 052 @Override 053 protected void extendElement(Element e) { 054 jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeSaveOlcbProfileSettings( 055 e, adapter); 056 } 057}