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