001package jmri.jmrix.srcp.networkdriver.configurexml;
002
003import jmri.jmrix.configurexml.AbstractNetworkConnectionConfigXml;
004import jmri.jmrix.srcp.networkdriver.ConnectionConfig;
005import jmri.jmrix.srcp.networkdriver.NetworkDriverAdapter;
006
007/*import org.jdom2.*;
008 import javax.swing.*;*/
009/**
010 * Handle XML persistance of layout connections by persistening the
011 * NetworkDriverAdapter (and connections).
012 * <p>
013 * Note this is named as the XML version of a ConnectionConfig object, but it's
014 * actually persisting the NetworkDriverAdapter.
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
021 * @author Paul Bender Copyright: Copyright (c) 2010
022 */
023public class ConnectionConfigXml extends AbstractNetworkConnectionConfigXml {
024
025    public ConnectionConfigXml() {
026        super();
027    }
028
029    @Override
030    protected void getInstance() {
031        if (adapter == null) {
032            adapter = new NetworkDriverAdapter();
033        }
034    }
035
036    @Override
037    protected void getInstance(Object object) {
038        adapter = ((ConnectionConfig) object).getAdapter();
039    }
040
041    @Override
042    protected void register() {
043        this.register(new ConnectionConfig(adapter));
044    }
045}