Search in sources :

Example 16 with RouteManager

use of jmri.RouteManager 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)16 Route (jmri.Route)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 JsonException (jmri.server.json.JsonException)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Sensor (jmri.Sensor)4 SensorManager (jmri.SensorManager)4 Conditional (jmri.Conditional)3 Logix (jmri.Logix)3 Turnout (jmri.Turnout)3 SensorGroupConditional (jmri.implementation.SensorGroupConditional)3 DefaultRouteManager (jmri.managers.DefaultRouteManager)3 IOException (java.io.IOException)2 DefaultListModel (javax.swing.DefaultListModel)2 JmriException (jmri.JmriException)2 TurnoutManager (jmri.TurnoutManager)2 DefaultRoute (jmri.implementation.DefaultRoute)2 JsonMockConnection (jmri.server.json.JsonMockConnection)2 Element (org.jdom2.Element)2 ActionEvent (java.awt.event.ActionEvent)1