Skip to content

Commit

Permalink
fix default directory and file not being set [fixes #401]
Browse files Browse the repository at this point in the history
  • Loading branch information
kunstmusik committed Sep 30, 2018
1 parent 9f54969 commit 8752832
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ FIX
* Fix resizing of timeline on movement or resizing of Score Objects, whether by
mouse or by ScoreObject Properties window

* Issue #401: Fix setting of default/last directory/file path for open/save
file dialogs


> Notes for 2.7.3 <
[release 2017.12.15]
Expand Down
28 changes: 22 additions & 6 deletions blue-ui-utilities/src/blue/ui/utilities/FileChooserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,42 @@ public List<File> showOpenDialog(Object fileChooserId, Component parent) {
if (temp.directoriesOnly) {
DirectoryChooser chooser = new DirectoryChooser();
chooser.setTitle(temp.dialogTitle);

if(temp.currentDirectory != null) {
chooser.setInitialDirectory(temp.currentDirectory);
}

File f = chooser.showDialog(s);
if (f != null) {
retVal.add(f);
temp.currentDirectory = f;
}
} else {
FileChooser f = new FileChooser();
f.setTitle(temp.dialogTitle);
f.getExtensionFilters().addAll(temp.filters);
f.getExtensionFilters().add(allFilter);
if (temp.selectedFile != null) {
f.setInitialFileName(temp.selectedFile.getName());
}

if (temp.currentDirectory != null) {
f.setInitialDirectory(temp.currentDirectory);
} else if(temp.selectedFile != null){
f.setInitialDirectory(temp.selectedFile.getParentFile());
}
if (temp.selectedFile != null) {
f.setInitialFileName(temp.selectedFile.getName());
}

if (temp.isMultiSelect) {
temp.selectedFile = null;
List<File> found = f.showOpenMultipleDialog(s);
if (found != null) {
temp.currentDirectory = found.get(0).getParentFile();
retVal.addAll(found);
}
} else {
File ret = f.showOpenDialog(s);
if (ret != null) {
temp.currentDirectory = ret.getParentFile();
retVal.add(ret);
}
}
Expand Down Expand Up @@ -180,15 +191,19 @@ public File showSaveDialog(Object fileChooserId, Component parent) {
f.setTitle(temp.dialogTitle);
f.getExtensionFilters().addAll(temp.filters);

if (temp.selectedFile != null) {
f.setInitialFileName(temp.selectedFile.getName());
}
if (temp.currentDirectory != null) {
f.setInitialDirectory(temp.currentDirectory);
} else if(temp.selectedFile != null) {
f.setInitialDirectory(temp.selectedFile.getParentFile());
}
if (temp.selectedFile != null) {
f.setInitialFileName(temp.selectedFile.getName());
}

File ret = f.showSaveDialog(s);
if (ret != null) {
temp.currentDirectory = null;
temp.selectedFile = ret;
retVal.set(ret);
}

Expand All @@ -214,6 +229,7 @@ private DialogInfoSet getDialogInfoSet(Object fileChooserId) {
DialogInfoSet temp = new DialogInfoSet();

temp.selectedFile = new File(System.getProperty("user.home"));
temp.currentDirectory = new File(System.getProperty("user.home"));

dialogInfoSets.put(fileChooserId, temp);

Expand Down

0 comments on commit 8752832

Please sign in to comment.