Skip to content

Commit d1b5450

Browse files
committed
Merge remote-tracking branch 'upstream/floating-mode' into floating-mode
# Conflicts: # src/main/java/org/jabref/gui/util/FilteredListProxy.java
2 parents 240d0fc + fab86b7 commit d1b5450

21 files changed

+289
-174
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1414
- We added support for selecting and using CSL Styles in JabRef's OpenOffice/LibreOffice integration for inserting bibliographic and in-text citations into a document. [#2146](https://github.com/JabRef/jabref/issues/2146), [#8893](https://github.com/JabRef/jabref/issues/8893)
1515
- We added Tools > New library based on references in PDF file... to create a new library based on the references section in a PDF file. [#11522](https://github.com/JabRef/jabref/pull/11522)
1616
- When converting the references section of a paper (PDF file), more than the last page is treated. [#11522](https://github.com/JabRef/jabref/pull/11522)
17+
- Added the functionality to invoke offline reference parsing explicitly. [#11565](https://github.com/JabRef/jabref/pull/11565)
18+
- The dialog for [adding an entry using reference text](https://docs.jabref.org/collect/newentryfromplaintext) is now filled with the clipboard contents as default. [#11565](https://github.com/JabRef/jabref/pull/11565)
1719
- Added minimal support for [biblatex data annotation](https://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf#subsection.3.7) fields in `.layout` files. [#11505](https://github.com/JabRef/jabref/issues/11505)
1820
- Added saving of selected options in the [Lookup -> Search for unlinked local files dialog](https://docs.jabref.org/collect/findunlinkedfiles#link-the-pdfs-to-your-bib-library). [#11439](https://github.com/JabRef/jabref/issues/11439)
1921
- We added a toggle button to invert the selected groups. [#9073](https://github.com/JabRef/jabref/issues/9073)
@@ -24,12 +26,14 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
2426
- The Pubmed/Medline Plain importer now imports the PMID field as well [#11488](https://github.com/JabRef/jabref/issues/11488)
2527
- The 'Check for updates' menu bar button is now always enabled. [#11485](https://github.com/JabRef/jabref/pull/11485)
2628
- JabRef respects the [configuration for storing files relative to the .bib file](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files) in more cases. [#11492](https://github.com/JabRef/jabref/pull/11492)
29+
- JabRef does not show finished background tasks in the status bar popup. [#11574](https://github.com/JabRef/jabref/pull/11574)
2730
- We enhanced the indexing speed. [#11502](https://github.com/JabRef/jabref/pull/11502)
2831

2932
### Fixed
3033

3134
- We fixed an issue where the "Check for updates" preference was not saved. [#11485](https://github.com/JabRef/jabref/pull/11485)
3235
- We fixed an issue where an exception was thrown after changing "show preview as a tab" in the preferences. [#11515](https://github.com/JabRef/jabref/pull/11515)
36+
- We fixed an issue that online and offline mode for new library creation were handled incorrectly. [#11565](https://github.com/JabRef/jabref/pull/11565)
3337
- We fixed an issue with colors in the search bar when dark theme is enabled. [#11569](https://github.com/JabRef/jabref/issues/11569)
3438
- We fixed an issue where a new unsaved library was not marked with an asterisk. [#11519](https://github.com/JabRef/jabref/pull/11519)
3539
- We fixed an issue where JabRef starts without window decorations. [#11440](https://github.com/JabRef/jabref/pull/11440)

src/main/java/module-info.java

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@
66
requires java.sql;
77
requires java.sql.rowset;
88

9-
// JavaFX
9+
// region JavaFX
1010
requires javafx.base;
1111
requires javafx.graphics;
1212
requires javafx.controls;
1313
requires javafx.web;
1414
requires javafx.fxml;
15+
1516
requires afterburner.fx;
17+
provides com.airhacks.afterburner.views.ResourceLocator
18+
with org.jabref.gui.util.JabRefResourceLocator;
19+
1620
requires com.dlsc.gemsfx;
1721
uses com.dlsc.gemsfx.TagsField;
22+
23+
requires com.tobiasdiez.easybind;
24+
1825
requires de.saxsys.mvvmfx;
19-
requires reactfx;
26+
requires de.saxsys.mvvmfx.validation;
27+
28+
requires org.controlsfx.controls;
2029
requires org.fxmisc.flowless;
30+
requires org.fxmisc.richtext;
2131

2232
requires org.kordamp.ikonli.core;
2333
requires org.kordamp.ikonli.javafx;
@@ -30,20 +40,17 @@
3040
provides org.kordamp.ikonli.IkonProvider
3141
with org.jabref.gui.icon.JabrefIconProvider;
3242

33-
requires org.controlsfx.controls;
34-
requires org.fxmisc.richtext;
35-
requires com.tobiasdiez.easybind;
36-
37-
provides com.airhacks.afterburner.views.ResourceLocator
38-
with org.jabref.gui.util.JabRefResourceLocator;
43+
requires reactfx;
44+
// endregion
3945

40-
// Logging
46+
// region: Logging
4147
requires org.slf4j;
4248
requires jul.to.slf4j;
4349
requires org.apache.logging.log4j.to.slf4j;
4450
requires org.tinylog.api;
4551
requires org.tinylog.api.slf4j;
4652
requires org.tinylog.impl;
53+
// endregion
4754

4855
provides org.tinylog.writers.Writer
4956
with org.jabref.gui.logging.GuiWriter;
@@ -55,16 +62,18 @@
5562
// YAML
5663
requires org.yaml.snakeyaml;
5764

58-
// Annotations (@PostConstruct)
65+
// region: Annotations (@PostConstruct)
5966
requires jakarta.annotation;
6067
requires jakarta.inject;
68+
// endregion
6169

62-
// http server and client exchange
70+
// region: http server and client exchange
6371
requires java.net.http;
6472
requires jakarta.ws.rs;
6573
requires org.glassfish.grizzly;
74+
// endregion
6675

67-
// data mapping
76+
// region: data mapping
6877
requires jakarta.xml.bind;
6978
requires jdk.xml.dom;
7079
requires com.google.gson;
@@ -73,22 +82,26 @@
7382
requires com.fasterxml.jackson.datatype.jsr310;
7483
// needs to be loaded here as it's otherwise not found at runtime
7584
requires org.glassfish.jaxb.runtime;
85+
// endregion
7686

7787
// dependency injection using HK2
7888
requires org.glassfish.hk2.api;
7989

80-
// http clients
90+
// region: http clients
8191
requires unirest.java.core;
8292
requires unirest.modules.gson;
93+
requires org.apache.httpcomponents.core5.httpcore5;
8394
requires org.jsoup;
95+
// endregion
8496

85-
// SQL databases
97+
// region: SQL databases
8698
requires ojdbc10;
8799
requires org.postgresql.jdbc;
88100
requires org.mariadb.jdbc;
89101
uses org.mariadb.jdbc.credential.CredentialPlugin;
102+
// endregion
90103

91-
// Apache Commons and other (similar) helper libraries
104+
// region: Apache Commons and other (similar) helper libraries
92105
requires com.google.common;
93106
requires io.github.javadiffutils;
94107
requires java.string.similarity;
@@ -98,9 +111,13 @@
98111
requires org.apache.commons.lang3;
99112
requires org.apache.commons.text;
100113
requires org.apache.commons.logging;
114+
// endregion
101115

116+
// region: latex2unicode
102117
requires com.github.tomtung.latex2unicode;
103118
requires fastparse;
119+
requires scala.library;
120+
// endregion
104121

105122
requires jbibtex;
106123
requires citeproc.java;
@@ -123,15 +140,15 @@
123140

124141
requires org.jooq.jool;
125142

126-
// fulltext search
143+
// region: fulltext search
127144
requires org.apache.lucene.core;
128145
// In case the version is updated, please also adapt SearchFieldConstants#VERSION to the newly used version
129146
uses org.apache.lucene.codecs.lucene99.Lucene99Codec;
130-
131147
requires org.apache.lucene.queryparser;
132148
uses org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
133149
requires org.apache.lucene.analysis.common;
134150
requires org.apache.lucene.highlighter;
151+
// endregion
135152

136153
requires net.harawata.appdirs;
137154
requires com.sun.jna;
@@ -143,11 +160,10 @@
143160

144161
requires transitive org.jspecify;
145162

146-
// other libraries
147-
requires org.antlr.antlr4.runtime;
148-
requires org.libreoffice.uno;
149-
requires de.saxsys.mvvmfx.validation;
163+
// region: other libraries (alphabetically)
150164
requires dd.plist;
151165
requires mslinks;
152-
requires org.apache.httpcomponents.core5.httpcore5;
166+
requires org.antlr.antlr4.runtime;
167+
requires org.libreoffice.uno;
168+
// endregion
153169
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public <V> void showProgressDialogAndWait(String title, String content, Task<V>
348348
@Override
349349
public <V> Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) {
350350
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
351-
EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
351+
EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks());
352352
taskProgressView.setRetainTasks(false);
353353
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);
354354

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import javafx.collections.FXCollections;
1414
import javafx.collections.ObservableList;
1515
import javafx.collections.ObservableMap;
16+
import javafx.collections.transformation.FilteredList;
1617
import javafx.concurrent.Task;
1718
import javafx.scene.Node;
1819
import javafx.util.Pair;
@@ -139,8 +140,9 @@ public Optional<Node> getFocusOwner() {
139140
return focusOwner.get();
140141
}
141142

142-
public ObservableList<Task<?>> getBackgroundTasks() {
143-
return EasyBind.map(backgroundTasks, Pair::getValue);
143+
public ObservableList<Task<?>> getRunningBackgroundTasks() {
144+
FilteredList<Pair<BackgroundTask<?>, Task<?>>> pairs = new FilteredList<>(backgroundTasks, task -> task.getValue().isRunning());
145+
return EasyBind.map(pairs, Pair::getValue);
144146
}
145147

146148
public void addBackgroundTask(BackgroundTask<?> backgroundTask, Task<?> task) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public Button createIconButton(Action action, Command command) {
146146
button.graphicProperty().unbind();
147147
action.getIcon().ifPresent(icon -> button.setGraphic(icon.getGraphicNode()));
148148

149-
button.setFocusTraversable(false); // Prevent the buttons from stealing the focus
149+
// Prevent the buttons from stealing the focus
150+
button.setFocusTraversable(false);
151+
150152
return button;
151153
}
152154

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public enum StandardActions implements Action {
9393

9494
PARSE_LATEX(Localization.lang("Search for citations in LaTeX files..."), IconTheme.JabRefIcons.LATEX_CITATIONS),
9595
NEW_SUB_LIBRARY_FROM_AUX(Localization.lang("New sublibrary based on AUX file") + "...", Localization.lang("New BibTeX sublibrary") + Localization.lang("This feature generates a new library based on which entries are needed in an existing LaTeX document."), IconTheme.JabRefIcons.NEW),
96-
NEW_LIBRARY_FROM_PDF_ONLINE(Localization.lang("New library based on references in PDF file... (online)"), Localization.lang("This feature generates a new library based on the list of references in a PDF file. Thereby, it uses GROBID's functionality."), IconTheme.JabRefIcons.NEW),
96+
NEW_LIBRARY_FROM_PDF_ONLINE(Localization.lang("New library based on references in PDF file... (online)"), Localization.lang("This feature generates a new library based on the list of references in a PDF file. Thereby, it uses Grobid's functionality."), IconTheme.JabRefIcons.NEW),
9797
NEW_LIBRARY_FROM_PDF_OFFLINE(Localization.lang("New library based on references in PDF file... (offline)"), Localization.lang("This feature generates a new library based on the list of references in a PDF file. Thereby, it uses JabRef's built-in functionality."), IconTheme.JabRefIcons.NEW),
9898
WRITE_METADATA_TO_PDF(Localization.lang("Write metadata to PDF files"), Localization.lang("Will write metadata to the PDFs linked from selected entries."), KeyBinding.WRITE_METADATA_TO_PDF),
9999

@@ -135,7 +135,9 @@ public enum StandardActions implements Action {
135135

136136
NEW_ENTRY(Localization.lang("New entry"), IconTheme.JabRefIcons.ADD_ENTRY, KeyBinding.NEW_ENTRY),
137137
NEW_ARTICLE(Localization.lang("New article"), IconTheme.JabRefIcons.ADD_ARTICLE),
138-
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),
138+
NEW_ENTRY_FROM_PLAIN_TEXT(Localization.lang("New entry from plain text"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT),
139+
NEW_ENTRY_FROM_PLAIN_TEXT_ONLINE(Localization.lang("New entry from plain text (online)"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT, KeyBinding.NEW_ENTRY_FROM_PLAIN_TEXT_ONLINE),
140+
NEW_ENTRY_FROM_PLAIN_TEXT_OFFLINE(Localization.lang("New entry from plain text (offline)"), IconTheme.JabRefIcons.NEW_ENTRY_FROM_PLAIN_TEXT),
139141
LIBRARY_PROPERTIES(Localization.lang("Library properties")),
140142
FIND_DUPLICATES(Localization.lang("Find duplicates"), IconTheme.JabRefIcons.FIND_DUPLICATES),
141143
MERGE_ENTRIES(Localization.lang("Merge entries"), IconTheme.JabRefIcons.MERGE_ENTRIES, KeyBinding.MERGE_ENTRIES),

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

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.jabref.gui.bibtexextractor;
22

3-
import java.util.HashMap;
43
import java.util.List;
5-
import java.util.Map;
64

75
import javax.swing.undo.UndoManager;
86

@@ -25,24 +23,33 @@
2523
import org.slf4j.Logger;
2624
import org.slf4j.LoggerFactory;
2725

26+
/**
27+
* View model for the feature "Extract BibTeX from plain text".
28+
* Handles both online and offline case.
29+
*
30+
* @implNote Instead of using inheritance, we do if/else checks.
31+
*/
2832
public class BibtexExtractorViewModel {
2933

3034
private static final Logger LOGGER = LoggerFactory.getLogger(BibtexExtractorViewModel.class);
3135

32-
private final StringProperty inputTextProperty = new SimpleStringProperty("");
36+
private final boolean onlineMode;
3337
private final DialogService dialogService;
3438
private final PreferencesService preferencesService;
3539
private final TaskExecutor taskExecutor;
36-
private final ImportHandler importHandler;
3740

38-
public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext,
39-
DialogService dialogService,
40-
PreferencesService preferencesService,
41-
FileUpdateMonitor fileUpdateMonitor,
42-
TaskExecutor taskExecutor,
43-
UndoManager undoManager,
44-
StateManager stateManager) {
41+
private final ImportHandler importHandler;
42+
private final StringProperty inputTextProperty = new SimpleStringProperty("");
4543

44+
public BibtexExtractorViewModel(boolean onlineMode,
45+
BibDatabaseContext bibdatabaseContext,
46+
DialogService dialogService,
47+
PreferencesService preferencesService,
48+
FileUpdateMonitor fileUpdateMonitor,
49+
TaskExecutor taskExecutor,
50+
UndoManager undoManager,
51+
StateManager stateManager) {
52+
this.onlineMode = onlineMode;
4653
this.dialogService = dialogService;
4754
this.preferencesService = preferencesService;
4855
this.taskExecutor = taskExecutor;
@@ -56,25 +63,20 @@ public BibtexExtractorViewModel(BibDatabaseContext bibdatabaseContext,
5663
taskExecutor);
5764
}
5865

59-
public StringProperty inputTextProperty() {
60-
return this.inputTextProperty;
61-
}
62-
6366
public void startParsing() {
64-
if (preferencesService.getGrobidPreferences().isGrobidEnabled()) {
65-
parseUsingGrobid();
67+
if (onlineMode) {
68+
startParsingOnline();
6669
} else {
67-
parseUsingBibtexExtractor();
70+
startParsingOffline();
6871
}
6972
}
7073

71-
private void parseUsingBibtexExtractor() {
74+
private void startParsingOffline() {
7275
BibEntry parsedEntry = new BibtexExtractor().extract(inputTextProperty.getValue());
7376
importHandler.importEntries(List.of(parsedEntry));
74-
trackNewEntry(parsedEntry, "ParseWithBibTeXExtractor");
7577
}
7678

77-
private void parseUsingGrobid() {
79+
private void startParsingOnline() {
7880
GrobidCitationFetcher grobidCitationFetcher = new GrobidCitationFetcher(preferencesService.getGrobidPreferences(), preferencesService.getImportFormatPreferences());
7981
BackgroundTask.wrap(() -> grobidCitationFetcher.performSearch(inputTextProperty.getValue()))
8082
.onRunning(() -> dialogService.notify(Localization.lang("Your text is being parsed...")))
@@ -90,14 +92,10 @@ private void parseUsingGrobid() {
9092
.onSuccess(parsedEntries -> {
9193
dialogService.notify(Localization.lang("%0 entries were parsed from your query.", String.valueOf(parsedEntries.size())));
9294
importHandler.importEntries(parsedEntries);
93-
for (BibEntry bibEntry : parsedEntries) {
94-
trackNewEntry(bibEntry, "ParseWithGrobid");
95-
}
9695
}).executeWith(taskExecutor);
9796
}
9897

99-
private void trackNewEntry(BibEntry bibEntry, String eventMessage) {
100-
Map<String, String> properties = new HashMap<>();
101-
properties.put("EntryType", bibEntry.typeProperty().getValue().getName());
98+
public StringProperty inputTextProperty() {
99+
return this.inputTextProperty;
102100
}
103101
}

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

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.jabref.gui.bibtexextractor;
2+
3+
import org.jabref.gui.DialogService;
4+
import org.jabref.gui.StateManager;
5+
import org.jabref.gui.actions.SimpleCommand;
6+
7+
import static org.jabref.gui.actions.ActionHelper.needsDatabase;
8+
9+
public class ExtractBibtexActionOffline extends SimpleCommand {
10+
11+
private final DialogService dialogService;
12+
13+
public ExtractBibtexActionOffline(DialogService dialogService, StateManager stateManager) {
14+
this.dialogService = dialogService;
15+
this.executable.bind(needsDatabase(stateManager));
16+
}
17+
18+
@Override
19+
public void execute() {
20+
dialogService.showCustomDialogAndWait(new ExtractBibtexDialog(false));
21+
}
22+
}

0 commit comments

Comments
 (0)