Skip to content

Commit

Permalink
Merge branch 'main' into fist-attempt-at-8977
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr authored Nov 10, 2023
2 parents 52c7689 + f4a44ba commit 0ae4ce3
Show file tree
Hide file tree
Showing 36 changed files with 734 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ jobs:
cat heylogs.txt
# exit 1 in case of error
# We have 2 "valid" issues in CHANGELOG.md
grep -q "2 problems" heylogs.txt || exit 1
# We have 1 "valid" issue in CHANGELOG.md
grep -q "1 problem" heylogs.txt || exit 1
- name: Add comment on pull request
if: ${{ failure() }}
uses: thollander/actions-comment-pull-request@v2
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a scite.ai tab in the entry editor that retrieves 'Smart Citation' tallies for citations that have a DOI. [koppor#375](https://github.com/koppor/jabref/issues/375)
- We added a dropdown menu to let users change the reference library during AUX file import. [#10472](https://github.com/JabRef/jabref/issues/10472)
- We added a button to let users reset the cite command to the default value. [#10569](https://github.com/JabRef/jabref/issues/10569)
- We added the option to use System Preference for Light/Dark Theme [#8729](https://github.com/JabRef/jabref/issues/8729).
- We added [scholar.archive.org](https://scholar.archive.org/) as a new fetcher. [#10498](https://github.com/JabRef/jabref/issues/10498)

### Changed

- We moved the location of the 'Open only one instance of JabRef' preference option from "Network" to "General". [#9306](https://github.com/JabRef/jabref/issues/9306)
- The two previews in the change resolver dialog now have their scrollbars synchronized. [#9576](https://github.com/JabRef/jabref/issues/9576).
- We changed the setting of the keyword separator to accept a single character only. [#177](https://github.com/koppor/jabref/issues/177)
- We replaced "SearchAll" in Web Search by "Search Selected". [#10556](https://github.com/JabRef/jabref/issues/10556)
- Short DOI formatter now checks, if the value is already formatted. If so, it returns the value instead of calling the ShortDOIService again. [#10589](https://github.com/JabRef/jabref/issues/10589)
- We upgraded to JavaFX 21.0.1. As a consequence JabRef requires now macOS 11 or later and GTK 3.8 or later on Linux [10627](https://github.com/JabRef/jabref/pull/10627).

### Fixed

Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencyLocking {
}

javafx {
version = "20.0.2"
version = "21.0.1"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing' ]
}

Expand Down Expand Up @@ -179,7 +179,8 @@ dependencies {
exclude group: 'org.apache.logging.log4j'
}

implementation 'org.controlsfx:controlsfx:11.1.2'
implementation 'org.controlsfx:controlsfx:11.2.0'
implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6'

implementation 'org.jsoup:jsoup:1.16.2'
implementation 'com.konghq:unirest-java:3.14.5'
Expand Down
7 changes: 7 additions & 0 deletions external-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ URL: https://github.com/lemire/javaewah
License: Apache-2.0
```
```yaml
Id: com.jthemedetecor.OsThemeDetector
Project: jSystemThemeDetector
URL: https://github.com/Dansoftowner/jSystemThemeDetector
License: Apache-2.0
```
```yaml
Id: com.konghq.unirest
Project: Unirest for Java
Expand Down
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@
requires org.antlr.antlr4.runtime;
requires org.libreoffice.uno;
requires de.saxsys.mvvmfx.validation;
requires com.jthemedetector;
}
18 changes: 18 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,21 @@
.description {
-fx-font-style: italic;
}

.scite-tallies-label {
-fx-font-size: 1.5em;
-fx-font-weight: bold;
}

.scite-error-box {
-fx-padding: 30 0 0 30;
}
.scite-message-box {
-fx-padding: 30 0 0 30;
}

.scite-error-label {
-fx-font-size: 1.5em;
-fx-font-weight: bold;
-fx-text-fill: -fx-accent;
}
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private List<EntryEditorTab> createTabs() {
entryEditorTabList.remove(RelatedArticlesTab.NAME);
entryEditorTabList.remove(LatexCitationsTab.NAME);
entryEditorTabList.remove(FulltextSearchResultsTab.NAME);
entryEditorTabList.remove(SciteTab.NAME);
entryEditorTabList.remove("Comments");
// Then show the remaining configured
for (Map.Entry<String, Set<Field>> tab : entryEditorTabList.entrySet()) {
Expand Down Expand Up @@ -302,6 +303,8 @@ private List<EntryEditorTab> createTabs() {

entryEditorTabs.add(new FulltextSearchResultsTab(stateManager, preferencesService, dialogService, taskExecutor));

entryEditorTabs.add(new SciteTab(preferencesService, taskExecutor, dialogService));

return entryEditorTabs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static JournalPopupEnabled fromString(String status) {
private final DoubleProperty dividerPosition;
private final BooleanProperty autoLinkFiles;
private final ObjectProperty<JournalPopupEnabled> enablementStatus;
private final BooleanProperty shouldShowSciteTab;

public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList,
Map<String, Set<Field>> defaultEntryEditorTabList,
Expand All @@ -58,7 +59,8 @@ public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList,
boolean allowIntegerEditionBibtex,
double dividerPosition,
boolean autolinkFilesEnabled,
JournalPopupEnabled journalPopupEnabled) {
JournalPopupEnabled journalPopupEnabled,
boolean showSciteTab) {

this.entryEditorTabList = new SimpleMapProperty<>(FXCollections.observableMap(entryEditorTabList));
this.defaultEntryEditorTabList = new SimpleMapProperty<>(FXCollections.observableMap(defaultEntryEditorTabList));
Expand All @@ -71,6 +73,7 @@ public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList,
this.dividerPosition = new SimpleDoubleProperty(dividerPosition);
this.autoLinkFiles = new SimpleBooleanProperty(autolinkFilesEnabled);
this.enablementStatus = new SimpleObjectProperty<>(journalPopupEnabled);
this.shouldShowSciteTab = new SimpleBooleanProperty(showSciteTab);
}

public ObservableMap<String, Set<Field>> getEntryEditorTabs() {
Expand Down Expand Up @@ -196,4 +199,16 @@ public ObjectProperty<JournalPopupEnabled> enableJournalPopupProperty() {
public void setEnableJournalPopup(JournalPopupEnabled journalPopupEnabled) {
this.enablementStatus.set(journalPopupEnabled);
}

public boolean shouldShowSciteTab() {
return this.shouldShowSciteTab.get();
}

public BooleanProperty shouldShowLSciteTabProperty() {
return this.shouldShowSciteTab;
}

public void setShouldShowSciteTab(boolean shouldShowSciteTab) {
this.shouldShowSciteTab.set(shouldShowSciteTab);
}
}
131 changes: 131 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/SciteTab.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package org.jabref.gui.entryeditor;

import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import javafx.geometry.HPos;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

import org.jabref.gui.DialogService;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;

import com.tobiasdiez.easybind.EasyBind;
import org.controlsfx.control.HyperlinkLabel;

public class SciteTab extends EntryEditorTab {

public static final String NAME = "Scite";
public static final String SCITE_REPORTS_URL_BASE = "https://scite.ai/reports/";

private final GridPane sciteResultsPane;
private final ProgressIndicator progressIndicator;
private final SciteTabViewModel viewModel;
private final PreferencesService preferencesService;
private final DialogService dialogService;

public SciteTab(PreferencesService preferencesService, TaskExecutor taskExecutor, DialogService dialogService) {
this.preferencesService = preferencesService;
this.viewModel = new SciteTabViewModel(preferencesService, taskExecutor);
this.dialogService = dialogService;
this.sciteResultsPane = new GridPane();
this.progressIndicator = new ProgressIndicator();
setText(NAME);
setTooltip(new Tooltip(Localization.lang("Search scite.ai for Smart Citations")));
setSciteResultsPane();
}

private void setSciteResultsPane() {
progressIndicator.setMaxSize(100, 100);
sciteResultsPane.add(progressIndicator, 0, 0);

ColumnConstraints column = new ColumnConstraints();
column.setPercentWidth(100);
column.setHalignment(HPos.CENTER);

sciteResultsPane.getColumnConstraints().setAll(column);
sciteResultsPane.setId("scitePane");
setContent(sciteResultsPane);

EasyBind.subscribe(viewModel.statusProperty(), status -> {
sciteResultsPane.getChildren().clear();
switch (status) {
case IN_PROGRESS ->
sciteResultsPane.add(progressIndicator, 0, 0);
case FOUND ->
viewModel.getCurrentResult().ifPresent(result -> sciteResultsPane.add(getTalliesPane(result), 0, 0));
case ERROR ->
sciteResultsPane.add(getErrorPane(), 0, 0);
}
});
}

@Override
public boolean shouldShow(BibEntry entry) {
return viewModel.shouldShow();
}

@Override
protected void bindToEntry(BibEntry entry) {
viewModel.bindToEntry(entry);
}

private VBox getErrorPane() {
Label titleLabel = new Label(Localization.lang("Error"));
titleLabel.getStyleClass().add("scite-error-label");
Text errorMessageText = new Text(viewModel.searchErrorProperty().get());
VBox errorMessageBox = new VBox(30, titleLabel, errorMessageText);
errorMessageBox.getStyleClass().add("scite-error-box");
return errorMessageBox;
}

private VBox getTalliesPane(SciteTallyModel tallModel) {
Label titleLabel = new Label(Localization.lang("Tallies for %0", tallModel.doi()));
titleLabel.getStyleClass().add("scite-tallies-label");
Text message = new Text(String.format("Total Citations: %d\nSupporting: %d\nContradicting: %d\nMentioning: %d\nUnclassified: %d\nCiting Publications: %d",
tallModel.total(),
tallModel.supporting(),
tallModel.contradicting(),
tallModel.mentioning(),
tallModel.unclassified(),
tallModel.citingPublications()
));

String url = SCITE_REPORTS_URL_BASE + URLEncoder.encode(tallModel.doi(), StandardCharsets.UTF_8);
VBox messageBox = getMessageBox(url, titleLabel, message);
messageBox.getStyleClass().add("scite-message-box");
return messageBox;
}

private VBox getMessageBox(String url, Label titleLabel, Text message) {
HyperlinkLabel link = new HyperlinkLabel(Localization.lang("See full report at [%0]", url));
link.setOnAction(event -> {
if (event.getSource() instanceof Hyperlink) {
var filePreferences = preferencesService.getFilePreferences();
try {
JabRefDesktop.openBrowser(url, filePreferences);
} catch (IOException ioex) {
// Can't throw a checked exception from here, so display a message to the user instead.
dialogService.showErrorDialogAndWait(
"An error occurred opening web browser",
"JabRef was unable to open a web browser for link:\n\n" + url + "\n\nError Message:\n\n" + ioex.getMessage(),
ioex
);
}
}
});

return new VBox(30, titleLabel, message, link);
}
}
Loading

0 comments on commit 0ae4ce3

Please sign in to comment.