- private void setLogdir() {
- if (logdir == null)
- logdir = new File(logdirChooser.getCurrentDirectory(), logdirName);
- logdirChooser.setCurrentDirectory(logdir);
+ /* logdir preference name */
+ final static String logdirPreference = "LOGDIR";
+
+ /* Default logdir is ~/TeleMetrum */
+ final static String logdirName = "TeleMetrum";
+
+ /* Initialize logdir from preferences */
+ {
+ String logdir_string = altosui_preferences.get(logdirPreference, null);
+ if (logdir_string != null)
+ logdir = new File(logdir_string);
+ else
+ /* a hack -- make the file chooser tell us what the default directory
+ * would be and stick our logdir in a subdirectory of that.
+ */
+ logdir = new File(new JFileChooser().getCurrentDirectory(), logdirName);
+ }
+
+ private void set_logdir(File new_logdir) {
+ logdir = new_logdir;
+ System.out.printf("Set logdir to %s\n", logdir.toString());
+ synchronized (altosui_preferences) {
+ altosui_preferences.put(logdirPreference, logdir.getPath());
+ try {
+ altosui_preferences.flush();
+ } catch (BackingStoreException ee) {
+ JOptionPane.showMessageDialog(AltosUI.this,
+ altosui_preferences.absolutePath(),
+ "Cannot save prefernces",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }