001package jmri.jmrix.acela.serialdriver; 002 003import javax.swing.JButton; 004import javax.swing.JPanel; 005import jmri.jmrix.acela.nodeconfig.NodeConfigAction; 006 007/** 008 * Definition of objects to handle configuring a CTI Electronics Acela layout 009 * connection via a SerialDriverAdapter object. 010 * 011 * @author Bob Jacobsen Copyright (C) 2001, 2003, 2008 012 * @author Bob Coleman, Copyright (C) 2007, 2008 Based on MRC example, modified 013 * to establish Acela support. 014 */ 015public class ConnectionConfig extends jmri.jmrix.AbstractSerialConnectionConfig { 016 017 /** 018 * Create a connection configuration with a preexisting adapter. This is 019 * used principally when loading a configuration that defines this 020 * connection. 021 * 022 * @param p the adapter to create a connection configuration for 023 */ 024 public ConnectionConfig(jmri.jmrix.SerialPortAdapter p) { 025 super(p); 026 } 027 028 /** 029 * Ctor for a connection configuration with no preexisting adapter. 030 * {@link #setInstance()} will fill the adapter member. 031 */ 032 public ConnectionConfig() { 033 super(); 034 } 035 036 JButton b = new JButton(Bundle.getMessage("ConfigNodesTitle")); 037 038 /** 039 * {@inheritDoc} 040 */ 041 @Override 042 public void loadDetails(JPanel details) { 043 // have to embed the usual one in a new JPanel 044 045 setInstance(); 046 047 b.addActionListener(new NodeConfigAction()); 048 if (!additionalItems.contains(b)) { 049 additionalItems.add(b); 050 } 051 super.loadDetails(details); 052 } 053 054 @Override 055 public String name() { 056 return "Acela"; // NOI18N 057 } 058 059 /** 060 * {@inheritDoc} 061 */ 062 @Override 063 protected void setInstance() { 064 if (adapter == null) { 065 adapter = new SerialDriverAdapter(); 066 } 067 } 068 069}