Skip to content

Commit f22a640

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Add option to parse new references from plain text using GROBID… (#5614) update jlink plugin and gradle to 6.2 (#5964) Remove background command line window (#5965)
2 parents c23b8de + 5fa1dcf commit f22a640

File tree

18 files changed

+376
-46
lines changed

18 files changed

+376
-46
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This is https://github.com/marketplace/actions/gradle-wrapper-validation
2+
# It ensures that the jar file is from gradle and not by a strange third party.
3+
4+
name: "Validate Gradle Wrapper"
5+
on: [push, pull_request]
6+
7+
jobs:
8+
validation:
9+
name: "Validation"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: gradle/wrapper-validation-action@v1
14+

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1313

1414
### Changed
1515

16+
- We reintroduced the possibility to extract references from plain text (using GROBID) [#5614](https://github.com/JabRef/jabref/pull/5614)
1617
- We changed the open office panel to show buttons in rows of three instead of going straight down to save space as the button expanded out to take up unnecessary horizontal space. [#5479](https://github.com/JabRef/jabref/issues/5479)
1718
- We cleaned up the group add/edit dialog. [#5826](https://github.com/JabRef/jabref/pull/5826)
1819
- We reintroduced the index column. [#5844](https://github.com/JabRef/jabref/pull/5844)
@@ -22,6 +23,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
2223

2324
### Fixed
2425

26+
- We fixed an issue where the command line console was always opened in the background. [#5474](https://github.com/JabRef/jabref/issues/5474)
2527
- We fixed and issue where pdf files will not open under some KDE linux distributions when using okular. [#5253](https://github.com/JabRef/jabref/issues/5253)
2628
- We fixed an issue where the Medline fetcher was only working when JabRef was running from source. [#5645](https://github.com/JabRef/jabref/issues/5645)
2729
- We fixed some visual issues in the dark theme. [#5764](https://github.com/JabRef/jabref/pull/5764) [#5753](https://github.com/JabRef/jabref/issues/5753)

build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plugins {
2323
id 'com.github.ben-manes.versions' version '0.27.0'
2424
id 'org.javamodularity.moduleplugin' version '1.5.0'
2525
id 'org.openjfx.javafxplugin' version '0.0.8'
26-
id 'org.beryx.jlink' version '2.17.1'
26+
id 'org.beryx.jlink' version '2.17.2'
2727

2828
// nicer test outputs during running and completion
2929
id 'com.adarshr.test-logger' version '2.0.0'
@@ -255,7 +255,7 @@ dependencyUpdates.resolutionStrategy = {
255255
}
256256
rules.withModule("de.jensd:fontawesomefx-materialdesignfont") { ComponentSelection selection ->
257257
if (selection.candidate.version ==~ /2.0.26-9.1.2/
258-
|| selection.candidate.version ==~ /2.0.26-9.1.1/
258+
|| selection.candidate.version ==~ /2.0.26-9.1.1/
259259
|| selection.candidate.version ==~ /2.0.26-9.1.0/) {
260260
selection.reject('1.7.22-11 is actually newer (strange version system)')
261261
}
@@ -590,7 +590,7 @@ jlink {
590590
requires 'java.rmi'
591591
requires 'java.xml'
592592
requires 'com.sun.xml.txw2'
593-
requires 'com.google.gson';
593+
requires 'com.google.gson'
594594
requires 'java.desktop'
595595
requires 'java.security.jgss'
596596
requires 'jdk.jsobject'
@@ -628,7 +628,6 @@ jlink {
628628
// This requires WiX to be installed: https://github.com/wixtoolset/wix3/releases
629629
installerType = "msi"
630630
imageOptions = [
631-
'--win-console',
632631
'--icon', "${projectDir}/src/main/resources/icons/jabref.ico",
633632
]
634633
installerOptions = [

gradle/wrapper/gradle-wrapper.jar

-7 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ private Node createToolbar() {
481481
HBox rightSide = new HBox(
482482
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, StandardEntryType.Article, dialogService, Globals.prefs, stateManager)),
483483
factory.createIconButton(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs, stateManager)),
484+
factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new ExtractBibtexAction(stateManager)),
484485
factory.createIconButton(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, stateManager)),
485486
new Separator(Orientation.VERTICAL),
486487
factory.createIconButton(StandardActions.UNDO, new OldDatabaseCommandWrapper(Actions.UNDO, this, stateManager)),
@@ -729,6 +730,7 @@ private MenuBar createMenu() {
729730
//@formatter:off
730731
library.getItems().addAll(
731732
factory.createMenuItem(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs, stateManager)),
733+
factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new ExtractBibtexAction(stateManager)),
732734
factory.createMenuItem(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, stateManager)),
733735

734736
new SeparatorMenuItem(),
@@ -768,7 +770,6 @@ private MenuBar createMenu() {
768770
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(this, stateManager)),
769771
factory.createMenuItem(StandardActions.WRITE_XMP, new OldDatabaseCommandWrapper(Actions.WRITE_XMP, this, stateManager)),
770772
factory.createMenuItem(StandardActions.COPY_LINKED_FILES, new CopyFilesAction(stateManager, this.getDialogService())),
771-
factory.createMenuItem(StandardActions.EXTRACT_BIBTEX, new ExtractBibtexAction(stateManager)),
772773

773774
new SeparatorMenuItem(),
774775

src/main/java/org/jabref/gui/actions/StandardActions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public enum StandardActions implements Action {
120120

121121
NEW_ENTRY(Localization.lang("New entry"), IconTheme.JabRefIcons.ADD_ENTRY, KeyBinding.NEW_ENTRY),
122122
NEW_ARTICLE(Localization.lang("New article"), IconTheme.JabRefIcons.ADD_ARTICLE),
123-
NEW_ENTRY_FROM_PLAINTEX(Localization.lang("New entry from plain text"), KeyBinding.NEW_FROM_PLAIN_TEXT),
123+
NEW_ENTRY_FROM_PLAIN_TEXT(Localization.lang("New entry from plain text"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT, KeyBinding.NEW_ENTRY_FROM_PLAIN_TEXT),
124124
LIBRARY_PROPERTIES(Localization.lang("Library properties")),
125125
EDIT_PREAMBLE(Localization.lang("Edit preamble")),
126126
EDIT_STRINGS(Localization.lang("Edit string constants"), IconTheme.JabRefIcons.EDIT_STRINGS, KeyBinding.EDIT_STRINGS),
@@ -138,7 +138,6 @@ public enum StandardActions implements Action {
138138
DOWNLOAD_FULL_TEXT(Localization.lang("Search full text documents online"), IconTheme.JabRefIcons.FILE_SEARCH, KeyBinding.DOWNLOAD_FULL_TEXT),
139139
CLEANUP_ENTRIES(Localization.lang("Cleanup entries"), IconTheme.JabRefIcons.CLEANUP_ENTRIES, KeyBinding.CLEANUP),
140140
SET_FILE_LINKS(Localization.lang("Automatically set file links"), KeyBinding.AUTOMATICALLY_LINK_FILES),
141-
EXTRACT_BIBTEX(Localization.lang("Extract BibTeX from plain text")),
142141

143142
HELP(Localization.lang("Online help"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
144143
HELP_KEY_PATTERNS(Localization.lang("Help on key patterns"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),

src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,60 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6+
import javax.swing.undo.UndoManager;
7+
68
import javafx.beans.property.SimpleStringProperty;
79
import javafx.beans.property.StringProperty;
810

911
import org.jabref.Globals;
12+
import org.jabref.gui.DialogService;
13+
import org.jabref.gui.StateManager;
14+
import org.jabref.gui.externalfiles.ImportHandler;
15+
import org.jabref.gui.externalfiletype.ExternalFileTypes;
16+
import org.jabref.gui.util.BackgroundTask;
17+
import org.jabref.gui.util.TaskExecutor;
18+
import org.jabref.logic.importer.fetcher.GrobidCitationFetcher;
19+
import org.jabref.logic.l10n.Localization;
1020
import org.jabref.model.database.BibDatabaseContext;
1121
import org.jabref.model.entry.BibEntry;
12-
import org.jabref.model.entry.types.EntryType;
13-
import org.jabref.model.entry.types.StandardEntryType;
22+
import org.jabref.model.util.FileUpdateMonitor;
23+
import org.jabref.preferences.JabRefPreferences;
1424

1525
public class BibtexExtractorViewModel {
1626

1727
private final StringProperty inputTextProperty = new SimpleStringProperty("");
18-
private final BibDatabaseContext bibdatabaseContext;
19-
20-
public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext) {
21-
this.bibdatabaseContext = bibdatabaseContext;
28+
private DialogService dialogService;
29+
private GrobidCitationFetcher currentCitationfetcher;
30+
private TaskExecutor taskExecutor;
31+
private ImportHandler importHandler;
32+
33+
public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext, DialogService dialogService,
34+
JabRefPreferences jabRefPreferences, FileUpdateMonitor fileUpdateMonitor, TaskExecutor taskExecutor, UndoManager undoManager, StateManager stateManager) {
35+
this.dialogService = dialogService;
36+
currentCitationfetcher = new GrobidCitationFetcher(jabRefPreferences.getImportFormatPreferences());
37+
this.taskExecutor = taskExecutor;
38+
this.importHandler = new ImportHandler(dialogService, bibdatabaseContext, ExternalFileTypes.getInstance(), jabRefPreferences.getFilePreferences(), jabRefPreferences.getImportFormatPreferences(), jabRefPreferences.getUpdateFieldPreferences(), fileUpdateMonitor, undoManager, stateManager);
2239
}
2340

2441
public StringProperty inputTextProperty() {
2542
return this.inputTextProperty;
2643
}
2744

28-
public void startExtraction() {
29-
30-
BibtexExtractor extractor = new BibtexExtractor();
31-
BibEntry entity = extractor.extract(inputTextProperty.getValue());
32-
this.bibdatabaseContext.getDatabase().insertEntry(entity);
33-
trackNewEntry(StandardEntryType.Article);
45+
public void startParsing() {
46+
BackgroundTask.wrap(() -> currentCitationfetcher.performSearch(inputTextProperty.getValue()))
47+
.onRunning(() -> dialogService.notify(Localization.lang("Your text is being parsed...")))
48+
.onSuccess(parsedEntries -> {
49+
dialogService.notify(Localization.lang("%0 entries were parsed from your query.", String.valueOf(parsedEntries.size())));
50+
importHandler.importEntries(parsedEntries);
51+
for (BibEntry bibEntry : parsedEntries) {
52+
trackNewEntry(bibEntry);
53+
}
54+
}).executeWith(taskExecutor);
3455
}
3556

36-
private void trackNewEntry(EntryType type) {
57+
private void trackNewEntry(BibEntry bibEntry) {
3758
Map<String, String> properties = new HashMap<>();
38-
properties.put("EntryType", type.getName());
39-
40-
Globals.getTelemetryClient().ifPresent(client -> client.trackEvent("NewEntry", properties, new HashMap<>()));
59+
properties.put("EntryType", bibEntry.typeProperty().getValue().getName());
60+
Globals.getTelemetryClient().ifPresent(client -> client.trackEvent("ParseWithGrobid", properties, new HashMap<>()));
4161
}
4262
}

src/main/java/org/jabref/gui/bibtexextractor/ExtractBibtexDialog.fxml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
<?import javafx.scene.control.DialogPane?>
55
<?import javafx.scene.control.TextArea?>
66

7+
<?import javafx.scene.layout.VBox?>
8+
79
<DialogPane prefHeight="430.0" prefWidth="586.0" xmlns="http://javafx.com/javafx/8.0.171"
810
xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.bibtexextractor.ExtractBibtexDialog">
911
<content>
10-
<TextArea fx:id="input" minHeight="-Infinity" prefHeight="350.0" prefWidth="586.0"/>
12+
<VBox fx:id="contentVbox" minHeight="-Infinity" prefHeight="200.0" prefWidth="100.0">
13+
<children>
14+
<TextArea fx:id="input" minHeight="-Infinity" prefHeight="350.0" prefWidth="586.0" wrapText="true"/>
15+
</children>
16+
</VBox>
1117
</content>
12-
<ButtonType fx:id="extractButtonType" buttonData="OK_DONE" text="%Extract"/>
18+
<ButtonType fx:id="parseButtonType" buttonData="OK_DONE" text = "%Add to current library"/>
1319
<ButtonType fx:constant="CANCEL"/>
1420
</DialogPane>
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package org.jabref.gui.bibtexextractor;
22

33
import javax.inject.Inject;
4+
import javax.swing.undo.UndoManager;
45

56
import javafx.fxml.FXML;
67
import javafx.scene.control.Button;
78
import javafx.scene.control.ButtonType;
89
import javafx.scene.control.TextArea;
910
import javafx.scene.control.Tooltip;
1011

12+
import org.jabref.gui.DialogService;
1113
import org.jabref.gui.StateManager;
1214
import org.jabref.gui.util.BaseDialog;
15+
import org.jabref.gui.util.TaskExecutor;
1316
import org.jabref.logic.l10n.Localization;
1417
import org.jabref.model.database.BibDatabaseContext;
18+
import org.jabref.model.util.FileUpdateMonitor;
19+
import org.jabref.preferences.JabRefPreferences;
1520

1621
import com.airhacks.afterburner.views.ViewLoader;
1722

@@ -20,31 +25,34 @@
2025
*/
2126
public class ExtractBibtexDialog extends BaseDialog<Void> {
2227

23-
private final Button buttonExtract;
28+
private final Button buttonParse;
2429
@FXML private TextArea input;
25-
@FXML private ButtonType extractButtonType;
30+
@FXML private ButtonType parseButtonType;
2631
private BibtexExtractorViewModel viewModel;
27-
2832
@Inject private StateManager stateManager;
33+
@Inject private DialogService dialogService;
34+
@Inject private FileUpdateMonitor fileUpdateMonitor;
35+
@Inject private TaskExecutor taskExecutor;
36+
@Inject private UndoManager undoManager;
2937

3038
public ExtractBibtexDialog() {
31-
3239
ViewLoader.view(this)
3340
.load()
3441
.setAsDialogPane(this);
35-
36-
this.setTitle(Localization.lang("Input text to parse"));
37-
buttonExtract = (Button) getDialogPane().lookupButton(extractButtonType);
38-
buttonExtract.setTooltip(new Tooltip((Localization.lang("Starts the extraction of the BibTeX entry"))));
39-
buttonExtract.setOnAction(e -> viewModel.startExtraction());
40-
buttonExtract.disableProperty().bind(viewModel.inputTextProperty().isEmpty());
42+
this.setTitle(Localization.lang("Plain References Parser"));
43+
input.setPromptText(Localization.lang("Please enter the plain references to extract from separated by double empty lines."));
44+
input.selectAll();
45+
46+
buttonParse = (Button) getDialogPane().lookupButton(parseButtonType);
47+
buttonParse.setTooltip(new Tooltip((Localization.lang("Starts the extraction and adds the resulting entries to the currently opened database"))));
48+
buttonParse.setOnAction(event -> viewModel.startParsing());
49+
buttonParse.disableProperty().bind(viewModel.inputTextProperty().isEmpty());
4150
}
4251

4352
@FXML
4453
private void initialize() {
4554
BibDatabaseContext database = stateManager.getActiveDatabase().orElseThrow(() -> new NullPointerException("Database null"));
46-
this.viewModel = new BibtexExtractorViewModel(database);
47-
55+
this.viewModel = new BibtexExtractorViewModel(database, dialogService, JabRefPreferences.getInstance(), fileUpdateMonitor, taskExecutor,undoManager,stateManager);
4856
input.textProperty().bindBidirectional(viewModel.inputTextProperty());
4957
}
5058
}

0 commit comments

Comments
 (0)