Search in sources :

Example 11 with FirmwareSetting

use of com.willwinder.universalgcodesender.firmware.FirmwareSetting in project Universal-G-Code-Sender by winder.

the class FirmwareSettingsTableModel method setValueAt.

@Override
public void setValueAt(Object value, int rowIndex, int columnIndex) {
    if (columnIndex == 1) {
        FirmwareSetting oldSetting = settings.get(rowIndex);
        FirmwareSetting setting = new FirmwareSetting(oldSetting.getKey(), value.toString(), oldSetting.getUnits(), oldSetting.getDescription(), oldSetting.getShortDescription());
        settings.set(rowIndex, setting);
    }
}
Also used : FirmwareSetting(com.willwinder.universalgcodesender.firmware.FirmwareSetting)

Example 12 with FirmwareSetting

use of com.willwinder.universalgcodesender.firmware.FirmwareSetting in project Universal-G-Code-Sender by winder.

the class FirmwareSettingsDialog method saveButtonActionPerformed.

private void saveButtonActionPerformed() {
    // Make a copy of all settings
    java.util.List<FirmwareSetting> settingsToUpdate = new ArrayList<>(firmwareSettingsTableModel.getSettings());
    // Loop through them and try to set them in the settings manager
    settingsToUpdate.forEach(s -> {
        FirmwareSetting updatedSetting = s;
        try {
            updatedSetting = firmwareSettingsManager.setValue(s.getKey(), s.getValue());
        } catch (FirmwareSettingsException ignored) {
            logger.log(Level.SEVERE, "Couldn't save setting: " + s.getKey() + "=" + s.getValue());
        } finally {
            firmwareSettingsTableModel.updateSetting(updatedSetting);
        }
    });
}
Also used : FirmwareSetting(com.willwinder.universalgcodesender.firmware.FirmwareSetting) ArrayList(java.util.ArrayList) FirmwareSettingsException(com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)

Aggregations

FirmwareSetting (com.willwinder.universalgcodesender.firmware.FirmwareSetting)12 FirmwareSettingsException (com.willwinder.universalgcodesender.firmware.FirmwareSettingsException)8 IFirmwareSettingsListener (com.willwinder.universalgcodesender.firmware.IFirmwareSettingsListener)3 Test (org.junit.Test)3 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)2 TimeoutException (java.util.concurrent.TimeoutException)2 TinyGGcodeCommand (com.willwinder.universalgcodesender.types.TinyGGcodeCommand)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1