001package jmri.jmrix.oaktree.simulator; 002 003import javax.swing.JButton; 004import javax.swing.JPanel; 005import jmri.jmrix.oaktree.OakTreeSystemConnectionMemo; 006import jmri.jmrix.oaktree.nodeconfig.NodeConfigAction; 007 008/** 009 * Handle configuring an oaktree layout connection via an OaktreeSimulator 010 * adapter. 011 * <p> 012 * This uses the {@link SimulatorAdapter} class to do the actual connection. 013 * 014 * @author Bob Jacobsen Copyright (C) 2001, 2003 015 * @author Paul Bender Copyright (C) 2009 016 * @author Mark Underwood Copyright (C) 2015 017 * 018 * @see SimulatorAdapter 019 * 020 * Based on jmri.jmrix.grapevine.simulator.ConnectionConfig and SecsiSimulator 021 */ 022public class ConnectionConfig extends jmri.jmrix.AbstractSimulatorConnectionConfig { 023 024 /** 025 * Ctor for an object being created during load process; Swing init is 026 * deferred. 027 * @param p Serial port adapter. 028 */ 029 public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) { 030 super(p); 031 } 032 033 /** 034 * Ctor for a connection configuration with no preexisting adapter. 035 * {@link #setInstance()} will fill the adapter member. 036 */ 037 public ConnectionConfig() { 038 super(); 039 } 040 041 JButton b = new JButton(Bundle.getMessage("ConfigNodesTitle")); 042 043 /** 044 * {@inheritDoc} 045 */ 046 @Override 047 public void loadDetails(JPanel details) { 048 setInstance(); 049 050 // have to embed the usual one in a new JPanel 051 b.addActionListener(new NodeConfigAction((OakTreeSystemConnectionMemo) adapter.getSystemConnectionMemo())); 052 // add another button 053 if (!additionalItems.contains(b)) { 054 additionalItems.add(b); 055 } 056 super.loadDetails(details); 057 } 058 059 @Override 060 public String name() { 061 return "OakTree Simulator"; 062 } 063 064 String manufacturerName = jmri.jmrix.oaktree.SerialConnectionTypeList.OAK; 065 066 @Override 067 public String getManufacturer() { 068 return manufacturerName; 069 } 070 071 @Override 072 public void setManufacturer(String manu) { 073 manufacturerName = manu; 074 } 075 076 @Override 077 protected void setInstance() { 078 if (adapter == null) { 079 adapter = new SimulatorAdapter(); 080 } 081 } 082 083}