Search in sources :

Example 1 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgDebugger method setMode.

@Override
public final void setMode(ProgrammingMode m) {
    log.debug("Setting mode from {} to {}", mode, m);
    if (getSupportedModes().contains(m)) {
        ProgrammingMode oldMode = mode;
        mode = m;
        notifyPropertyChange("Mode", oldMode, m);
    } else {
        throw new IllegalArgumentException("Invalid requested mode: " + m);
    }
}
Also used : ProgrammingMode(jmri.ProgrammingMode)

Example 2 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class LnOpsModeProgrammerTest method testGetMode.

public void testGetMode() {
    LnOpsModeProgrammer lnopsmodeprogrammer = new LnOpsModeProgrammer(sm, memo, 1, true);
    ProgrammingMode intRet = lnopsmodeprogrammer.getMode();
    Assert.assertEquals("OpsByteMode", DefaultProgrammerManager.OPSBYTEMODE, intRet);
}
Also used : ProgrammingMode(jmri.ProgrammingMode)

Example 3 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgServiceModeComboBox method programmerSelected.

/**
     * reload the interface with the new programmers
     */
void programmerSelected() {
    DefaultComboBoxModel<ProgrammingMode> model = new DefaultComboBoxModel<ProgrammingMode>();
    Programmer p = getProgrammer();
    if (p != null) {
        for (ProgrammingMode mode : getProgrammer().getSupportedModes()) {
            model.addElement(mode);
        }
    }
    log.trace("programmerSelected sets model");
    modeBox.setModel(model);
    ProgrammingMode mode = (getProgrammer() != null) ? getProgrammer().getMode() : null;
    log.trace("programmerSelected sets mode {}", mode);
    modeBox.setSelectedItem(mode);
}
Also used : Programmer(jmri.Programmer) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ProgrammingMode(jmri.ProgrammingMode)

Example 4 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgOpsModePane 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();
    // require new programmer if possible
    oldAddrValue = -1;
    // configure buttons
    int index = 0;
    List<ProgrammingMode> modes;
    if (getProgrammer() != null) {
        modes = programmer.getSupportedModes();
    } else {
        modes = ((AddressedProgrammerManager) progBox.getSelectedItem()).getDefaultModes();
    }
    // add OPSACCBYTEMODE if possible
    if (modes.contains(DefaultProgrammerManager.OPSBYTEMODE) && !modes.contains(DefaultProgrammerManager.OPSACCBYTEMODE)) {
        log.debug("   adding button for {} via AccessoryOpsModeProgrammerFacade", DefaultProgrammerManager.OPSACCBYTEMODE);
        modes.add(DefaultProgrammerManager.OPSACCBYTEMODE);
    }
    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)

Example 5 with ProgrammingMode

use of jmri.ProgrammingMode in project JMRI by JMRI.

the class ProgServiceModePane method actionPerformed.

/**
     * Listen to buttons for mode changes
     */
@Override
public void actionPerformed(@Nonnull java.awt.event.ActionEvent e) {
    // find selected button
    log.debug("Selected button: {}", e.getActionCommand());
    for (ProgrammingMode mode : buttonMap.keySet()) {
        if (mode.toString().equals(e.getActionCommand())) {
            log.debug("      set mode {} on {}", mode.toString(), getProgrammer());
            getProgrammer().setMode(mode);
            // 1st match
            return;
        }
    }
}
Also used : 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