X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosUIPreferences.java;h=a28c07b06a9c5202cb71989b99012332eedc587e;hp=8f1e45d93e5e48116ac077fe4ef1d8cf6f54ed90;hb=f985ea055d935b10ae9ae8441fe808ba2c13c99e;hpb=fe009534ce6846b6db96cac8f6c2d53ba8010d91 diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index 8f1e45d9..a28c07b0 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -19,12 +19,8 @@ package altosui; import java.io.*; import java.util.*; -import java.text.*; -import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; import java.awt.Component; import javax.swing.*; -import javax.swing.filechooser.FileSystemView; import org.altusmetrum.AltosLib.*; public class AltosUIPreferences extends AltosPreferences { @@ -50,14 +46,16 @@ public class AltosUIPreferences extends AltosPreferences { static boolean serial_debug; public static void init() { + AltosPreferences.init(new AltosUIPreferencesBackend()); + font_listeners = new LinkedList(); - font_size = preferences.getInt(fontSizePreference, Altos.font_size_medium); + font_size = backend.getInt(fontSizePreference, Altos.font_size_medium); Altos.set_fonts(font_size); - look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName()); + look_and_feel = backend.getString(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName()); ui_listeners = new LinkedList(); - serial_debug = preferences.getBoolean(serialDebugPreference, false); + serial_debug = backend.getBoolean(serialDebugPreference, false); AltosLink.set_debug(serial_debug); } @@ -102,7 +100,7 @@ public class AltosUIPreferences extends AltosPreferences { } } public static int font_size() { - synchronized (preferences) { + synchronized (backend) { return font_size; } } @@ -111,9 +109,9 @@ public class AltosUIPreferences extends AltosPreferences { } public static void set_font_size(int new_font_size) { - synchronized (preferences) { + synchronized (backend) { font_size = new_font_size; - preferences.putInt(fontSizePreference, font_size); + backend.putInt(fontSizePreference, font_size); flush_preferences(); Altos.set_fonts(font_size); for (AltosFontListener l : font_listeners) @@ -122,13 +120,13 @@ public class AltosUIPreferences extends AltosPreferences { } public static void register_font_listener(AltosFontListener l) { - synchronized (preferences) { + synchronized (backend) { font_listeners.add(l); } } public static void unregister_font_listener(AltosFontListener l) { - synchronized (preferences) { + synchronized (backend) { font_listeners.remove(l); } } @@ -138,9 +136,9 @@ public class AltosUIPreferences extends AltosPreferences { UIManager.setLookAndFeel(new_look_and_feel); } catch (Exception e) { } - synchronized(preferences) { + synchronized(backend) { look_and_feel = new_look_and_feel; - preferences.put(lookAndFeelPreference, look_and_feel); + backend.putString(lookAndFeelPreference, look_and_feel); flush_preferences(); for (AltosUIListener l : ui_listeners) l.ui_changed(look_and_feel); @@ -148,35 +146,35 @@ public class AltosUIPreferences extends AltosPreferences { } public static String look_and_feel() { - synchronized (preferences) { + synchronized (backend) { return look_and_feel; } } public static void register_ui_listener(AltosUIListener l) { - synchronized(preferences) { + synchronized(backend) { ui_listeners.add(l); } } public static void unregister_ui_listener(AltosUIListener l) { - synchronized (preferences) { + synchronized (backend) { ui_listeners.remove(l); } } public static void set_serial_debug(boolean new_serial_debug) { - AltosLink.set_debug(new_serial_debug); - synchronized (preferences) { + AltosLink.set_debug(serial_debug); + synchronized (backend) { serial_debug = new_serial_debug; - preferences.putBoolean(serialDebugPreference, serial_debug); + backend.putBoolean(serialDebugPreference, serial_debug); flush_preferences(); } } public static boolean serial_debug() { - synchronized (preferences) { + synchronized (backend) { return serial_debug; } } -} \ No newline at end of file +}