001package jmri.jmrix.marklin.simulation; 002 003import javax.swing.JPanel; 004 005/** 006 * Handle configuring a simulated Marklin CS2 layout connection 007 * via a NetworkDriverAdapter object. 008 * 009 * @author Bob Jacobsen Copyright (C) 2001, 2003 010 * @author Steve Young Copyright (C) 2024 011 */ 012public class MarklinSimConnectionConfig extends jmri.jmrix.AbstractNetworkConnectionConfig { 013 014 /** 015 * Ctor for an object being created during load process; Swing init is 016 * deferred. 017 * @param p network port adapter. 018 */ 019 public MarklinSimConnectionConfig(jmri.jmrix.NetworkPortAdapter p) { 020 super(p); 021 } 022 023 /** 024 * Ctor for a connection configuration with no preexisting adapter. 025 * {@link #setInstance()} will fill the adapter member. 026 */ 027 public MarklinSimConnectionConfig() { 028 super(); 029 } 030 031 /** 032 * {@inheritDoc} 033 */ 034 @Override 035 public void loadDetails(final JPanel details) { 036 super.loadDetails(details); 037 this.updateAdapter(); 038 portField.setEnabled(false); 039 this.hostNameField.setEditable(false); 040 } 041 042 @Override 043 public String name() { 044 return "Marklin Simulation"; // NOI18N 045 } 046 047 @Override 048 public String getConnectionName() { 049 if ( adapter!= null && adapter.getSystemConnectionMemo() != null) { 050 return adapter.getSystemConnectionMemo().getUserName(); 051 } else { 052 return null; 053 } 054 } 055 056 @Override 057 protected void setInstance() { 058 if (adapter == null) { 059 adapter = new MarklinSimDriverAdapter(); 060 } 061 } 062 063}