001package jmri.jmrix.ieee802154;
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 copied from NCE into PowerLine for
019 * multiple connections by
020 * @author Ken Cameron Copyright (C) 2011 copied from PowerLine into IEEE802154
021 * by
022 * @author Paul Bender Copyright (C) 2013
023 */
024public class IEEE802154SystemConnectionMemo extends jmri.jmrix.DefaultSystemConnectionMemo implements ConfiguringSystemConnectionMemo {
025
026    public IEEE802154SystemConnectionMemo() {
027        this("Z", "IEEE802.15.4");
028    }
029
030    public IEEE802154SystemConnectionMemo(String prefix, String userName) {
031        super(prefix, userName);
032        register(); // registers general type
033        InstanceManager.store(this, IEEE802154SystemConnectionMemo.class); // also register as specific type
034        init();
035    }
036
037    /*
038     * Override the init function for any subtype specific
039     * registration into init.  init is called by the generic contstructor.
040     */
041    protected void init() {
042        // create and register the ComponentFactory
043        InstanceManager.store(componentFactory = new jmri.jmrix.ieee802154.swing.IEEE802154ComponentFactory(this),
044                jmri.jmrix.swing.ComponentFactory.class);
045
046    }
047
048    jmri.jmrix.swing.ComponentFactory componentFactory = null;
049
050    /**
051     * Traffic Controller for this instance.
052     * @param newtc tc to save for connection
053     */
054    public void setTrafficController(IEEE802154TrafficController newtc) {
055        _tc = newtc;
056    }
057
058    public IEEE802154TrafficController getTrafficController() {
059        return _tc;
060    }
061    private IEEE802154TrafficController _tc = null;
062
063    /**
064     * Configure the common managers for IEEE802154 connections. This puts the
065     * common manager config in one place.
066     */
067    @Override
068    public void configureManagers() {
069        // now does nothing here, it's done by the specific class
070    }
071
072    @Override
073    protected ResourceBundle getActionModelResourceBundle() {
074        return ResourceBundle.getBundle("jmri.jmrix.ieee802154.IEEE802154ActionListBundle");
075    }
076
077    @Override
078    public <B extends NamedBean> Comparator<B> getNamedBeanComparator(Class<B> type) {
079        return new NamedBeanComparator<>();
080    }
081
082    @Override
083    public void dispose() {
084        InstanceManager.deregister(this, IEEE802154SystemConnectionMemo.class);
085        super.dispose();
086    }
087
088}