001package jmri.jmrix.cmri.serial.serialdriver;
002
003import java.util.ResourceBundle;
004import javax.swing.JButton;
005import javax.swing.JPanel;
006import jmri.jmrix.cmri.CMRISystemConnectionMemo;
007import jmri.jmrix.cmri.serial.nodeconfigmanager.NodeConfigManagerAction;
008
009/**
010 * Definition of objects to handle configuring a layout connection via a C/MRI
011 * SerialDriverAdapter object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001, 2003
014 * @author Chuck Catania Copyright (C) 2017
015 */
016public class ConnectionConfig extends jmri.jmrix.AbstractSerialConnectionConfig {
017
018    public final static String NAME = Bundle.getMessage("TypeSerial");
019
020    /**
021     * Ctor for an object being created during load process; Swing init is
022     * deferred.
023     * @param p serial port adapter.
024     */
025    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
026        super(p);
027    }
028
029    /**
030     * Ctor for a connection configuration with no preexisting adapter.
031     * {@link #setInstance()} will fill the adapter member.
032     */
033    public ConnectionConfig() {
034        super();
035    }
036
037    @Override
038    public String name() {
039        return NAME;
040    }
041
042    private JButton b;
043
044    /**
045     * {@inheritDoc}
046     */
047    @Override
048    public void loadDetails(JPanel details) {
049
050        setInstance();
051        b = new JButton(Bundle.getMessage("ConfigureNodesTitle"));
052        b.addActionListener(new NodeConfigManagerAction((CMRISystemConnectionMemo)adapter.getSystemConnectionMemo()));
053        if (!additionalItems.contains(b)) {
054            additionalItems.add(b);
055        }
056        super.loadDetails(details);
057
058    }
059
060    @Override
061    protected ResourceBundle getActionModelResourceBundle() {
062        return ResourceBundle.getBundle("jmri.jmrix.cmri.CmriActionListBundle");
063    }
064
065    /**
066     * {@inheritDoc}
067     */
068    @Override
069    protected void setInstance() {
070        if (adapter == null) {
071            adapter = new SerialDriverAdapter();
072        }
073    }
074
075}