Search in sources :

Example 1 with NceConsistRosterEntry

use of jmri.jmrix.nce.consist.NceConsistRosterEntry in project JMRI by JMRI.

the class AddressPanel method consistRosterSelected.

private void consistRosterSelected() {
    if (!(conRosterBox.getSelectedItem().equals(Bundle.getMessage("NoConsistSelected")))) {
        String rosterEntryTitle = conRosterBox.getSelectedItem().toString();
        NceConsistRosterEntry cre = NceConsistRoster.instance().entryFromTitle(rosterEntryTitle);
        DccLocoAddress a = new DccLocoAddress(Integer.parseInt(cre.getLoco1DccAddress()), cre.isLoco1LongAddress());
        addrSelector.setAddress(a);
        consistAddress = null;
        int cA = 0;
        try {
            cA = Integer.parseInt(cre.getConsistNumber());
        } catch (NumberFormatException e) {
        }
        if (0 < cA && cA < 128) {
            consistAddress = new DccLocoAddress(cA, false);
        } else {
            log.warn("consist number missing " + cre.getLoco1DccAddress());
            JOptionPane.showMessageDialog(mainPanel, Bundle.getMessage("ConsistNumberHasNotBeenAssigned"), Bundle.getMessage("NeedsConsistNumber"), JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (JOptionPane.showConfirmDialog(mainPanel, Bundle.getMessage("SendFunctionToLead"), Bundle.getMessage("NCEconsistThrottle"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
            addrSelector.setAddress(consistAddress);
            consistAddress = null;
        }
        changeOfAddress();
    }
}
Also used : NceConsistRosterEntry(jmri.jmrix.nce.consist.NceConsistRosterEntry) DccLocoAddress(jmri.DccLocoAddress)

Aggregations

DccLocoAddress (jmri.DccLocoAddress)1 NceConsistRosterEntry (jmri.jmrix.nce.consist.NceConsistRosterEntry)1