001package jmri.jmrix.can.adapters.loopback;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004import javax.swing.JPanel;
005
006/**
007 * Definition of objects to handle configuring a layout connection via a CAN
008 * hexfile emulator.
009 *
010 * @author Bob Jacobsen Copyright (C) 2008
011 */
012@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "name assigned historically")
013public class ConnectionConfig extends jmri.jmrix.can.adapters.ConnectionConfig {
014
015    /**
016     * Create a connection configuration with a preexisting adapter. This is
017     * used principally when loading a configuration that defines this
018     * connection.
019     *
020     * @param p the adapter to create a connection configuration for
021     */
022    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
023        super(p);
024    }
025
026    // Needed for instantiation by reflection, do not remove.
027    /**
028     * Ctor for a connection configuration with no preexisting adapter.
029     * {@link #setInstance()} will fill the adapter member.
030     */
031    public ConnectionConfig() {
032        super();
033    }
034
035    /**
036     * {@inheritDoc}
037     */
038    @Override
039    public void loadDetails(JPanel details) {
040        super.loadDetails(details);
041        portBoxLabel.setVisible(false); // hide portBoxLabel during config, as when extending jmri.jmrix.AbstractSimulatorConnectionConfig
042        portBox.setVisible(false);      // hide portBox combo idem
043        baudBoxLabel.setVisible(false); // hide baudBoxLabel idem
044        baudBox.setVisible(false);      // hide baudBox combo idem
045        outputIntervalLabel.setVisible(true);   // show interval JSpinner idem
046        outputIntervalSpinner.setVisible(true); // show intervalLabel idem
047        outputIntervalReset.setVisible(true);   // show Interval Reset button
048    }
049
050    @Override
051    public String name() {
052        return Bundle.getMessage("CanSimulationName");
053    }
054
055    /**
056     * {@inheritDoc}
057     */
058    @Override
059    protected void setInstance() {
060        if (adapter == null) {
061            adapter = new Port();
062        }
063    }
064
065}