001package jmri.jmrix.can.adapters.lawicell.canusb.serialdriver.configurexml; 002 003import org.jdom2.Element; 004 005import jmri.jmrix.PortAdapter; 006import jmri.jmrix.can.adapters.lawicell.canusb.serialdriver.CanUsbDriverAdapter; 007import jmri.jmrix.can.adapters.lawicell.canusb.serialdriver.ConnectionConfig; 008import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml; 009 010/** 011 * Handle XML persistance of layout connections by persistening the 012 * CanUsbDriverAdapter (and connections). Note this is named as the XML version 013 * of a ConnectionConfig object, but it's actually persisting the 014 * CanUsbDriverAdapter. 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, 2008 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(Object object) { 031 adapter = ((ConnectionConfig) object).getAdapter(); 032 } 033 034 @Override 035 protected void getInstance() { 036 adapter = new CanUsbDriverAdapter(); 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}