From 4da0042c0766a6d1938976a8844061e43075dec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 14 Jul 2024 11:19:14 +0200 Subject: [PATCH] Polish the dot file and create the folder when they don't exist. --- .../extensions/core/ResourceSupport.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/core/ResourceSupport.java b/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/core/ResourceSupport.java index 504f4aea..ec20c773 100644 --- a/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/core/ResourceSupport.java +++ b/org.eclipse.swtchart.extensions/src/org/eclipse/swtchart/extensions/core/ResourceSupport.java @@ -12,10 +12,11 @@ *******************************************************************************/ package org.eclipse.swtchart.extensions.core; -import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; @@ -30,7 +31,6 @@ import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.Image; import org.eclipse.swtchart.Resources; -import org.eclipse.swtchart.extensions.preferences.PreferenceInitializer; public class ResourceSupport extends Resources { @@ -88,19 +88,18 @@ private ResourceSupport() { public static IPreferenceStore getPreferenceStore() { if(preferenceStore == null) { - /* - * SWTChart may be used also in a non Eclipse context. - * Hence, a simple file preference store instead of a ScopedPreferenceStore is used. - */ - String filename = System.getProperty("user.home") + File.separator + ".eclipseswtchartsettings"; - preferenceStore = new PreferenceStore(filename); - /* - * Load existing values. - */ try { + /* + * SWTChart may be used also in a non Eclipse context. + * Hence, a simple file preference store instead of a ScopedPreferenceStore is used. + */ + Path path = Paths.get(System.getProperty("user.home"), ".eclipse", "org.eclipse.swtchart.extensions", "chart.properties"); + Files.createDirectories(path.getParent()); + preferenceStore = new PreferenceStore(path.toAbsolutePath().toString()); + /* + * Load existing values. + */ ((PreferenceStore)preferenceStore).load(); - } catch(FileNotFoundException e) { - // Ignore } catch(IOException e) { e.printStackTrace(); }