001package jmri.jmrix.bachrus; 002 003import java.util.Comparator; 004import java.util.ResourceBundle; 005 006import jmri.jmrix.ConfiguringSystemConnectionMemo; 007import jmri.InstanceManager; 008import jmri.NamedBean; 009import jmri.util.NamedBeanComparator; 010 011/** 012 * Lightweight class to denote that a system is active, and provide general 013 * information. 014 * <p> 015 * Objects of specific subtypes are registered in the instance manager to 016 * activate their particular system. 017 * 018 * @author Bob Jacobsen Copyright (C) 2010 019 */ 020public class SpeedoSystemConnectionMemo extends jmri.jmrix.DefaultSystemConnectionMemo implements ConfiguringSystemConnectionMemo { 021 022 public SpeedoSystemConnectionMemo(SpeedoTrafficController tc) { 023 super("A", "Speedo"); 024 this.tc = tc; 025 register(); 026 InstanceManager.store(cf = new jmri.jmrix.bachrus.swing.SpeedoComponentFactory(this), 027 jmri.jmrix.swing.ComponentFactory.class); 028 } 029 030 public SpeedoSystemConnectionMemo() { 031 super("A", "Speedo"); 032 register(); // registers general type 033 InstanceManager.store(this, SpeedoSystemConnectionMemo.class); // also register as specific type 034 //Needs to be implemented 035 InstanceManager.store(cf = new jmri.jmrix.bachrus.swing.SpeedoComponentFactory(this), 036 jmri.jmrix.swing.ComponentFactory.class); 037 } 038 039 jmri.jmrix.swing.ComponentFactory cf = null; 040 041 /** 042 * Provide access to the TrafficController for this particular connection. 043 * @return traffic controller. 044 */ 045 public SpeedoTrafficController getTrafficController() { 046 return tc; 047 } 048 049 public void setSpeedoTrafficController(SpeedoTrafficController tc) { 050 this.tc = tc; 051 } 052 private SpeedoTrafficController tc; 053 054 /** 055 * Configure the common managers for Internal connections. This puts the 056 * common manager config in one place. This method is static so that it can 057 * be referenced from classes that don't inherit. 058 */ 059 @Override 060 public void configureManagers() { 061 // None to configure 062 } 063 064 @Override 065 protected ResourceBundle getActionModelResourceBundle() { 066 // No Actions at start up to return 067 return null; 068 } 069 070 @Override 071 public <B extends NamedBean> Comparator<B> getNamedBeanComparator(Class<B> type) { 072 return new NamedBeanComparator<>(); 073 } 074 075 @Override 076 public void dispose() { 077 tc = null; 078 InstanceManager.deregister(this, SpeedoSystemConnectionMemo.class); 079 if (cf != null) { 080 InstanceManager.deregister(cf, jmri.jmrix.swing.ComponentFactory.class); 081 } 082 super.dispose(); 083 } 084 085}