Search in sources :

Example 11 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgOpsModePane method setGuiFromProgrammer.

/**
     * Change the selected mode in GUI when programmer is changed elsewhere.
     */
void setGuiFromProgrammer() {
    if (getProgrammer() == null) {
        // no mode selected
        for (JRadioButton button : buttonPool) {
            button.setSelected(false);
        }
        return;
    }
    ProgrammingMode mode = getProgrammer().getMode();
    if (opsAccyMode) {
        mode = DefaultProgrammerManager.OPSACCBYTEMODE;
    }
    JRadioButton button = buttonMap.get(mode);
    if (button == null) {
        log.error("setGuiFromProgrammer found mode \"{}\" that's not supported by the programmer", mode);
        return;
    }
    log.debug("  setting button for mode {}", mode);
    button.setSelected(true);
    setAddrParams();
}
Also used : JRadioButton(javax.swing.JRadioButton) ProgrammingMode(jmri.ProgrammingMode)

Example 12 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgServiceModePane method setGuiFromProgrammer.

void setGuiFromProgrammer() {
    ProgrammingMode mode = getProgrammer().getMode();
    JRadioButton button = buttonMap.get(mode);
    log.debug("  setting button for mode {}", mode);
    if (button == null) {
        log.debug("   didn't find button, returning");
        return;
    }
    button.setSelected(true);
}
Also used : JRadioButton(javax.swing.JRadioButton) ProgrammingMode(jmri.ProgrammingMode)

Example 13 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgServiceModePane method programmerSelected.

/**
     * reload the interface with the new programmers
     */
void programmerSelected() {
    log.debug("programmerSelected starts with {} buttons", buttonPool.size());
    // hide buttons
    for (JRadioButton button : buttonPool) {
        button.setVisible(false);
    }
    // clear map
    buttonMap.clear();
    // configure buttons
    int index = 0;
    if (getProgrammer() == null) {
        return;
    }
    List<ProgrammingMode> modes = getProgrammer().getSupportedModes();
    log.debug("   has {} modes", modes.size());
    for (ProgrammingMode mode : modes) {
        JRadioButton button;
        // need a new button?
        if (index >= buttonPool.size()) {
            log.debug("   add button");
            button = new JRadioButton();
            buttonPool.add(button);
            modeGroup.add(button);
            button.addActionListener(this);
            // add to GUI
            add(button);
        }
        // configure next button in pool
        log.debug("   set for {}", mode.toString());
        button = buttonPool.get(index++);
        button.setVisible(true);
        modeGroup.add(button);
        button.setText(mode.toString());
        buttonMap.put(mode, button);
    }
    setGuiFromProgrammer();
}
Also used : JRadioButton(javax.swing.JRadioButton) ProgrammingMode(jmri.ProgrammingMode)

Aggregations

ProgrammingMode (jmri.ProgrammingMode)13 JRadioButton (javax.swing.JRadioButton)4 Element (org.jdom2.Element)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 Programmer (jmri.Programmer)1 Attribute (org.jdom2.Attribute)1