Search in sources :

Example 1 with IdentifyDecoder

use of jmri.jmrit.decoderdefn.IdentifyDecoder in project JMRI by JMRI.

the class CombinedLocoSelPane method startIdentifyDecoder.

/**
     * Identify loco button pressed, start the identify operation. This defines
     * what happens when the identify is done.
     */
protected void startIdentifyDecoder() {
    // start identifying a decoder
    final CombinedLocoSelPane me = this;
    Programmer p = null;
    if (selector != null && selector.isSelected()) {
        p = selector.getProgrammer();
    }
    if (p == null) {
        log.warn("Selector did not provide a programmer, use default");
        p = jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    }
    IdentifyDecoder id = new IdentifyDecoder(p) {

        private CombinedLocoSelPane who = me;

        @Override
        protected void done(int mfg, int model, int productID) {
            // if Done, updated the selected decoder
            who.selectDecoder(mfg, model, productID);
        }

        @Override
        protected void message(String m) {
            if (_statusLabel != null) {
                _statusLabel.setText(m);
            }
        }

        @Override
        protected void error() {
            // raise the button again
            iddecoder.setSelected(false);
        }
    };
    id.start();
}
Also used : Programmer(jmri.Programmer) IdentifyDecoder(jmri.jmrit.decoderdefn.IdentifyDecoder)

Example 2 with IdentifyDecoder

use of jmri.jmrit.decoderdefn.IdentifyDecoder in project JMRI by JMRI.

the class NewLocoSelPane method startIdentify.

private void startIdentify() {
    // start identifying a decoder
    final NewLocoSelPane me = this;
    Programmer p = null;
    if (selector != null && selector.isSelected())
        p = selector.getProgrammer();
    if (p == null) {
        log.warn("Selector did not provide a programmer, use default");
        p = jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer();
    }
    IdentifyDecoder id = new IdentifyDecoder(p) {

        private NewLocoSelPane who = me;

        @Override
        protected void done(int mfg, int model, int productID) {
            // if Done, updated the selected decoder
            who.selectDecoder(mfg, model, productID);
        }

        @Override
        protected void message(String m) {
            if (_statusLabel != null) {
                _statusLabel.setText(m);
            }
        }

        @Override
        public void error() {
        }
    };
    id.start();
}
Also used : Programmer(jmri.Programmer) IdentifyDecoder(jmri.jmrit.decoderdefn.IdentifyDecoder)

Aggregations

Programmer (jmri.Programmer)2 IdentifyDecoder (jmri.jmrit.decoderdefn.IdentifyDecoder)2