001package jmri.jmrix.dccpp.network; 002 003import javax.swing.JPanel; 004 005/** 006 * Handle configuring a DCC++ layout connection via Ethernet.Port 007 * <p> 008 * This uses the {@link DCCppEthernetAdapter} class to do the actual connection. 009 * 010 * @author Paul Bender Copyright (C) 2011 011 * @author Mark Underwood Copyright (C) 2015 012 * 013 * Adapted from LIUSBEthernetAdapter 014 * 015 * @see jmri.jmrix.lenz.liusbethernet.LIUSBEthernetAdapter 016 */ 017public class ConnectionConfig extends jmri.jmrix.AbstractNetworkConnectionConfig { 018 019 /** 020 * Ctor for an object being created during load process; Swing init is 021 * deferred. 022 * @param p network port adapter. 023 */ 024 public ConnectionConfig(jmri.jmrix.NetworkPortAdapter p) { 025 super(p); 026 027 } 028 029 /** 030 * Ctor for a functional Swing object with no pre-existing adapter 031 */ 032 public ConnectionConfig() { 033 super(); 034 } 035 036 @Override 037 public String name() { 038 return "DCC++ Ethernet"; 039 } 040 041 /** 042 * {@inheritDoc} 043 */ 044 @Override 045 protected void setInstance() { 046 if (adapter == null) { 047 adapter = new DCCppEthernetAdapter(); 048 } 049 } 050 051 /** 052 * {@inheritDoc} 053 */ 054 @Override 055 public void loadDetails(JPanel details) { 056 super.loadDetails(details); 057 hostNameField.setText(adapter.getHostName()); 058 portFieldLabel.setText(Bundle.getMessage("CommunicationPortLabel")); 059 portField.setText(String.valueOf(adapter.getPort())); 060 portField.setEnabled(true); 061 } 062 063 @Override 064 public boolean isHostNameAdvanced() { 065 return showAutoConfig.isSelected(); 066 } 067 068 @Override 069 public boolean isAutoConfigPossible() { 070 return true; 071 } 072 073}