Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
Siedlerchr committed May 4, 2020
2 parents 4e48079 + 7cb7ea6 commit ded2a2a
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 16 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added support for basic markdown in custom formatted previews [#6194](https://github.com/JabRef/jabref/issues/6194)
- 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)
- We created a new install screen for macOS. [#5759](https://github.com/JabRef/jabref/issues/5759)
- We implemented an option to download fulltext files while importing. [#6381](https://github.com/JabRef/jabref/pull/6381)

### Changed

Expand All @@ -26,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- 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)
- 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
- 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).
- 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)
- We improved the error message for invalid jstyles. [#6303](https://github.com/JabRef/jabref/issues/6303)

### Fixed
Expand Down Expand Up @@ -102,7 +104,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where adding the addition of a new entry was not completely validated [#6370](https://github.com/JabRef/jabref/issues/6370)
- 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)
- 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)

- We fixed an issue where few keyboard shortcuts regarding new entries were missing [#6403](https://github.com/JabRef/jabref/issues/6403)
### Removed

- 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)
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id 'com.github.ben-manes.versions' version '0.28.0'
id 'org.javamodularity.moduleplugin' version '1.5.0'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'org.beryx.jlink' version '2.17.8'
id 'org.beryx.jlink' version '2.18.0'

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

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

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

implementation 'com.vladsch.flexmark:flexmark:0.61.20'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.61.20'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.61.20'
implementation 'com.vladsch.flexmark:flexmark:0.61.24'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.61.24'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.61.24'

testImplementation 'io.github.classgraph:classgraph:4.8.77'
testImplementation 'io.github.classgraph:classgraph:4.8.78'
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.6.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.6.2'

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

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

