001package jmri.jmrix.secsi.simulator;
002
003import javax.swing.JButton;
004import javax.swing.JPanel;
005import jmri.jmrix.secsi.SecsiSystemConnectionMemo;
006import jmri.jmrix.secsi.nodeconfig.NodeConfigAction;
007
008/**
009 * Handle configuring an SECSI layout connection via a SecsiSimulator
010 * adapter.
011 * <p>
012 * This uses the {@link SimulatorAdapter} class to do the actual connection.
013 *
014 * @author Bob Jacobsen Copyright (C) 2001, 2003
015 * @author Paul Bender Copyright (C) 2009
016 * @author Mark Underwood Copyright (C) 2015
017 *
018 * @see SimulatorAdapter
019 *
020 * Based on jmri.jmrix.grapevine.simulator.ConnectionConfig
021 */
022public class ConnectionConfig extends jmri.jmrix.AbstractSimulatorConnectionConfig {
023
024    /**
025     * Ctor for an object being created during load process; Swing init is
026     * deferred.
027     * @param p Serial port adapter.
028     */
029    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
030        super(p);
031    }
032
033    /**
034     * Ctor for a connection configuration with no preexisting adapter.
035     * {@link #setInstance()} will fill the adapter member.
036     */
037    public ConnectionConfig() {
038        super();
039    }
040
041    JButton b = new JButton(Bundle.getMessage("ConfigNodesTitle"));
042
043    /**
044     * {@inheritDoc}
045     */
046    @Override
047    public void loadDetails(JPanel details) {
048        setInstance();
049
050        // have to embed the usual one in a new JPanel
051        b.addActionListener(new NodeConfigAction((SecsiSystemConnectionMemo)adapter.getSystemConnectionMemo()));
052        if (!additionalItems.contains(b)) {
053            additionalItems.add(b);
054        }
055        super.loadDetails(details);
056    }
057
058    @Override
059    public String name() {
060        return "SECSI Simulator";
061    }
062
063    String manufacturerName = jmri.jmrix.secsi.SerialConnectionTypeList.TRACTRONICS;
064
065    @Override
066    public String getManufacturer() {
067        return manufacturerName;
068    }
069
070    @Override
071    public void setManufacturer(String manu) {
072        manufacturerName = manu;
073    }
074
075    /**
076     * {@inheritDoc}
077     */
078    @Override
079    protected void setInstance() {
080        if (adapter == null) {
081            adapter = new SimulatorAdapter();
082        }
083    }
084
085}