X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=micropeak%2FMicroSave.java;h=d6e354f261a881e5903a4b227392ce96af98ad69;hp=cb4b4221d3b0b0d2e14ff7b121cfc7969e8863b8;hb=HEAD;hpb=d83587c3c66b730cc54ca153714eee520ee40b2c diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index cb4b4221..f6e2ed2a 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,14 +25,20 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.AltosLib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_14.*; +import org.altusmetrum.altosuilib_14.*; public class MicroSave extends JFileChooser { JFrame frame; MicroData data; + public static void save(File file, MicroData data) throws FileNotFoundException, IOException { + FileOutputStream fos = new FileOutputStream(file); + data.save(fos); + fos.close(); + } + public boolean runDialog() { int ret; @@ -65,7 +72,7 @@ public class MicroSave extends JFileChooser { JOptionPane.YES_NO_OPTION); if (r != JOptionPane.YES_OPTION) continue; - + if (!file.canWrite()) { JOptionPane.showMessageDialog(frame, String.format("\"%s\" is not writable", @@ -76,9 +83,8 @@ public class MicroSave extends JFileChooser { } } try { - FileOutputStream fos = new FileOutputStream(file); - data.save(fos); - fos.close(); + save(file, data); + AltosUIPreferences.set_last_logdir(file.getParentFile()); data.set_name(filename); return true; } catch (FileNotFoundException fe) { @@ -97,6 +103,7 @@ public class MicroSave extends JFileChooser { setDialogTitle("Save MicroPeak Data File"); setFileFilter(new FileNameExtensionFilter("MicroPeak data file", "mpd")); - setCurrentDirectory(AltosUIPreferences.logdir()); + setCurrentDirectory(AltosUIPreferences.last_logdir()); + setSelectedFile(MicroFile.make(data)); } }