export remembers last path used

This commit is contained in:
hneemann 2016-08-25 18:14:11 +02:00
parent 99c1f4e386
commit e9b0276465

View File

@ -65,6 +65,8 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
private static final ArrayList<Key> ATTR_LIST = new ArrayList<>(); private static final ArrayList<Key> ATTR_LIST = new ArrayList<>();
private static boolean experimental; private static boolean experimental;
private static File LAST_EXPORT_DIRECTORY;
/** /**
* @return true if experimental features are enabled * @return true if experimental features are enabled
*/ */
@ -918,10 +920,17 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
if (filename != null) if (filename != null)
fc.setSelectedFile(checkSuffix(filename, suffix)); fc.setSelectedFile(checkSuffix(filename, suffix));
if (LAST_EXPORT_DIRECTORY != null)
fc.setCurrentDirectory(LAST_EXPORT_DIRECTORY);
fc.addChoosableFileFilter(new FileNameExtensionFilter(name, suffix)); fc.addChoosableFileFilter(new FileNameExtensionFilter(name, suffix));
if (fc.showSaveDialog(Main.this) == JFileChooser.APPROVE_OPTION) { if (fc.showSaveDialog(Main.this) == JFileChooser.APPROVE_OPTION) {
LAST_EXPORT_DIRECTORY=fc.getSelectedFile().getParentFile();
try (OutputStream out = new FileOutputStream(checkSuffix(fc.getSelectedFile(), suffix))) { try (OutputStream out = new FileOutputStream(checkSuffix(fc.getSelectedFile(), suffix))) {
new Export(circuitComponent.getCircuit(), exportFactory).export(out); new Export(circuitComponent.getCircuit(), exportFactory).export(out);
} catch (IOException e1) { } catch (IOException e1) {
new ErrorMessage(Lang.get("msg_errorWritingFile")).addCause(e1).show(Main.this); new ErrorMessage(Lang.get("msg_errorWritingFile")).addCause(e1).show(Main.this);
} }