summaryrefslogtreecommitdiff
path: root/altosui/AltosPreferences.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-04-19 08:43:40 -0700
committerKeith Packard <keithp@keithp.com>2011-04-19 08:43:40 -0700
commit17f38e045fcd8ca0224095c0b2b7b098df77a8d8 (patch)
tree07c49d1151a54d3176f2356b55b6f9f129305b9c /altosui/AltosPreferences.java
parentf249e5926f5fd9f86c41e7f0a414193533d4d8b0 (diff)
altosui: Use persistent list of bluetooth devices for device dialogs
Store a list of known bluetooth devices as preferences. Always include those in device dialogs with an option to go browse for more devices in both the device dialog and the Configure AltosUI dialog. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosPreferences.java')
-rw-r--r--altosui/AltosPreferences.java25
1 files changed, 18 insertions, 7 deletions
diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java
index 5f827655..b1192be1 100644
--- a/altosui/AltosPreferences.java
+++ b/altosui/AltosPreferences.java
@@ -79,11 +79,9 @@ class AltosPreferences {
/* Serial debug */
static boolean serial_debug;
- public static void init(Component ui) {
+ public static void init() {
preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
- component = ui;
-
/* Initialize logdir from preferences */
String logdir_string = preferences.get(logdirPreference, null);
if (logdir_string != null)
@@ -116,14 +114,23 @@ class AltosPreferences {
AltosSerial.set_debug(serial_debug);
}
+ static { init(); }
+
+ static void set_component(Component in_component) {
+ component = in_component;
+ }
+
static void flush_preferences() {
try {
preferences.flush();
} catch (BackingStoreException ee) {
- JOptionPane.showMessageDialog(component,
- preferences.absolutePath(),
- "Cannot save prefernces",
- JOptionPane.ERROR_MESSAGE);
+ if (component != null)
+ JOptionPane.showMessageDialog(component,
+ preferences.absolutePath(),
+ "Cannot save prefernces",
+ JOptionPane.ERROR_MESSAGE);
+ else
+ System.err.printf("Cannot save preferences\n");
}
}
@@ -262,4 +269,8 @@ class AltosPreferences {
public static boolean serial_debug() {
return serial_debug;
}
+
+ public static Preferences bt_devices() {
+ return preferences.node("bt_devices");
+ }
}