001package jmri.jmrix.pi.simulator;
002
003import jmri.jmrix.pi.*;
004
005/**
006 * Handle configuring a Raspberry Pi layout connection.
007 * <p>
008 * This uses the {@link RaspberryPiAdapter} class to do the actual connection.
009 *
010 * @author Paul Bender       Copyright (C) 2015
011 * @author Daniel Bergqvist  Copyright (C) 2022
012 *
013 * @see RaspberryPiAdapter
014 */
015public class RaspberryPiSimulatorConnectionConfig extends jmri.jmrix.AbstractConnectionConfig {
016
017    private boolean disabled = false;
018    private RaspberryPiAdapter adapter = null;
019
020    /**
021     * Ctor for an object being created during load process; Swing init is
022     * deferred.
023     *
024     * @param p the pre-existing adapter
025     */
026    public RaspberryPiSimulatorConnectionConfig(RaspberryPiAdapter p) {
027        super();
028        adapter = p;
029    }
030
031    /**
032     * Ctor for a connection configuration with no preexisting adapter.
033     * {@link #setInstance()} will fill the adapter member.
034     */
035    public RaspberryPiSimulatorConnectionConfig() {
036        super();
037        adapter = new RaspberryPiAdapter(true);
038    }
039
040    /**
041     * {@inheritDoc}
042     */
043    @Override
044    protected void checkInitDone() {
045    }
046
047    @Override
048    public void updateAdapter() {
049    }
050
051    @Override
052    protected void showAdvancedItems() {
053    }
054
055    /**
056     * {@inheritDoc}
057     */
058    @Override
059    public void loadDetails(final javax.swing.JPanel details) {
060        _details = details;
061        setInstance();
062    }
063
064    /**
065     * {@inheritDoc}
066     */
067    @Override
068    protected void setInstance() {
069        if (adapter == null) {
070            adapter = new RaspberryPiAdapter(true);
071        }
072    }
073
074    @Override
075    public RaspberryPiAdapter getAdapter() {
076        return adapter;
077    }
078
079    @Override
080    public String getInfo() {
081        return Bundle.getMessage("none");
082    }
083
084    String manuf = RaspberryPiConnectionTypeList.PI;
085
086    @Override
087    public String getManufacturer() {
088        return manuf;
089    }
090
091    @Override
092    public void setManufacturer(String manufacturer) {
093        manuf = manufacturer;
094    }
095
096    @Override
097    public String name() {
098        return getConnectionName();
099    }
100
101    @Override
102    public String getConnectionName() {
103        return "Raspberry Pi Simulator"; // NOI18N
104    }
105
106    @Override
107    public boolean getDisabled() {
108        return disabled;
109    }
110
111    @Override
112    public void setDisabled(boolean disable) {
113        this.disabled = disable;
114    }
115
116//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(RaspberryPiSimulatorConnectionConfig.class);
117
118}