Search in sources :

Example 1 with NamedBeanHandleManager

use of jmri.NamedBeanHandleManager in project JMRI by JMRI.

the class ConsistControllerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    apps.tests.Log4JFixture.setUp();
    InstanceManager.setDefault(ConsistManager.class, new TestConsistManager());
    InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}
Also used : NamedBeanHandleManager(jmri.NamedBeanHandleManager) TestConsistManager(jmri.jmrit.consisttool.TestConsistManager)

Example 2 with NamedBeanHandleManager

use of jmri.NamedBeanHandleManager in project JMRI by JMRI.

the class MultiThrottleTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    apps.tests.Log4JFixture.setUp();
    JUnitUtil.resetInstanceManager();
    InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}
Also used : NamedBeanHandleManager(jmri.NamedBeanHandleManager)

Example 3 with NamedBeanHandleManager

use of jmri.NamedBeanHandleManager in project JMRI by JMRI.

the class RouteControllerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    apps.tests.Log4JFixture.setUp();
    JUnitUtil.resetInstanceManager();
    InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}
Also used : NamedBeanHandleManager(jmri.NamedBeanHandleManager)

Example 4 with NamedBeanHandleManager

use of jmri.NamedBeanHandleManager in project JMRI by JMRI.

the class WiThrottleManagerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    apps.tests.Log4JFixture.setUp();
    JUnitUtil.resetInstanceManager();
    InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}
Also used : NamedBeanHandleManager(jmri.NamedBeanHandleManager)

Example 5 with NamedBeanHandleManager

use of jmri.NamedBeanHandleManager in project JMRI by JMRI.

the class PositionableShape method setControlSensor.

/**
     * Attach a named sensor to shape
     *
     * @param pName Used as a system/user name to lookup the sensor object
     * @param hide true if sensor should be hidden
     * @param level level at which sensor is placed
     * @return error message, if any
     */
public String setControlSensor(String pName, boolean hide, int level) {
    String msg = null;
    if (pName == null || pName.trim().isEmpty()) {
        setControlSensorHandle(null);
        return null;
    }
    NamedBeanHandle<Sensor> senHandle = null;
    _saveLevel = super.getDisplayLevel();
    Optional<SensorManager> sensorManager = InstanceManager.getOptionalDefault(SensorManager.class);
    if (sensorManager.isPresent()) {
        Sensor sensor = sensorManager.get().getSensor(pName);
        Optional<NamedBeanHandleManager> nbhm = InstanceManager.getOptionalDefault(NamedBeanHandleManager.class);
        if (sensor != null) {
            if (nbhm.isPresent()) {
                senHandle = nbhm.get().getNamedBeanHandle(pName, sensor);
            }
            _doHide = hide;
            _changeLevel = level;
            if (_changeLevel <= 0) {
                _changeLevel = super.getDisplayLevel();
            }
        } else {
            // NOI18N
            msg = Bundle.getMessage("badSensorName", pName);
        }
    } else {
        // NOI18N
        msg = Bundle.getMessage("NoSensorManager");
    }
    if (msg != null) {
        log.warn("{} for {} sensor", msg, Bundle.getMessage("VisibleSensor"));
    }
    setControlSensorHandle(senHandle);
    return msg;
}
Also used : NamedBeanHandleManager(jmri.NamedBeanHandleManager) SensorManager(jmri.SensorManager) Sensor(jmri.Sensor)

Aggregations

NamedBeanHandleManager (jmri.NamedBeanHandleManager)10 TabbedPreferences (apps.gui3.TabbedPreferences)1 Sensor (jmri.Sensor)1 SensorManager (jmri.SensorManager)1 TestConsistManager (jmri.jmrit.consisttool.TestConsistManager)1 FileHistory (jmri.jmrit.revhistory.FileHistory)1 EntryExitPairs (jmri.jmrit.signalling.EntryExitPairs)1 Before (org.junit.Before)1