Skip to content

Commit ded2a2a

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Added a download checkbox to the import dialog (#6381) Bump jaxb-xjc from 2.3.2 to 2.3.3 (#6410) Bump flexmark-ext-gfm-strikethrough from 0.61.20 to 0.61.24 (#6413) Bump byte-buddy-parent from 1.10.9 to 1.10.10 (#6408) Bump flexmark-ext-gfm-tasklist from 0.61.20 to 0.61.24 (#6412) Bump org.beryx.jlink from 2.17.8 to 2.18.0 (#6411) Bump tika-core from 1.24 to 1.24.1 (#6409) Bump flexmark from 0.61.20 to 0.61.24 (#6416) Bump classgraph from 4.8.77 to 4.8.78 (#6414) Restore some missing keyboard shortcuts (#6406) Fix StartupWMClass (#6398)
2 parents 4e48079 + 7cb7ea6 commit ded2a2a

File tree

15 files changed

+92
-16
lines changed

15 files changed

+92
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
1717
- We added support for basic markdown in custom formatted previews [#6194](https://github.com/JabRef/jabref/issues/6194)
1818
- We now show the number of items found and selected to import in the online search dialog. [#6248](https://github.com/JabRef/jabref/pull/6248)
1919
- We created a new install screen for macOS. [#5759](https://github.com/JabRef/jabref/issues/5759)
20+
- We implemented an option to download fulltext files while importing. [#6381](https://github.com/JabRef/jabref/pull/6381)
2021

2122
### Changed
2223

@@ -26,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2627
- We changed the buttons for import/export/show all/reset of preferences to smaller icon buttons in the preferences dialog. [#6130](https://github.com/JabRef/jabref/pull/6130)
2728
- We moved the functionality "Manage field names & content" from the "Library" menu to the "Edit" menu, because it affects the selected entries and not the whole library
2829
- We merged the functionality "Append contents from a BibTeX library into the currently viewed library" into the "Import into database" functionality. Fixes [#6049](https://github.com/JabRef/jabref/issues/6049).
30+
- We changed the directory where fulltext downloads are stored to the directory set in the import-tab in preferences. [#6381](https://github.com/JabRef/jabref/pull/6381)
2931
- We improved the error message for invalid jstyles. [#6303](https://github.com/JabRef/jabref/issues/6303)
3032

3133
### Fixed
@@ -102,7 +104,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
102104
- We fixed an issue where adding the addition of a new entry was not completely validated [#6370](https://github.com/JabRef/jabref/issues/6370)
103105
- We fixed an issue where the blue and red text colors in the Merge entries dialog were not quite visible [#6334](https://github.com/JabRef/jabref/issues/6334)
104106
- We fixed an issue where underscore character was removed from the file name in the Recent Libraries list in File menu [#6383](https://github.com/JabRef/jabref/issues/6383)
105-
107+
- We fixed an issue where few keyboard shortcuts regarding new entries were missing [#6403](https://github.com/JabRef/jabref/issues/6403)
106108
### Removed
107109

108110
- Ampersands are no longer escaped by default in the `bib` file. If you want to keep the current behaviour, you can use the new "Escape Ampersands" formatter as a save action. [#5869](https://github.com/JabRef/jabref/issues/5869)

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
id 'com.github.ben-manes.versions' version '0.28.0'
1717
id 'org.javamodularity.moduleplugin' version '1.5.0'
1818
id 'org.openjfx.javafxplugin' version '0.0.8'
19-
id 'org.beryx.jlink' version '2.17.8'
19+
id 'org.beryx.jlink' version '2.18.0'
2020

2121
// nicer test outputs during running and completion
2222
id 'com.adarshr.test-logger' version '2.0.0'
@@ -112,7 +112,7 @@ dependencies {
112112
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.8'
113113
implementation 'com.h2database:h2-mvstore:1.4.200'
114114

115-
implementation group: 'org.apache.tika', name: 'tika-core', version: '1.24'
115+
implementation group: 'org.apache.tika', name: 'tika-core', version: '1.24.1'
116116

117117
// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
118118
implementation 'org.bouncycastle:bcprov-jdk15on:1.65'
@@ -191,16 +191,16 @@ dependencies {
191191
exclude module: "log4j-core"
192192
}
193193

194-
implementation 'com.vladsch.flexmark:flexmark:0.61.20'
195-
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.61.20'
196-
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.61.20'
194+
implementation 'com.vladsch.flexmark:flexmark:0.61.24'
195+
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.61.24'
196+
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.61.24'
197197

198-
testImplementation 'io.github.classgraph:classgraph:4.8.77'
198+
testImplementation 'io.github.classgraph:classgraph:4.8.78'
199199
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
200200
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.6.2'
201201
testImplementation 'org.junit.platform:junit-platform-launcher:1.6.2'
202202

203-
testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.9'
203+
testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.10'
204204
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT'
205205
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT'
206206
testImplementation 'org.mockito:mockito-core:3.3.3'
@@ -212,7 +212,7 @@ dependencies {
212212
testImplementation "org.hamcrest:hamcrest-library:2.2"
213213

214214
checkstyle 'com.puppycrawl.tools:checkstyle:8.32'
215-
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.2'
215+
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.3'
216216
jython 'org.python:jython-standalone:2.7.2'
217217
}
218218

buildres/linux/JabRef.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Type=Application
99
DESKTOP_MIMES
1010
Categories=DEPLOY_BUNDLE_CATEGORY
1111
Keywords=bibtex;biblatex;latex;bibliography
12-
StartupWMClass=org-jabref-JabRefMain
12+
StartupWMClass=org.jabref.JabRefMain

src/main/java/org/jabref/gui/JabRefFrame.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,30 @@ private void initKeyBindings() {
245245
case SEARCH:
246246
getGlobalSearchBar().focus();
247247
break;
248+
case NEW_ARTICLE:
249+
new NewEntryAction(this, StandardEntryType.Article, dialogService, prefs, stateManager).execute();
250+
break;
251+
case NEW_BOOK:
252+
new NewEntryAction(this, StandardEntryType.Book, dialogService, prefs, stateManager).execute();
253+
break;
254+
case NEW_INBOOK:
255+
new NewEntryAction(this, StandardEntryType.InBook, dialogService, prefs, stateManager).execute();
256+
break;
257+
case NEW_MASTERSTHESIS:
258+
new NewEntryAction(this, StandardEntryType.MastersThesis, dialogService, prefs, stateManager).execute();
259+
break;
260+
case NEW_PHDTHESIS:
261+
new NewEntryAction(this, StandardEntryType.PhdThesis, dialogService, prefs, stateManager).execute();
262+
break;
263+
case NEW_PROCEEDINGS:
264+
new NewEntryAction(this, StandardEntryType.Proceedings, dialogService, prefs, stateManager).execute();
265+
break;
266+
case NEW_TECHREPORT:
267+
new NewEntryAction(this, StandardEntryType.TechReport, dialogService, prefs, stateManager).execute();
268+
break;
269+
case NEW_UNPUBLISHED:
270+
new NewEntryAction(this, StandardEntryType.Unpublished, dialogService, prefs, stateManager).execute();
271+
break;
248272
default:
249273
}
250274
}

src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.jabref.logic.l10n.Localization;
3939
import org.jabref.logic.net.URLDownload;
4040
import org.jabref.logic.util.io.FileNameUniqueness;
41+
import org.jabref.logic.util.io.FileUtil;
4142
import org.jabref.logic.xmp.XmpPreferences;
4243
import org.jabref.logic.xmp.XmpUtilWriter;
4344
import org.jabref.model.database.BibDatabaseContext;
@@ -415,6 +416,7 @@ public void download() {
415416
LinkedFile newLinkedFile = LinkedFilesEditorViewModel.fromFile(destination, databaseContext.getFileDirectoriesAsPaths(filePreferences), externalFileTypes);
416417
linkedFile.setLink(newLinkedFile.getLink());
417418
linkedFile.setFileType(newLinkedFile.getFileType());
419+
entry.addFile(0, newLinkedFile);
418420
});
419421
downloadProgress.bind(downloadTask.workDonePercentageProperty());
420422
taskExecutor.execute(downloadTask);
@@ -431,8 +433,9 @@ public BackgroundTask<Path> prepareDownloadTask(Path targetDirectory, URLDownloa
431433
String suggestedTypeName = externalFileType.getName();
432434
linkedFile.setFileType(suggestedTypeName);
433435
String suggestedName = linkedFileHandler.getSuggestedFileName(externalFileType.getExtension());
434-
suggestedName = FileNameUniqueness.getNonOverWritingFileName(targetDirectory, suggestedName);
435-
return targetDirectory.resolve(suggestedName);
436+
String fulltextDir = FileUtil.createDirNameFromPattern(databaseContext.getDatabase(), entry, filePreferences.getFileDirPattern());
437+
suggestedName = FileNameUniqueness.getNonOverWritingFileName(targetDirectory.resolve(fulltextDir), suggestedName);
438+
return targetDirectory.resolve(fulltextDir).resolve(suggestedName);
436439
})
437440
.then(destination -> new FileDownloadTask(urlDownload.getSource(), destination))
438441
.onFailure(exception -> dialogService.showErrorDialogAndWait("Download failed", exception));

src/main/java/org/jabref/gui/importer/ImportEntriesDialog.fxml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.scene.control.Button?>
4+
<?import javafx.scene.control.CheckBox?>
45
<?import javafx.scene.control.ButtonType?>
56
<?import javafx.scene.control.DialogPane?>
67
<?import javafx.scene.control.Label?>
@@ -38,6 +39,7 @@
3839
<Label fx:id="selectedItems" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
3940
</GridPane>
4041
</HBox>
42+
<CheckBox fx:id="downloadLinkedOnlineFiles" text="%Download linked online files"/>
4143
</VBox>
4244
</content>
4345
<ButtonType fx:id="importButton" buttonData="OK_DONE" text="%Import entries"/>

src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import javafx.scene.Node;
1313
import javafx.scene.control.Button;
1414
import javafx.scene.control.ButtonType;
15+
import javafx.scene.control.CheckBox;
1516
import javafx.scene.control.Label;
1617
import javafx.scene.control.ToggleButton;
1718
import javafx.scene.control.Tooltip;
@@ -50,6 +51,7 @@ public class ImportEntriesDialog extends BaseDialog<Boolean> {
5051
public ButtonType importButton;
5152
public Label totalItems;
5253
public Label selectedItems;
54+
public CheckBox downloadLinkedOnlineFiles;
5355
private final BackgroundTask<ParserResult> task;
5456
private ImportEntriesViewModel viewModel;
5557
@Inject private TaskExecutor taskExecutor;
@@ -77,9 +79,11 @@ public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserRes
7779
Button btn = (Button) this.getDialogPane().lookupButton(importButton);
7880
btn.disableProperty().bind(booleanBind);
7981

82+
downloadLinkedOnlineFiles.setSelected(preferences.getFilePreferences().getDownloadLinkedFiles());
83+
8084
setResultConverter(button -> {
8185
if (button == importButton) {
82-
viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems());
86+
viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems(), downloadLinkedOnlineFiles.isSelected());
8387
} else {
8488
dialogService.notify(Localization.lang("Import canceled"));
8589
}

src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
1919
import org.jabref.gui.externalfiles.ImportHandler;
2020
import org.jabref.gui.externalfiletype.ExternalFileTypes;
21+
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
2122
import org.jabref.gui.groups.GroupTreeNodeViewModel;
2223
import org.jabref.gui.groups.UndoableAddOrRemoveGroup;
2324
import org.jabref.gui.undo.NamedCompound;
@@ -31,6 +32,7 @@
3132
import org.jabref.model.database.BibDatabaseContext;
3233
import org.jabref.model.entry.BibEntry;
3334
import org.jabref.model.entry.BibtexString;
35+
import org.jabref.model.entry.LinkedFile;
3436
import org.jabref.model.groups.GroupTreeNode;
3537
import org.jabref.model.metadata.MetaData;
3638
import org.jabref.model.util.FileUpdateMonitor;
@@ -44,6 +46,7 @@ public class ImportEntriesViewModel extends AbstractViewModel {
4446
private static final Logger LOGGER = LoggerFactory.getLogger(ImportEntriesViewModel.class);
4547

4648
private final StringProperty message;
49+
private final TaskExecutor taskExecutor;
4750
private final BibDatabaseContext databaseContext;
4851
private final DialogService dialogService;
4952
private final UndoManager undoManager;
@@ -58,6 +61,7 @@ public class ImportEntriesViewModel extends AbstractViewModel {
5861
* @param task the task executed for parsing the selected files(s).
5962
*/
6063
public ImportEntriesViewModel(BackgroundTask<ParserResult> task, TaskExecutor taskExecutor, BibDatabaseContext databaseContext, DialogService dialogService, UndoManager undoManager, PreferencesService preferences, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor) {
64+
this.taskExecutor = taskExecutor;
6165
this.databaseContext = databaseContext;
6266
this.dialogService = dialogService;
6367
this.undoManager = undoManager;
@@ -99,7 +103,7 @@ public boolean hasDuplicate(BibEntry entry) {
99103
*
100104
* @param entriesToImport subset of the entries contained in parserResult
101105
*/
102-
public void importEntries(List<BibEntry> entriesToImport) {
106+
public void importEntries(List<BibEntry> entriesToImport, boolean downloadFiles) {
103107
// Check if we are supposed to warn about duplicates.
104108
// If so, then see if there are duplicates, and warn if yes.
105109
if (preferences.shouldWarnAboutDuplicatesForImport()) {
@@ -126,6 +130,15 @@ public void importEntries(List<BibEntry> entriesToImport) {
126130
buildImportHandlerThenImportEntries(entriesToImport);
127131
}
128132

133+
if (downloadFiles) {
134+
for (BibEntry bibEntry : entriesToImport) {
135+
for (LinkedFile linkedFile : bibEntry.getFiles()) {
136+
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(linkedFile, bibEntry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), ExternalFileTypes.getInstance());
137+
linkedFileViewModel.download();
138+
}
139+
}
140+
}
141+
129142
NamedCompound namedCompound = new NamedCompound(Localization.lang("Import file"));
130143
namedCompound.addEdit(new UndoableInsertEntries(databaseContext.getDatabase(), entriesToImport));
131144

src/main/java/org/jabref/gui/preferences/ImportTab.fxml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<?import javafx.scene.control.CheckBox?>
34
<?import javafx.scene.control.ComboBox?>
45
<?import javafx.scene.control.Label?>
56
<?import javafx.scene.control.TextField?>
@@ -30,5 +31,6 @@
3031
<Label text="%File directory pattern" GridPane.rowIndex="1"/>
3132
<TextField fx:id="fileDirPattern" GridPane.columnIndex="1" GridPane.rowIndex="1"
3233
prefWidth="300" minWidth="300" maxWidth="300"/>
34+
<CheckBox fx:id="downloadLinkedFiles" text="%Download linked online files" GridPane.rowIndex="2"/>
3335
</GridPane>
3436
</fx:root>

src/main/java/org/jabref/gui/preferences/ImportTabView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jabref.gui.preferences;
22

33
import javafx.fxml.FXML;
4+
import javafx.scene.control.CheckBox;
45
import javafx.scene.control.ComboBox;
56
import javafx.scene.control.TextField;
67

@@ -13,6 +14,7 @@ public class ImportTabView extends AbstractPreferenceTabView<ImportTabViewModel>
1314

1415
@FXML private ComboBox<String> fileNamePattern;
1516
@FXML private TextField fileDirPattern;
17+
@FXML private CheckBox downloadLinkedFiles;
1618

1719
public ImportTabView(JabRefPreferences preferences) {
1820
this.preferences = preferences;
@@ -28,6 +30,7 @@ public void initialize() {
2830
fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
2931
fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
3032
fileDirPattern.textProperty().bindBidirectional(viewModel.fileDirPatternProperty());
33+
downloadLinkedFiles.selectedProperty().bindBidirectional(viewModel.downloadLinkedFilesProperty());
3134
}
3235

3336
@Override

0 commit comments

Comments
 (0)