001package jmri.jmrix.maple.serialdriver;
002
003import javax.swing.JButton;
004import javax.swing.JPanel;
005import jmri.jmrix.maple.MapleSystemConnectionMemo;
006import jmri.jmrix.maple.nodeconfig.NodeConfigAction;
007
008/**
009 * Definition of objects to handle configuring a layout connection via a
010 * SerialDriverAdapter object.
011 *
012 * @author Bob Jacobsen Copyright (C) 2001, 2003
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("WindowTitle"));
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((MapleSystemConnectionMemo)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("TypeSerial");
053    }
054
055    /**
056     * {@inheritDoc}
057     */
058    @Override
059    protected void setInstance() {
060        if (adapter == null) {
061            adapter = new SerialDriverAdapter();
062        }
063    }
064
065}