use AWT's FileDialog so we get real native OS file dialogs

i need to test this more on Windows/Linux to ensure it works fine there
too, but i think it should be fine.

getting native OS file dialogs is _probably_ most important on OS X
as the Swing JFileChooser version lacks the favourites column which
a lot of users will end up feeling somewhat lost without.
This commit is contained in:
Gered 2015-12-01 13:58:57 -05:00
parent 0559de6b88
commit 23a413a98a

View file

@ -39,7 +39,7 @@ final class Actions {
private Llanfair master; private Llanfair master;
private File file; private File file;
private JFileChooser fileChooser; private FileDialog fileChooser;
private volatile long lastUnsplit; private volatile long lastUnsplit;
private volatile long lastSkip; private volatile long lastSkip;
@ -55,7 +55,8 @@ final class Actions {
master = owner; master = owner;
file = null; file = null;
fileChooser = new JFileChooser( UserSettings.getSplitsPath() ); fileChooser = new FileDialog(master);
fileChooser.setDirectory(UserSettings.getSplitsPath());
lastUnsplit = 0L; lastUnsplit = 0L;
lastSkip = 0L; lastSkip = 0L;
@ -227,17 +228,17 @@ final class Actions {
* @return a file selected by the user or {@code null} if he canceled * @return a file selected by the user or {@code null} if he canceled
*/ */
private File selectFile(FILE_CHOOSER_TYPE dialogType) { private File selectFile(FILE_CHOOSER_TYPE dialogType) {
int option = -1;
if (dialogType == FILE_CHOOSER_TYPE.OPEN) if (dialogType == FILE_CHOOSER_TYPE.OPEN)
option = fileChooser.showOpenDialog(master); fileChooser.setMode(FileDialog.LOAD);
else if (dialogType == FILE_CHOOSER_TYPE.SAVE) else if (dialogType == FILE_CHOOSER_TYPE.SAVE)
option = fileChooser.showSaveDialog(master); fileChooser.setMode(FileDialog.SAVE);
if ( option == JFileChooser.APPROVE_OPTION ) { fileChooser.setVisible(true);
return fileChooser.getSelectedFile(); String selectedFile = fileChooser.getFile();
} else { if (selectedFile != null)
return new File(fileChooser.getDirectory() + File.separator + selectedFile);
else
return null; return null;
}
} }
/** /**