Skip to content

Commit 8302d09

Browse files
committed
Merge pull request #425 from infthi/Settings_storage_fix
Fix for preference page not saving some preferences
2 parents 86b1fad + ef59ba7 commit 8302d09

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package it.baeyens.arduino.common;
2+
3+
public class Defaults {
4+
public static final boolean OPEN_SERIAL_WITH_MONITOR = true;
5+
public static final boolean AUTO_IMPORT_LIBRARIES = true;
6+
}

it.baeyens.arduino.common/src/it/baeyens/arduino/common/InstancePreferences.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public class InstancePreferences extends Const {
2727

2828
public static boolean getOpenSerialWithMonitor() {
29-
return getGlobalBoolean(KEY_OPEN_SERIAL_WITH_MONITOR, true);
29+
return getGlobalBoolean(KEY_OPEN_SERIAL_WITH_MONITOR, Defaults.OPEN_SERIAL_WITH_MONITOR);
3030
}
3131

3232
public static void setOpenSerialWithMonitor(boolean value) {
@@ -39,7 +39,7 @@ public static void setOpenSerialWithMonitor(boolean value) {
3939
* @return true if libraries need to be added else false.
4040
*/
4141
public static boolean getAutomaticallyIncludeLibraries() {
42-
return getGlobalBoolean(KEY_AUTO_IMPORT_LIBRARIES, true);
42+
return getGlobalBoolean(KEY_AUTO_IMPORT_LIBRARIES, Defaults.AUTO_IMPORT_LIBRARIES);
4343
}
4444

4545
public static void setAutomaticallyIncludeLibraries(boolean value) {

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/PreferencePage.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.eclipse.ui.preferences.ScopedPreferenceStore;
1616

1717
import it.baeyens.arduino.common.Const;
18+
import it.baeyens.arduino.common.Defaults;
1819

1920
/**
2021
* ArduinoPreferencePage is the class that is behind the preference page of
@@ -38,7 +39,11 @@ public class PreferencePage extends FieldEditorPreferencePage implements IWorkbe
3839
public PreferencePage() {
3940
super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID);
4041
setDescription(Messages.ui_workspace_settings);
41-
setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, Const.NODE_ARDUINO));
42+
43+
ScopedPreferenceStore preferences = new ScopedPreferenceStore(InstanceScope.INSTANCE, Const.NODE_ARDUINO);
44+
preferences.setDefault(Const.KEY_OPEN_SERIAL_WITH_MONITOR, Defaults.OPEN_SERIAL_WITH_MONITOR);
45+
preferences.setDefault(Const.KEY_AUTO_IMPORT_LIBRARIES, Defaults.AUTO_IMPORT_LIBRARIES);
46+
setPreferenceStore(preferences);
4247
}
4348

4449
@Override
@@ -90,12 +95,10 @@ protected void createFieldEditors() {
9095
this.arduinoPrivateLibPath = new PathEditor(Const.KEY_PRIVATE_LIBRARY_PATHS, Messages.ui_private_lib_path,
9196
Messages.ui_private_lib_path_help, parent);
9297
addField(this.arduinoPrivateLibPath);
93-
this.arduinoPrivateLibPath.setPreferenceStore(getPreferenceStore());
9498

9599
this.arduinoPrivateHardwarePath = new PathEditor(Const.KEY_PRIVATE_HARDWARE_PATHS,
96100
Messages.ui_private_hardware_path, Messages.ui_private_hardware_path_help, parent);
97101
addField(this.arduinoPrivateHardwarePath);
98-
this.arduinoPrivateHardwarePath.setPreferenceStore(getPreferenceStore());
99102

100103
Dialog.applyDialogFont(parent);
101104
createLine(parent, 4);

0 commit comments

Comments
 (0)