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