Search in sources :

Example 1 with DefaultRouteManager

use of jmri.managers.DefaultRouteManager in project JMRI by JMRI.

the class DefaultRouteManagerXml method replaceRouteManager.

/**
     * Replace the current RouteManager, if there is one, with one newly created
     * during a load operation. This is skipped if the present one is already of
     * the right type
     */
protected void replaceRouteManager() {
    RouteManager current = InstanceManager.getNullableDefault(jmri.RouteManager.class);
    if (current != null && current.getClass().getName().equals(DefaultRouteManager.class.getName())) {
        return;
    }
    // if old manager exists, remove it from configuration process
    if (current != null) {
        InstanceManager.getDefault(jmri.ConfigureManager.class).deregister(current);
        InstanceManager.deregister(current, RouteManager.class);
    }
    // register new one with InstanceManager
    DefaultRouteManager pManager = DefaultRouteManager.instance();
    InstanceManager.store(pManager, RouteManager.class);
    // register new one for configuration
    InstanceManager.getDefault(jmri.ConfigureManager.class).registerConfig(pManager, jmri.Manager.ROUTES);
}
Also used : DefaultRouteManager(jmri.managers.DefaultRouteManager) DefaultRouteManager(jmri.managers.DefaultRouteManager) RouteManager(jmri.RouteManager)

Aggregations

RouteManager (jmri.RouteManager)1 DefaultRouteManager (jmri.managers.DefaultRouteManager)1