Search in sources :

Example 11 with Settings

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());
        }
    }
}
Also used : Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 12 with Settings

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());
        }
    });
}
Also used : Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 13 with Settings

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);
}
Also used : Macro(com.willwinder.universalgcodesender.types.Macro) Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 14 with Settings

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) {
        }
    });
}
Also used : Settings(com.willwinder.universalgcodesender.utils.Settings)

Aggregations

Settings (com.willwinder.universalgcodesender.utils.Settings)14 Macro (com.willwinder.universalgcodesender.types.Macro)3 IFirmwareSettings (com.willwinder.universalgcodesender.firmware.IFirmwareSettings)2 AbstractUGSSettings (com.willwinder.universalgcodesender.uielements.helpers.AbstractUGSSettings)2 MigLayout (net.miginfocom.swing.MigLayout)2 Test (org.junit.Test)2 Gson (com.google.gson.Gson)1 ActionRegistrationService (com.willwinder.ugs.nbp.lib.services.ActionRegistrationService)1 AbstractController (com.willwinder.universalgcodesender.AbstractController)1 UGSEventListener (com.willwinder.universalgcodesender.listeners.UGSEventListener)1 BackendAPI (com.willwinder.universalgcodesender.model.BackendAPI)1 StepSizeOption (com.willwinder.universalgcodesender.pendantui.PendantConfigBean.StepSizeOption)1 ActionEvent (java.awt.event.ActionEvent)1 Before (org.junit.Before)1 FileObject (org.openide.filesystems.FileObject)1