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);
}
}
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);
}
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);
}
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();
}
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;
}
}
}
Aggregations