001package jmri.jmrix.loconet.bluetooth;
002
003import java.util.Vector;
004
005/**
006 * Definition of objects to handle configuring a LocoNet Bluetooth layout
007 * connection via a LocoNetBluetoothAdapter object.
008 */
009public class ConnectionConfig extends jmri.jmrix.AbstractSerialConnectionConfig {
010
011    /**
012     * Ctor for an object being created during load process; Swing init is
013     * deferred.
014     * @param p serial port adapter.
015     */
016    public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) {
017        super(p);
018    }
019
020    /**
021     * Ctor for a connection configuration with no preexisting adapter.
022     * {@link #setInstance()} will fill the adapter member.
023     */
024    public ConnectionConfig() {
025        super();
026    }
027
028    @Override
029    public String name() {
030        return "BT Locobridge";
031    }
032
033    /**
034     * {@inheritDoc}
035     */
036    @Override
037    protected void setInstance() {
038        if (adapter == null) {
039            adapter = new LocoNetBluetoothAdapter();
040        }
041    }
042
043    /**
044     * Overrides super method to remove unnecessary ui components (baud rate)
045     * and change the label "Serial Port: " to "Bluetooth adapter: ".
046     */
047    @Override
048    protected void showAdvancedItems() {
049        super.showAdvancedItems();
050        _details.remove(baudBoxLabel);
051        _details.remove(baudBox);
052        portBoxLabel.setText("Bluetooth adapter: ");
053    }
054
055    /**
056     * Overrides super method to remove unnecessary ui components (baud rate)
057     * and change the label "Serial Port: " to "Bluetooth adapter: ".
058     */
059    @Override
060    protected int addStandardDetails(boolean incAdvanced, int i) {
061        int out = super.addStandardDetails(incAdvanced, i);
062        _details.remove(baudBoxLabel);
063        _details.remove(baudBox);
064        portBoxLabel.setText("Bluetooth adapter: ");
065        return out;
066    }
067
068    @Override
069    protected Vector<String> getPortNames() {
070        return LocoNetBluetoothAdapter.discoverPortNames();
071    }
072
073    @Override
074    protected String[] getPortFriendlyNames() {
075        return new String[]{};
076    }
077
078    // private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ConnectionConfig.class);
079
080}