Skip to content

Commit

Permalink
Fix the 'Attach file' dialog for starting on the user's main directory (
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemdot authored and Siedlerchr committed May 26, 2019
1 parent 8e43be3 commit 0f8795b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where a database exception related to a missing timezone was too big. [#4827](https://github.com/JabRef/jabref/issues/4827)
- We fixed an issue where the command line help text had several errors, and arguments and descriptions have been rewritten to simplify and detail them better. [#4932](https://github.com/JabRef/jabref/issues/2016)
- We fixed an issue where the same menu for changing entry type had two different sizes and weights. [#4977](https://github.com/JabRef/jabref/issues/4977)
- We fixed an issue where the "Attach file" dialog, in the right-click menu for an entry, started on the working directory instead of the user's main directory. [#4995](https://github.com/JabRef/jabref/issues/4995)


### Removed
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/org/jabref/gui/filelist/AttachFileAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.filelist;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

import org.jabref.Globals;
Expand Down Expand Up @@ -32,14 +34,21 @@ public void execute() {
dialogService.notify(Localization.lang("This operation requires exactly one item to be selected."));
return;
}

BibEntry entry = panel.getSelectedEntries().get(0);

Path workingDirectory = panel.getBibDatabaseContext()
.getFirstExistingFileDir(Globals.prefs.getFilePreferences())
.orElse(Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)));

FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY))
.build();
.withInitialDirectory(workingDirectory)
.build();

dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(newFile -> {

LinkedFile linkedFile = LinkedFilesEditorViewModel.fromFile(newFile, panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFilePreferences()), ExternalFileTypes.getInstance());
LinkedFile linkedFile = LinkedFilesEditorViewModel.fromFile(newFile,
panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFilePreferences()),
ExternalFileTypes.getInstance());

LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(linkedFile);

Expand Down

0 comments on commit 0f8795b

Please sign in to comment.