Skip to content

Commit

Permalink
Merge branch 'main' into postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
LoayGhreeb committed Oct 4, 2024
2 parents f54bf6e + d3c7e51 commit 4b90aa5
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 57 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a "view as BibTeX" option before importing an entry from the citation relation tab. [#11826](https://github.com/JabRef/jabref/issues/11826)
- We added probable search hits instead of exact matches. Sorting by hit score can be done by the new score table column. [#11542](https://github.com/JabRef/jabref/pull/11542)
- We added support finding LaTeX-encoded special characters based on plain Unicode and vice versa. [#11542](https://github.com/JabRef/jabref/pull/11542)
- When a search hits a file, the file icon of that entry is changed accordingly. [#11542](https://github.com/JabRef/jabref/pull/11542)
Expand Down Expand Up @@ -53,6 +54,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We improved the DOI detection in PDF imports. [#11782](https://github.com/JabRef/jabref/pull/11782)
- We improved the performance when pasting and importing entries in an existing library. [#11843](https://github.com/JabRef/jabref/pull/11843)
- When fulltext search is selected but indexing is deactivated, a dialog is now shown asking if the user wants to enable indexing now [#9491](https://github.com/JabRef/jabref/issues/9491)
- We changed instances of 'Search Selected' to 'Search Pre-configured' in Web Search Preferences UI. [#11871](https://github.com/JabRef/jabref/pull/11871)

### Fixed

Expand Down Expand Up @@ -81,6 +83,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where HTML instead of the fulltext pdf was downloaded when importing arXiv entries. [#4913](https://github.com/JabRef/jabref/issues/4913)
- We fixed an issue where the keywords and crossref fields were not properly focused. [#11177](https://github.com/JabRef/jabref/issues/11177)
- We fixed an issue where recently opened files were not displayed in the main menu properly. [#9042](https://github.com/JabRef/jabref/issues/9042)
- We fixed an issue where the DOI lookup would show an error when a DOI was found for an entry. [#11850](https://github.com/JabRef/jabref/issues/11850)

### Removed

Expand Down
5 changes: 5 additions & 0 deletions docs/code-howtos/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ More information on the architecture can be found at [../getting-into-the-code/h

This test is triggered when any kind of documentation is touched (be it the JabRef docs, or JavaDoc in code). If you changed something in the documentation, and particularly added/changed any links (to external files or websites), check if the links are correct and working. If you didn't change/add any link, or added correct links, the test is most probably failing due to any of the existing links being broken, and thus can be ignored (in the context of your contribution).

### Failing <b>Fetcher</b> tests

Fetcher tests are run when any file in the `.../fetcher` directory has been touched. If you have changed any fetcher logic, check if the changes are correct. You can look for more details on how to locally run fetcher tests [here](https://devdocs.jabref.org/code-howtos/testing.html#fetchers-in-tests).
Otherwise, since these tests depend on remote services, their failure can also be caused by the network or an external server, and thus can be ignored in the context of your contribution. For more information, you can look [here](https://devdocs.jabref.org/code-howtos/fetchers.html#committing-and-pushing-changes-to-fetcher-files).

## Gradle outputs

### `ANTLR Tool version 4.12.0 used for code generation does not match the current runtime version 4.13.1`
Expand Down
7 changes: 7 additions & 0 deletions docs/code-howtos/fetchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ new BuildInfo().springerNatureAPIKey
```

When executing `./gradlew run`, gradle executes `processResources` and populates `build/build.properties` accordingly. However, when working directly in the IDE, Eclipse keeps reading `build.properties` from `src/main/resources`. In IntelliJ, the task `JabRef Main` is executing `./gradlew processResources` before running JabRef from the IDE to ensure the `build.properties` is properly populated.

## Committing and pushing changes to fetcher files

Fetcher tests are run when a PR contains changes touching any file in the `src/main/java/org/jabref/logic/importer/fetcher/` directory.
Since these tests rely on remote services, some of them may fail due to the network or the external server.

To learn more about doing fetcher tests locally, see Fetchers in tests in [Testing](https://devdocs.jabref.org/code-howtos/testing.html).
10 changes: 10 additions & 0 deletions docs/code-howtos/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ docker run -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=jabref -p 3800:3307 mys

Set the environment variable `DBMS` to `mysql`.

## Fetchers in tests

Fetcher tests can be run locally by executing the Gradle task `fetcherTest`. This can be done by running the following command in the command line:

```shell
./gradlew fetcherTest
```

Alternatively, if one is using IntelliJ, this can also be done by double-clicking the `fetcherTest` task under the `other` group in the Gradle Tool window (`JabRef > Tasks > other > fetcherTest`).

## Advanced testing and further reading

On top of basic unit testing, there are more ways to test a software:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private List<EntryEditorTab> createTabs() {
tabs.add(new FileAnnotationTab(libraryTab.getAnnotationCache()));
tabs.add(new SciteTab(preferences, taskExecutor, dialogService));
tabs.add(new CitationRelationsTab(dialogService, databaseContext,
undoManager, stateManager, fileMonitor, preferences, libraryTab, taskExecutor));
undoManager, stateManager, fileMonitor, preferences, libraryTab, taskExecutor, bibEntryTypesManager));
tabs.add(new RelatedArticlesTab(buildInfo, databaseContext, preferences, dialogService, taskExecutor));
sourceTab = new SourceTab(
databaseContext,
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/SourceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public int getLocationOffset(int x, int y) {

@Override
public void cancelLatestCommittedText() {
return;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.entryeditor.citationrelationtab;

import java.io.IOException;
import java.io.StringWriter;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
Expand All @@ -12,11 +13,15 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.SplitPane;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.Tooltip;
Expand All @@ -28,6 +33,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.LibraryTab;
import org.jabref.gui.StateManager;
import org.jabref.gui.collab.entrychange.PreviewWithSourceTab;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.entryeditor.EntryEditorTab;
import org.jabref.gui.entryeditor.citationrelationtab.semanticscholar.CitationFetcher;
Expand All @@ -36,11 +42,17 @@
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.util.NoSelectionModel;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.bibtex.BibEntryWriter;
import org.jabref.logic.bibtex.FieldPreferences;
import org.jabref.logic.bibtex.FieldWriter;
import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.exporter.BibWriter;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.os.OS;
import org.jabref.logic.util.BackgroundTask;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.database.BibDatabaseModeDetection;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -51,6 +63,8 @@

import com.tobiasdiez.easybind.EasyBind;
import org.controlsfx.control.CheckListView;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -74,6 +88,7 @@ public class CitationRelationsTab extends EntryEditorTab {
private final BibEntryRelationsRepository bibEntryRelationsRepository;
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel;
private final DuplicateCheck duplicateCheck;
private final BibEntryTypesManager entryTypesManager;

public CitationRelationsTab(DialogService dialogService,
BibDatabaseContext databaseContext,
Expand All @@ -82,7 +97,8 @@ public CitationRelationsTab(DialogService dialogService,
FileUpdateMonitor fileUpdateMonitor,
GuiPreferences preferences,
LibraryTab libraryTab,
TaskExecutor taskExecutor) {
TaskExecutor taskExecutor,
BibEntryTypesManager bibEntryTypesManager) {
this.dialogService = dialogService;
this.databaseContext = databaseContext;
this.preferences = preferences;
Expand All @@ -91,7 +107,8 @@ public CitationRelationsTab(DialogService dialogService,
setText(Localization.lang("Citation relations"));
setTooltip(new Tooltip(Localization.lang("Show articles related by citation")));

this.duplicateCheck = new DuplicateCheck(new BibEntryTypesManager());
this.entryTypesManager = bibEntryTypesManager;
this.duplicateCheck = new DuplicateCheck(entryTypesManager);
this.bibEntryRelationsRepository = new BibEntryRelationsRepository(new SemanticScholarFetcher(preferences.getImporterPreferences()),
new BibEntryRelationsCache());
citationsRelationsTabViewModel = new CitationsRelationsTabViewModel(databaseContext, preferences, undoManager, stateManager, dialogService, fileUpdateMonitor, taskExecutor);
Expand Down Expand Up @@ -254,6 +271,14 @@ private void styleFetchedListView(CheckListView<CitationRelationItem> listView)
vContainer.getChildren().addLast(openWeb);
}

Button showEntrySource = IconTheme.JabRefIcons.SOURCE.asButton();
showEntrySource.setTooltip(new Tooltip(Localization.lang("%0 source", "BibTeX")));
showEntrySource.setOnMouseClicked(event -> {
showEntrySourceDialog(entry.entry());
});

vContainer.getChildren().addLast(showEntrySource);

hContainer.getChildren().addAll(entryNode, separator, vContainer);
hContainer.getStyleClass().add("entry-container");

Expand All @@ -270,6 +295,43 @@ private void styleFetchedListView(CheckListView<CitationRelationItem> listView)
listView.setSelectionModel(new NoSelectionModel<>());
}

/**
* @implNote This code is similar to {@link PreviewWithSourceTab#getSourceString(BibEntry, BibDatabaseMode, FieldPreferences, BibEntryTypesManager)}.
*/
private String getSourceString(BibEntry entry, BibDatabaseMode type, FieldPreferences fieldPreferences, BibEntryTypesManager entryTypesManager) throws IOException {
StringWriter writer = new StringWriter();
BibWriter bibWriter = new BibWriter(writer, OS.NEWLINE);
FieldWriter fieldWriter = FieldWriter.buildIgnoreHashes(fieldPreferences);
new BibEntryWriter(fieldWriter, entryTypesManager).write(entry, bibWriter, type);
return writer.toString();
}

private void showEntrySourceDialog(BibEntry entry) {
CodeArea ca = new CodeArea();
try {
ca.appendText(getSourceString(entry, databaseContext.getMode(), preferences.getFieldPreferences(), this.entryTypesManager));
} catch (IOException e) {
LOGGER.warn("Incorrect entry, could not load source:", e);
return;
}

ca.setWrapText(true);
ca.setPadding(new Insets(0, 10, 0, 10));
ca.showParagraphAtTop(0);

ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
scrollPane.setContent(new VirtualizedScrollPane<>(ca));

DialogPane dialogPane = new DialogPane();
dialogPane.setPrefSize(800, 400);
dialogPane.setContent(scrollPane);
String title = Localization.lang("Show BibTeX source");

dialogService.showCustomDialogAndWait(title, dialogPane, ButtonType.OK);
}

/**
* Method to style heading labels
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private String lookupIdentifiers(List<BibEntry> bibEntries) {
}
namedCompound.end();
if (foundCount > 0) {
undoManager.addEdit(namedCompound);
UiTaskExecutor.runInJavaFXThread(() -> undoManager.addEdit(namedCompound));
}
return Localization.lang("Determined %0 for %1 entries", fetcher.getIdentifierName(), Integer.toString(foundCount));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<CheckBox fx:id="useCustomDOI" text="%Use custom DOI base URI for article access"/>
<TextField fx:id="useCustomDOIName" HBox.hgrow="ALWAYS"/>
</HBox>
<Label styleClass="sectionHeader" text="%Catalogues used for 'Search Selected'"/>
<Label styleClass="sectionHeader" text="%Catalogues used for 'Search pre-configured'"/>
<TableView
fx:id="catalogTable"
VBox.vgrow="ALWAYS"
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/importer/WebFetchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static Set<CustomizableKeyFetcher> getCustomizableKeyFetchers(ImportForma
}

/**
* Places "Search Selected" to the first of the set
* Places "Search pre-configured" to the first of the set
*/
class CompositeSearchFirstComparator implements Comparator<SearchBasedFetcher> {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class CompositeSearchBasedFetcher implements SearchBasedFetcher {

public static final String FETCHER_NAME = "Search Selected";
public static final String FETCHER_NAME = "Search pre-configured";

private static final Logger LOGGER = LoggerFactory.getLogger(CompositeSearchBasedFetcher.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -91,15 +92,7 @@ private String convertToString(BufferedReader input) {
/**
* Small pair-class to ensure the right order of the recommendations.
*/
private static class RankedBibEntry {

public BibEntry entry;
public Integer rank;

public RankedBibEntry(BibEntry entry, Integer rank) {
this.rank = rank;
this.entry = entry;
}
private record RankedBibEntry(BibEntry entry, Integer rank) {
}

/**
Expand All @@ -126,8 +119,7 @@ private void parse(BufferedReader input) throws IOException {
}

// Sort bib entries according to rank
rankedBibEntries.sort((RankedBibEntry rankedBibEntry1,
RankedBibEntry rankedBibEntry2) -> rankedBibEntry1.rank.compareTo(rankedBibEntry2.rank));
rankedBibEntries.sort(Comparator.comparing((RankedBibEntry rankedBibEntry) -> rankedBibEntry.rank));
List<BibEntry> bibEntries = rankedBibEntries.stream().map(e -> e.entry).collect(Collectors.toList());

bibDatabase.insertEntries(bibEntries);
Expand Down
20 changes: 5 additions & 15 deletions src/main/java/org/jabref/logic/openoffice/action/EditMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,11 @@ public static boolean mergeCitationGroups(XTextDocument doc, OOFrontend frontend
return madeModifications;
}

private static class JoinableGroupData {
/**
* A list of consecutive citation groups only separated by spaces.
*/
List<CitationGroup> group;

/**
* A cursor covering the XTextRange of each entry in group (and the spaces between them)
*/
XTextCursor groupCursor;

JoinableGroupData(List<CitationGroup> group, XTextCursor groupCursor) {
this.group = group;
this.groupCursor = groupCursor;
}
/**
* @param group A list of consecutive citation groups only separated by spaces.
* @param groupCursor A cursor covering the XTextRange of each entry in group (and the spaces between them)
*/
private record JoinableGroupData(List<CitationGroup> group, XTextCursor groupCursor) {
}

private static class ScanState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static <T> List<RangeSortable<T>> visualSort(List<RangeSortable<T>> input
// collect ordered result
List<RangeSortable<T>> result = new ArrayList<>(comparableMarks.size());
for (ComparableMark<RangeSortable<T>> mark : comparableMarks) {
result.add(mark.getContent());
result.add(mark.content());
}

if (result.size() != inputSize) {
Expand Down Expand Up @@ -111,20 +111,6 @@ private static <T> int compareTopToBottomLeftToRight(ComparableMark<T> a, Compar
* <p>
* Used for sorting reference marks by their visual positions.
*/
private static class ComparableMark<T> {

private final Point position;
private final int indexInPosition;
private final T content;

public ComparableMark(Point position, int indexInPosition, T content) {
this.position = position;
this.indexInPosition = indexInPosition;
this.content = content;
}

public T getContent() {
return content;
}
private record ComparableMark<T>(Point position, int indexInPosition, T content) {
}
}
1 change: 0 additions & 1 deletion src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ Case\ sensitive=Groß-/Kleinschreibung
change\ assignment\ of\ entries=Änderung der zugewiesenen Einträge
Catalogues\ used\ for\ 'Search\ Selected'=Kataloge für 'In Ausgewählten suchen'
Change\ case=Groß- und Kleinschreibung
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Case\ sensitive=Case sensitive

change\ assignment\ of\ entries=change assignment of entries

Catalogues\ used\ for\ 'Search\ Selected'=Catalogues used for 'Search Selected'
Catalogues\ used\ for\ 'Search\ pre-configured'=Catalogues used for 'Search pre-configured'

Change\ case=Change case

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ Case\ sensitive=Sensible al uso de mayúsculas/minúsculas
change\ assignment\ of\ entries=Cambiar asignación de entradas
Catalogues\ used\ for\ 'Search\ Selected'=Catálogos usados para «Buscar en selección»
Change\ case=Cambiar mayúsculas/minúsculas
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Case\ sensitive=Sensible à la casse

change\ assignment\ of\ entries=changer l'assignation des entrées
Catalogues\ used\ for\ 'Search\ Selected'=Catalogues utilisés pour la 'Recherche sélectionnée'
Catalogues\ used\ for\ 'Search\ pre-configured'=Catalogues utilisés pour la "recherche préconfigurée"
Change\ case=Changer la casse
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Case\ sensitive=Distingue maiuscole e minuscole

change\ assignment\ of\ entries=modifica l'assegnazione delle voci
Catalogues\ used\ for\ 'Search\ Selected'=Cataloghi usati per 'Ricerca selezionata'
Catalogues\ used\ for\ 'Search\ pre-configured'=Cataloghi usati per 'Ricerca pre-configurata'
Change\ case=Inverti maiuscolo/minuscolo
Expand Down
Loading

0 comments on commit 4b90aa5

Please sign in to comment.