From db3d39dcd88a07789e98ce1776e7ad8db40f1684 Mon Sep 17 00:00:00 2001 From: "Pierre-Yves B." <10694593+PyvesB@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:23:16 +0200 Subject: [PATCH] Fix syncing of preferences --- .../preferences/BooleanPreferences.java | 9 +++++++++ .../preferences/StringPreferences.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/BooleanPreferences.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/BooleanPreferences.java index 73caabb..a24d2a5 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/BooleanPreferences.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/BooleanPreferences.java @@ -12,6 +12,10 @@ *******************************************************************************/ package io.github.pyvesb.eclipse_solargraph.preferences; +import org.osgi.service.prefs.BackingStoreException; + +import io.github.pyvesb.eclipse_solargraph.utils.LogHelper; + public enum BooleanPreferences implements Preference { UPDATE_GEM("AutoUpdate", "Automatically update gems", true), @@ -51,6 +55,11 @@ public Boolean getDef() { @Override public void setValue(Boolean value) { PREFERENCES.putBoolean(key, value); + try { + PREFERENCES.sync(); + } catch (BackingStoreException e) { + LogHelper.error("Exception whilst persisting preference " + this.getKey(), e); + } } } diff --git a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/StringPreferences.java b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/StringPreferences.java index 46cbff7..65d73af 100644 --- a/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/StringPreferences.java +++ b/eclipse-solargraph-plugin/src/main/java/io/github/pyvesb/eclipse_solargraph/preferences/StringPreferences.java @@ -14,7 +14,10 @@ import static io.github.pyvesb.eclipse_solargraph.utils.CommandHelper.isWindows; +import org.osgi.service.prefs.BackingStoreException; + import io.github.pyvesb.eclipse_solargraph.utils.CommandHelper; +import io.github.pyvesb.eclipse_solargraph.utils.LogHelper; public enum StringPreferences implements Preference { @@ -55,6 +58,11 @@ public String getDef() { @Override public void setValue(String value) { PREFERENCES.put(key, value); + try { + PREFERENCES.sync(); + } catch (BackingStoreException e) { + LogHelper.error("Exception whilst persisting preference " + this.getKey(), e); + } } }