Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Copy linked files dialog showing NPE when no linked files #3821

Merged
merged 3 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The new default removes the linked file from the entry instead of deleting the f
- We fixed an issue where not all bibtex/biblatex fields would be exported as latex-free to MS-Office XML [koppor#284](https://github.com/koppor/jabref/issues/284)
- We fixed an issue where linked files would be deleted from bibliography entries despite choosing the "Cancel" option in the dialog menu.
- We fixed the name of the group editing window to "Add group" instead of "Edit Group" when adding a new group. [koppor#277](https://github.com/koppor/jabref/issues/277)
- We fixed an issue where the "Copy linked files" dialog produced an error when the entry had no file [#3818](https://github.com/JabRef/jabref/issues/3818)

### Removed
- We removed the [Look and Feels from JGoodies](http://www.jgoodies.com/freeware/libraries/looks/), because the open source version is not compatible with Java 9.
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ public void actionPerformed(ActionEvent e) {

private void startServiceAndshowProgessDialog(Task<List<CopyFilesResultItemViewModel>> exportService) {

DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showCanceableProgressDialogAndWait(exportService));
DefaultTaskExecutor.runInJavaFXThread(() -> {
dialogService.showCanceableProgressDialogAndWait(exportService);
});

exportService.run(); //Run kinda blocks, so we just show the result dialog wgeb run is ready
DefaultTaskExecutor.runInJavaFXThread(() -> showDialog(exportService.getValue()));
exportService.run();
DefaultTaskExecutor.runInJavaFXThread(() -> {
showDialog(exportService.getValue());
});
}

private void showDialog(List<CopyFilesResultItemViewModel> data) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CopyFilesTask extends Task<List<CopyFilesResultItemViewModel>> {
private final long totalFilesCount;
private final List<BibEntry> entries;
private final List<CopyFilesResultItemViewModel> results = new ArrayList<>();
private Optional<Path> newPath;
private Optional<Path> newPath = Optional.empty();
private int numberSucessful;
private int totalFilesCounter;

Expand All @@ -54,8 +54,7 @@ public CopyFilesTask(BibDatabaseContext databaseContext, List<BibEntry> entries,
}

@Override
protected List<CopyFilesResultItemViewModel> call()
throws InterruptedException, IOException {
protected List<CopyFilesResultItemViewModel> call() throws InterruptedException, IOException {

updateMessage(Localization.lang("Copying files..."));
updateProgress(0, totalFilesCount);
Expand Down Expand Up @@ -103,6 +102,7 @@ protected List<CopyFilesResultItemViewModel> call()
}
}
updateMessage(Localization.lang("Finished copying"));

String sucessMessage = Localization.lang("Copied %0 files of %1 sucessfully to %2", Integer.toString(numberSucessful), Integer.toString(totalFilesCounter), newPath.map(Path::getParent).map(Path::toString).orElse(""));
updateMessage(sucessMessage);
bw.write(sucessMessage);
Expand Down