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 pdf file import when only one file selected and no entry created #2592

Merged
merged 2 commits into from
Feb 28, 2017
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- ArXiV fetcher now checks similarity of entry when using DOI retrieval to avoid false positives [#2575](https://github.com/JabRef/jabref/issues/2575)
- Sciencedirect/Elsevier fetcher is now able to scrape new HTML structure [#2576](https://github.com/JabRef/jabref/issues/2576)
- Fixed the synchronization logic of keywords and special fields and vice versa [#2580](https://github.com/JabRef/jabref/issues/2580)

- We fixed an issue where the "find unlinked files" functionality threw an error when only one PDF was imported but not assigned to an entry [#2577](https://github.com/JabRef/jabref/issues/2577)

### Removed

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/org/jabref/pdfimport/PdfImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,25 @@ public PdfImporter(JabRefFrame frame, BasePanel panel, MainTable entryTable, int
this.dropRow = dropRow;
}


public class ImportPdfFilesResult {

private final List<String> noPdfFiles;
private final List<BibEntry> entries;


public ImportPdfFilesResult(List<String> noPdfFiles, List<BibEntry> entries) {
this.noPdfFiles = noPdfFiles;
this.entries = entries;
}


public List<String> getNoPdfFiles() {
return noPdfFiles;
}


public List<BibEntry> getEntries() {
return entries;
}
}


/**
*
* Imports the PDF files given by fileNames
Expand Down Expand Up @@ -128,7 +123,6 @@ private List<BibEntry> importPdfFilesInternal(List<String> fileNames) {
boolean neverShow = Globals.prefs.getBoolean(JabRefPreferences.IMPORT_ALWAYSUSE);
int globalChoice = Globals.prefs.getInt(JabRefPreferences.IMPORT_DEFAULT_PDF_IMPORT_STYLE);


List<BibEntry> res = new ArrayList<>();

for (String fileName : fileNames) {
Expand Down Expand Up @@ -156,7 +150,11 @@ private List<BibEntry> importPdfFilesInternal(List<String> fileNames) {
break;
case ImportDialog.ONLYATTACH:
DroppedFileHandler dfh = new DroppedFileHandler(frame, panel);
dfh.linkPdfToEntry(fileName, entryTable, dropRow);
if (dropRow >= 0) {
dfh.linkPdfToEntry(fileName, entryTable, dropRow);
} else {
dfh.linkPdfToEntry(fileName, entryTable, entryTable.getSelectedRow());
}
break;
default:
break;
Expand Down Expand Up @@ -236,7 +234,8 @@ private void doContentImport(String fileName, List<BibEntry> res) {
panel.getDatabase().insertEntry(entry);
panel.markBaseChanged();
BibtexKeyPatternUtil.makeAndSetLabel(panel.getBibDatabaseContext().getMetaData()
.getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern()), panel.getDatabase(), entry,
.getCiteKeyPattern(Globals.prefs.getBibtexKeyPatternPreferences().getKeyPattern()), panel.getDatabase(),
entry,
Globals.prefs.getBibtexKeyPatternPreferences());
DroppedFileHandler dfh = new DroppedFileHandler(frame, panel);
dfh.linkPdfToEntry(fileName, entry);
Expand Down