001package jmri.jmrix.can.adapters.gridconnect.net.configurexml; 002 003import org.jdom2.Element; 004 005import jmri.jmrix.PortAdapter; 006import jmri.jmrix.can.adapters.gridconnect.net.ConnectionConfig; 007import jmri.jmrix.can.adapters.gridconnect.net.NetworkDriverAdapter; 008import jmri.jmrix.configurexml.AbstractNetworkConnectionConfigXml; 009 010/** 011 * Handle XML persistance of layout connections by persistening the 012 * NetworkDriverAdapter (and connections). 013 * <p> 014 * Note this is named as the XML version of a ConnectionConfig object, but it's 015 * actually persisting the NetworkDriverAdapter. 016 * <p> 017 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class 018 * is the one actually registered. Reads are brought here directly via the class 019 * attribute in the XML. 020 * 021 * @author Bob Jacobsen Copyright: Copyright (c) 2003 022 */ 023public class ConnectionConfigXml extends AbstractNetworkConnectionConfigXml { 024 025 public ConnectionConfigXml() { 026 super(); 027 } 028 029 @Override 030 protected void getInstance() { 031 adapter = new NetworkDriverAdapter(); 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(e, 055 adapter); 056 } 057}