use of com.willwinder.universalgcodesender.utils.Settings in project Universal-G-Code-Sender by winder.
the class ConnectDisconnectAction method connect.
private void connect() {
logger.log(Level.INFO, "openclose button, connection open: {0}", backend.isConnected());
if (!backend.isConnected()) {
Settings s = backend.getSettings();
String firmware = s.getFirmwareVersion();
String port = s.getPort();
int baudRate = Integer.parseInt(s.getPortRate());
ThreadHelper.invokeLater(() -> {
try {
backend.connect(firmware, port, baudRate);
} catch (Exception e) {
GUIHelpers.displayErrorDialog(e.getMessage());
}
});
} else {
try {
backend.disconnect();
} catch (Exception e) {
GUIHelpers.displayErrorDialog(e.getMessage());
}
}
}
use of com.willwinder.universalgcodesender.utils.Settings in project Universal-G-Code-Sender by winder.
the class OpenAction method openGcodeFile.
private void openGcodeFile(File f) {
ThreadHelper.invokeLater(() -> {
try {
backend.setGcodeFile(f);
Settings settings = backend.getSettings();
settings.setLastOpenedFilename(f.getAbsolutePath());
SettingsFactory.saveSettings(settings);
} catch (Exception e) {
System.err.println("Couldn't set gcode-file" + e.getMessage());
}
});
}
use of com.willwinder.universalgcodesender.utils.Settings in project Universal-G-Code-Sender by winder.
the class MacroPanel method update.
/**
* Updates a macro and saves it in the settings.
* @param index macro index
* @param field field to update
* @param text updated text
*/
private void update(int index, MACRO_FIELD field, String text) {
Settings s = backend.getSettings();
Macro macro = s.getMacro(index);
switch(field) {
case NAME:
macro.setName(text);
break;
case CODE:
macro.setGcode(text);
break;
case DESCRIPTION:
macro.setDescription(text);
break;
}
s.updateMacro(index, macro);
}
use of com.willwinder.universalgcodesender.utils.Settings in project Universal-G-Code-Sender by winder.
the class OpenGcodeFileAction method openGcodeFile.
public void openGcodeFile(File f) {
ThreadHelper.invokeLater(() -> {
try {
backend.setGcodeFile(f);
Settings settings = backend.getSettings();
settings.setLastOpenedFilename(f.getAbsolutePath());
SettingsFactory.saveSettings(settings);
} catch (Exception e) {
}
});
}
Aggregations