001package jmri.jmrix.easydcc.networkdriver;
002
003import jmri.jmrix.JmrixConfigPane;
004
005/**
006 * Definition of objects to handle configuring an EasyDCC layout connection via
007 * a NetworkDriverAdapter object.
008 *
009 * @author Bob Jacobsen Copyright (C) 2001, 2003
010 */
011public class ConnectionConfig extends jmri.jmrix.AbstractNetworkConnectionConfig {
012
013    /**
014     * Ctor for an object being created during load process; Swing init is
015     * deferred.
016     * @param p network port adapter.
017     */
018    public ConnectionConfig(jmri.jmrix.NetworkPortAdapter p) {
019        super(p);
020    }
021
022    /**
023     * Ctor for a connection configuration with no preexisting adapter.
024     * {@link #setInstance()} will fill the adapter member.
025     */
026    public ConnectionConfig() {
027        super();
028    }
029
030    @Override
031    public String name() {
032        return Bundle.getMessage("AdapterNetworkName");
033    }
034
035    /**
036     * Reimplement this method to show the connected host, rather than the usual
037     * port name.
038     *
039     * @return human-readable connection information
040     */
041    @Override
042    public String getInfo() {
043        String t = adapter.getHostName();
044        if (t != null && !t.equals("")) {
045            return t;
046        } else {
047            return JmrixConfigPane.NONE;
048        }
049    }
050
051    /**
052     * {@inheritDoc}
053     */
054    @Override
055    protected void setInstance() {
056        if (adapter == null) {
057            adapter = new NetworkDriverAdapter();
058        }
059    }
060
061    @Override
062    public boolean isPortAdvanced() {
063        return false;
064    }
065
066}