001package jmri.jmrix.ieee802154.xbee;
002
003import javax.swing.JButton;
004import javax.swing.JPanel;
005import jmri.jmrix.ieee802154.xbee.swing.nodeconfig.XBeeNodeConfigAction;
006
007/**
008 * Definition of objects to handle configuring a layout connection
009 *
010 * @author Bob Jacobsen Copyright (C) 2003, 2006, 2007, 2008
011 */
012public class ConnectionConfig extends jmri.jmrix.AbstractSerialConnectionConfig {
013
014    /**
015     * Ctor for an object being created during load process; Swing init is
016     * deferred.
017     * @param p port adapter for connection
018     */
019    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
020        super(p);
021    }
022
023    /**
024     * Ctor for a connection configuration with no preexisting adapter.
025     * {@link #setInstance()} will fill the adapter member.
026     */
027    public ConnectionConfig() {
028        super();
029    }
030
031    final JButton b = new JButton(Bundle.getMessage("ConfigureXbeeTitle"));
032
033    /**
034     * {@inheritDoc}
035     */
036    @Override
037    public void loadDetails(JPanel details) {
038        b.addActionListener(new XBeeNodeConfigAction());
039        if (!additionalItems.contains(b)) {
040            additionalItems.add(b);
041        }
042        super.loadDetails(details);
043    }
044
045    @Override
046    public String name() {
047        return Bundle.getMessage("XBeeNetworkTitle");
048    }
049
050    @Override
051    protected void setInstance() {
052        if (adapter == null) {
053            adapter = new XBeeAdapter();
054        }
055    }
056
057}