001package jmri.jmrix.cmri.serial.networkdriver;
002
003import javax.swing.JButton;
004import javax.swing.JPanel;
005import jmri.jmrix.cmri.CMRISystemConnectionMemo;
006import jmri.jmrix.cmri.serial.nodeconfigmanager.NodeConfigManagerAction;
007
008/**
009 * Definition of objects to handle configuring a layout connection via a
010 * NetworkDriverAdapter object.
011 *
012 * @author Bob Jacobsen Copyright (C) 2001, 2003, 2015
013 */
014public class ConnectionConfig extends jmri.jmrix.AbstractNetworkConnectionConfig {
015
016    public final static String NAME = "Network Interface";
017
018    /**
019     * Ctor for an object being created during load process; Swing init is
020     * deferred.
021     * @param p network port adapter.
022     */
023    public ConnectionConfig(jmri.jmrix.NetworkPortAdapter p) {
024        super(p);
025    }
026
027    /**
028     * Ctor for a functional Swing object with no existing adapter.
029     */
030    public ConnectionConfig() {
031        super();
032    }
033
034    @Override
035    public String name() {
036        return NAME;
037    }
038
039    JButton b;
040
041    /**
042     * {@inheritDoc}
043     */
044    @Override
045    public void loadDetails(JPanel details) {
046
047        setInstance();
048        b = new JButton(Bundle.getMessage("ConfigureNodesTitle"));
049        b.addActionListener(new NodeConfigManagerAction((CMRISystemConnectionMemo)adapter.getSystemConnectionMemo()));
050        if (!additionalItems.contains(b)) {
051            additionalItems.add(b);
052        }
053        super.loadDetails(details);
054    }
055
056    /**
057     * {@inheritDoc}
058     */
059    @Override
060    protected void setInstance() {
061        if (adapter == null) {
062            adapter = new NetworkDriverAdapter();
063        }
064    }
065
066}