JFileChooser hexfile_chooser = new JFileChooser();
+ File firmwaredir = AltosPreferences.firmwaredir();
+ if (firmwaredir != null)
+ hexfile_chooser.setCurrentDirectory(firmwaredir);
+
hexfile_chooser.setDialogTitle("Select Flash Image");
hexfile_chooser.setFileFilter(new FileNameExtensionFilter("Flash Image", "ihx"));
int returnVal = hexfile_chooser.showOpenDialog(frame);
file = hexfile_chooser.getSelectedFile();
+ if (file != null)
+ AltosPreferences.set_firmwaredir(file.getParentFile());
+
thread = new Thread(this);
thread.start();
}
/* callsign preference name */
final static String callsignPreference = "CALLSIGN";
+ /* firmware directory preference name */
+ final static String firmwaredirPreference = "FIRMWARE";
+
/* Default logdir is ~/TeleMetrum */
final static String logdirName = "TeleMetrum";
/* Voice preference */
static boolean voice;
+ /* Callsign preference */
static String callsign;
+ /* Firmware directory */
+ static File firmwaredir;
+
public static void init(Component ui) {
preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
voice = preferences.getBoolean(voicePreference, true);
callsign = preferences.get(callsignPreference,"N0CALL");
+
+ String firmwaredir_string = preferences.get(firmwaredirPreference, null);
+ if (firmwaredir_string != null)
+ firmwaredir = new File(firmwaredir_string);
+ else
+ firmwaredir = null;
}
static void flush_preferences() {
public static String callsign() {
return callsign;
}
+
+ public static void set_firmwaredir(File new_firmwaredir) {
+ firmwaredir = new_firmwaredir;
+ synchronized (preferences) {
+ preferences.put(firmwaredirPreference, firmwaredir.getPath());
+ flush_preferences();
+ }
+ }
+
+ public static File firmwaredir() {
+ return firmwaredir;
+ }
}