Expand Down
2 changes: 1 addition & 1 deletion buildres/linux/JabRef.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Type=Application
DESKTOP_MIMES
Categories=DEPLOY_BUNDLE_CATEGORY
Keywords=bibtex;biblatex;latex;bibliography
StartupWMClass=org-jabref-JabRefMain
StartupWMClass=org.jabref.JabRefMain
24 changes: 24 additions & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,30 @@ private void initKeyBindings() {
case SEARCH:
getGlobalSearchBar().focus();
break;
case NEW_ARTICLE:
new NewEntryAction(this, StandardEntryType.Article, dialogService, prefs, stateManager).execute();
break;
case NEW_BOOK:
new NewEntryAction(this, StandardEntryType.Book, dialogService, prefs, stateManager).execute();
break;
case NEW_INBOOK:
new NewEntryAction(this, StandardEntryType.InBook, dialogService, prefs, stateManager).execute();
break;
case NEW_MASTERSTHESIS:
new NewEntryAction(this, StandardEntryType.MastersThesis, dialogService, prefs, stateManager).execute();
break;
case NEW_PHDTHESIS:
new NewEntryAction(this, StandardEntryType.PhdThesis, dialogService, prefs, stateManager).execute();
break;
case NEW_PROCEEDINGS:
new NewEntryAction(this, StandardEntryType.Proceedings, dialogService, prefs, stateManager).execute();
break;
case NEW_TECHREPORT:
new NewEntryAction(this, StandardEntryType.TechReport, dialogService, prefs, stateManager).execute();
break;
case NEW_UNPUBLISHED:
new NewEntryAction(this, StandardEntryType.Unpublished, dialogService, prefs, stateManager).execute();
break;
default:
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.URLDownload;
import org.jabref.logic.util.io.FileNameUniqueness;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.logic.xmp.XmpUtilWriter;
import org.jabref.model.database.BibDatabaseContext;
Expand Down Expand Up @@ -415,6 +416,7 @@ public void download() {
LinkedFile newLinkedFile = LinkedFilesEditorViewModel.fromFile(destination, databaseContext.getFileDirectoriesAsPaths(filePreferences), externalFileTypes);
linkedFile.setLink(newLinkedFile.getLink());
linkedFile.setFileType(newLinkedFile.getFileType());
entry.addFile(0, newLinkedFile);
});
downloadProgress.bind(downloadTask.workDonePercentageProperty());
taskExecutor.execute(downloadTask);
Expand All @@ -431,8 +433,9 @@ public BackgroundTask<Path> prepareDownloadTask(Path targetDirectory, URLDownloa
String suggestedTypeName = externalFileType.getName();
linkedFile.setFileType(suggestedTypeName);
String suggestedName = linkedFileHandler.getSuggestedFileName(externalFileType.getExtension());
suggestedName = FileNameUniqueness.getNonOverWritingFileName(targetDirectory, suggestedName);
return targetDirectory.resolve(suggestedName);
String fulltextDir = FileUtil.createDirNameFromPattern(databaseContext.getDatabase(), entry, filePreferences.getFileDirPattern());
suggestedName = FileNameUniqueness.getNonOverWritingFileName(targetDirectory.resolve(fulltextDir), suggestedName);
return targetDirectory.resolve(fulltextDir).resolve(suggestedName);
})
.then(destination -> new FileDownloadTask(urlDownload.getSource(), destination))
.onFailure(exception -> dialogService.showErrorDialogAndWait("Download failed", exception));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
Expand Down Expand Up @@ -38,6 +39,7 @@
<Label fx:id="selectedItems" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
</GridPane>
</HBox>
<CheckBox fx:id="downloadLinkedOnlineFiles" text="%Download linked online files"/>
</VBox>
</content>
<ButtonType fx:id="importButton" buttonData="OK_DONE" text="%Import entries"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.Tooltip;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class ImportEntriesDialog extends BaseDialog<Boolean> {
public ButtonType importButton;
public Label totalItems;
public Label selectedItems;
public CheckBox downloadLinkedOnlineFiles;
private final BackgroundTask<ParserResult> task;
private ImportEntriesViewModel viewModel;
@Inject private TaskExecutor taskExecutor;
Expand Down Expand Up @@ -77,9 +79,11 @@ public ImportEntriesDialog(BibDatabaseContext database, BackgroundTask<ParserRes
Button btn = (Button) this.getDialogPane().lookupButton(importButton);
btn.disableProperty().bind(booleanBind);

downloadLinkedOnlineFiles.setSelected(preferences.getFilePreferences().getDownloadLinkedFiles());

setResultConverter(button -> {
if (button == importButton) {
viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems());
viewModel.importEntries(entriesListView.getCheckModel().getCheckedItems(), downloadLinkedOnlineFiles.isSelected());
} else {
dialogService.notify(Localization.lang("Import canceled"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
import org.jabref.gui.externalfiles.ImportHandler;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
import org.jabref.gui.groups.GroupTreeNodeViewModel;
import org.jabref.gui.groups.UndoableAddOrRemoveGroup;
import org.jabref.gui.undo.NamedCompound;
Expand All @@ -31,6 +32,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibtexString;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.groups.GroupTreeNode;
import org.jabref.model.metadata.MetaData;
import org.jabref.model.util.FileUpdateMonitor;
Expand All @@ -44,6 +46,7 @@ public class ImportEntriesViewModel extends AbstractViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(ImportEntriesViewModel.class);

private final StringProperty message;
private final TaskExecutor taskExecutor;
private final BibDatabaseContext databaseContext;
private final DialogService dialogService;
private final UndoManager undoManager;
Expand All @@ -58,6 +61,7 @@ public class ImportEntriesViewModel extends AbstractViewModel {
* @param task the task executed for parsing the selected files(s).
*/
public ImportEntriesViewModel(BackgroundTask<ParserResult> task, TaskExecutor taskExecutor, BibDatabaseContext databaseContext, DialogService dialogService, UndoManager undoManager, PreferencesService preferences, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor) {
this.taskExecutor = taskExecutor;
this.databaseContext = databaseContext;
this.dialogService = dialogService;
this.undoManager = undoManager;
Expand Down Expand Up @@ -99,7 +103,7 @@ public boolean hasDuplicate(BibEntry entry) {
*
* @param entriesToImport subset of the entries contained in parserResult
*/
public void importEntries(List<BibEntry> entriesToImport) {
public void importEntries(List<BibEntry> entriesToImport, boolean downloadFiles) {
// Check if we are supposed to warn about duplicates.
// If so, then see if there are duplicates, and warn if yes.
if (preferences.shouldWarnAboutDuplicatesForImport()) {
Expand All @@ -126,6 +130,15 @@ public void importEntries(List<BibEntry> entriesToImport) {
buildImportHandlerThenImportEntries(entriesToImport);
}

if (downloadFiles) {
for (BibEntry bibEntry : entriesToImport) {
for (LinkedFile linkedFile : bibEntry.getFiles()) {
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(linkedFile, bibEntry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), ExternalFileTypes.getInstance());
linkedFileViewModel.download();
}
}
}

NamedCompound namedCompound = new NamedCompound(Localization.lang("Import file"));
namedCompound.addEdit(new UndoableInsertEntries(databaseContext.getDatabase(), entriesToImport));

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/preferences/ImportTab.fxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
Expand Down Expand Up @@ -30,5 +31,6 @@
<Label text="%File directory pattern" GridPane.rowIndex="1"/>
<TextField fx:id="fileDirPattern" GridPane.columnIndex="1" GridPane.rowIndex="1"
prefWidth="300" minWidth="300" maxWidth="300"/>
<CheckBox fx:id="downloadLinkedFiles" text="%Download linked online files" GridPane.rowIndex="2"/>
</GridPane>
</fx:root>
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/preferences/ImportTabView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.preferences;

import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;

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

@FXML private ComboBox<String> fileNamePattern;
@FXML private TextField fileDirPattern;
@FXML private CheckBox downloadLinkedFiles;

public ImportTabView(JabRefPreferences preferences) {
this.preferences = preferences;
Expand All @@ -28,6 +30,7 @@ public void initialize() {
fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
fileDirPattern.textProperty().bindBidirectional(viewModel.fileDirPatternProperty());
downloadLinkedFiles.selectedProperty().bindBidirectional(viewModel.downloadLinkedFilesProperty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.ArrayList;
import java.util.List;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
Expand All @@ -19,6 +21,7 @@ public class ImportTabViewModel implements PreferenceTabViewModel {
private final ListProperty<String> defaultFileNamePatternsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(DEFAULT_FILENAME_PATTERNS));
private final StringProperty fileNamePatternProperty = new SimpleStringProperty();
private final StringProperty fileDirPatternProperty = new SimpleStringProperty();
private final BooleanProperty downloadLinkedFilesProperty = new SimpleBooleanProperty();

private final DialogService dialogService;
private final JabRefPreferences preferences;
Expand All @@ -32,12 +35,14 @@ public ImportTabViewModel(DialogService dialogService, JabRefPreferences prefere
public void setValues() {
fileNamePatternProperty.setValue(preferences.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));
fileDirPatternProperty.setValue(preferences.get(JabRefPreferences.IMPORT_FILEDIRPATTERN));
downloadLinkedFilesProperty.setValue(preferences.getBoolean(JabRefPreferences.DOWNLOAD_LINKED_FILES));
}

@Override
public void storeSettings() {
preferences.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, fileNamePatternProperty.getValue());
preferences.put(JabRefPreferences.IMPORT_FILEDIRPATTERN, fileDirPatternProperty.getValue());
preferences.putBoolean(JabRefPreferences.DOWNLOAD_LINKED_FILES, downloadLinkedFilesProperty.getValue());
}

@Override
Expand All @@ -55,4 +60,6 @@ public List<String> getRestartWarnings() {
public StringProperty fileNamePatternProperty() { return fileNamePatternProperty; }

public StringProperty fileDirPatternProperty() { return fileDirPatternProperty; }

public BooleanProperty downloadLinkedFilesProperty() { return downloadLinkedFilesProperty; }
}
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,12 @@ public Optional<FieldChange> addFile(LinkedFile file) {
return setFiles(linkedFiles);
}

public Optional<FieldChange> addFile(int index, LinkedFile file) {
List<LinkedFile> linkedFiles = getFiles();
linkedFiles.add(index, file);
return setFiles(linkedFiles);
}

public ObservableMap<Field, String> getFieldsObservable() {
return fields;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/model/metadata/FilePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ public class FilePreferences {
private final boolean bibLocationAsPrimary;
private final String fileNamePattern;
private final String fileDirPattern;
private final boolean downloadLinkedFiles;

public FilePreferences(String user,
String mainFileDirectory,
boolean bibLocationAsPrimary,
String fileNamePattern,
String fileDirPattern) {
String fileDirPattern,
boolean downloadLinkedFiles) {
this.user = user;
this.mainFileDirectory = mainFileDirectory;
this.bibLocationAsPrimary = bibLocationAsPrimary;
this.fileNamePattern = fileNamePattern;
this.fileDirPattern = fileDirPattern;
this.downloadLinkedFiles = downloadLinkedFiles;
}

public String getUser() {
Expand All @@ -48,4 +51,6 @@ public String getFileNamePattern() {
public String getFileDirPattern() {
return fileDirPattern;
}

public boolean getDownloadLinkedFiles() { return downloadLinkedFiles; }
}
Loading

0 comments on commit ded2a2a

Please sign in to comment.