Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into addRightlickToGroup
Browse files Browse the repository at this point in the history
* upstream/main:
  Update abbrv.jabref.org (#12365)
  Bump buildres/abbrv.jabref.org from `78e1b08` to `c202741` (#12363)
  Bump org.beryx.jlink from 3.1.0-rc-1 to 3.1.1 (#12362)
  Bump tech.units:indriya from 2.2.1 to 2.2.2 (#12361)
  Bump com.dlsc.gemsfx:gemsfx from 2.80.0 to 2.81.0 (#12360)
  Bump org.mariadb.jdbc:mariadb-java-client from 2.7.9 to 2.7.12 (#12359)
  Bump org.mockito:mockito-core from 5.14.2 to 5.15.2 (#12358)
  Fix content not correctly parsed at pdf content importer (#12338)
  Bump de.undercouch:citeproc-java from 3.1.0 to 3.2.0 (#12347)
  Bump org.openrewrite.rewrite from 6.29.0 to 6.29.2 (#12345)
  Improve utf8 detection  (#12342)
  Bump org.fxmisc.richtext:richtextfx from 0.11.3 to 0.11.4 (#12346)
  Bump ai.djl:bom from 0.30.0 to 0.31.1 (#12344)
  Bump com.puppycrawl.tools:checkstyle from 10.21.0 to 10.21.1 (#12343)
  • Loading branch information
Siedlerchr committed Jan 8, 2025
2 parents 2b6c513 + 5f3fbbc commit aa95a25
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 65 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Changed

- We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278)

### Fixed

- We fixed an issue where a bib file with UFF-8 charset was wrongly loaded with a different charset [forum#5369](https://discourse.jabref.org/t/jabref-5-15-opens-bib-files-with-shift-jis-encoding-instead-of-utf-8/5369/)

### Removed

- "Web of Science" [journal abbreviation list](https://docs.jabref.org/advanced/journalabbreviations) was removed. [abbrv.jabref.org#176](https://github.com/JabRef/abbrv.jabref.org/issues/176)

## [6.0-alpha] – 2024-12-23

### Added
Expand Down
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {

id 'org.openjfx.javafxplugin' version '0.1.0'

id 'org.beryx.jlink' version '3.1.0-rc-1'
id 'org.beryx.jlink' version '3.1.1'

// nicer test outputs during running and completion
// Homepage: https://github.com/radarsh/gradle-test-logger-plugin
Expand All @@ -29,7 +29,7 @@ plugins {

id 'idea'

id 'org.openrewrite.rewrite' version '6.29.0'
id 'org.openrewrite.rewrite' version '6.29.3'

id "org.itsallcode.openfasttrace" version "3.0.1"
}
Expand Down Expand Up @@ -211,7 +211,7 @@ dependencies {

implementation 'com.fasterxml:aalto-xml:1.3.3'

implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.9'
implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.12'

implementation 'org.postgresql:postgresql:42.7.4'

Expand Down Expand Up @@ -243,8 +243,8 @@ dependencies {
exclude group: 'org.openjfx'
}
implementation 'org.fxmisc.flowless:flowless:0.7.3'
implementation 'org.fxmisc.richtext:richtextfx:0.11.3'
implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.80.0') {
implementation 'org.fxmisc.richtext:richtextfx:0.11.4'
implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.81.0') {
exclude module: 'javax.inject' // Split package, use only jakarta.inject
exclude module: 'commons-lang3'
exclude group: 'org.apache.commons.validator'
Expand All @@ -256,7 +256,7 @@ dependencies {
exclude group: 'tech.units'
}
// Required by gemsfx
implementation 'tech.units:indriya:2.2.1'
implementation 'tech.units:indriya:2.2.2'
// Required by gemsfx and langchain4j
implementation ('com.squareup.retrofit2:retrofit:2.11.0') {
exclude group: 'com.squareup.okhttp3'
Expand All @@ -281,7 +281,7 @@ dependencies {
// route all requests to log4j to SLF4J
implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.24.3'

implementation('de.undercouch:citeproc-java:3.1.0') {
implementation('de.undercouch:citeproc-java:3.2.0') {
exclude group: 'org.antlr'
}

Expand Down Expand Up @@ -358,7 +358,7 @@ dependencies {
}

implementation 'org.apache.velocity:velocity-engine-core:2.4.1'
implementation platform('ai.djl:bom:0.30.0')
implementation platform('ai.djl:bom:0.31.1')
implementation 'ai.djl:api'
implementation 'ai.djl.huggingface:tokenizers'
implementation 'ai.djl.pytorch:pytorch-model-zoo'
Expand All @@ -383,7 +383,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testImplementation 'org.junit.platform:junit-platform-launcher:1.11.4'

testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'org.mockito:mockito-core:5.15.2'
testImplementation 'org.xmlunit:xmlunit-core:2.10.0'
testImplementation 'org.xmlunit:xmlunit-matchers:2.10.0'
testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.3.0'
Expand All @@ -396,12 +396,12 @@ dependencies {
// recommended by https://github.com/wiremock/wiremock/issues/2149#issuecomment-1835775954
testImplementation 'org.wiremock:wiremock-standalone:3.10.0'

checkstyle 'com.puppycrawl.tools:checkstyle:10.21.0'
checkstyle 'com.puppycrawl.tools:checkstyle:10.21.1'
// xjc needs the runtime as well for the ant task, otherwise it fails
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2'
xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2'

rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.22.0"))
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.23.2"))
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
rewrite("org.openrewrite.recipe:rewrite-logging-frameworks")
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void updateItem(CitationKeyPatternsPanelItemModel item, boolean empty) {
setStyle("");
} else if (isSelected()) {
setStyle("-fx-background-color: -fx-selection-bar");
} else if (item.getEntryType().getName().equals(CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME)) {
} else if (CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME.equals(item.getEntryType().getName())) {
setStyle("-fx-background-color: -fx-default-button");
} else {
setStyle("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class CitationKeyPatternsPanelViewModel {

if (itemOneName.equals(itemTwoName)) {
return 0;
} else if (itemOneName.equals(ENTRY_TYPE_DEFAULT_NAME)) {
} else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemOneName)) {
return -1;
} else if (itemTwoName.equals(ENTRY_TYPE_DEFAULT_NAME)) {
} else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemTwoName)) {
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static Set<ExternalFileType> fromString(String storedFileTypes) {
// Read the prefs information for file types:
String[][] vals = StringUtil.decodeStringDoubleArray(storedFileTypes);
for (String[] val : vals) {
if ((val.length == 2) && val[1].equals(FILE_TYPE_REMOVED_FLAG)) {
if ((val.length == 2) && FILE_TYPE_REMOVED_FLAG.equals(val[1])) {
// This entry indicates that a default entry type should be removed:
ExternalFileType toRemove = null;
for (ExternalFileType type : types) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public void setValues() {
if (parentNode != null) {
parentNode.getGroup()
.getIconName()
.filter(iconName -> !iconName.equals(DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON))
.filter(iconName -> !DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON.equals(iconName))
.ifPresent(iconProperty::setValue);
parentNode.getGroup().getColor().ifPresent(color -> colorUseProperty.setValue(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void setValues() {
catalogs.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences)
.stream()
.map(SearchBasedFetcher::getName)
.filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME))
.filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name))
.map(name -> {
boolean enabled = importerPreferences.getCatalogs().contains(name);
return new StudyCatalogItem(name, enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ManageStudyDefinitionViewModel(ImportFormatPreferences importFormatPrefer
.map(SearchBasedFetcher::getName)
// The user wants to select specific fetchers
// The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR)
.filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME))
.filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name))
.map(name -> {
boolean enabled = DEFAULT_SELECTION.contains(name);
return new StudyCatalogItem(name, enabled);
Expand Down Expand Up @@ -108,7 +108,7 @@ public ManageStudyDefinitionViewModel(Study study,
.map(SearchBasedFetcher::getName)
// The user wants to select specific fetchers
// The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR)
.filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME))
.filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name))
.map(name -> {
boolean enabled = studyDatabases.contains(new StudyDatabase(name, true));
return new StudyCatalogItem(name, enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static Map<String, String> serializeMetaData(Map<String, List<String>> s
continue;
}

boolean isSaveActions = metaItem.getKey().equals(MetaData.SAVE_ACTIONS);
boolean isSaveActions = MetaData.SAVE_ACTIONS.equals(metaItem.getKey());
// The last "MetaData.SEPARATOR_STRING" adds compatibility to JabRef v5.9 and earlier
StringJoiner joiner = new StringJoiner(MetaData.SEPARATOR_STRING, "", MetaData.SEPARATOR_STRING);
boolean lastWasSaveActionsEnablement = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/exporter/XmpExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void export(BibDatabaseContext databaseContext, Path file, List<BibEntry>

// This is a distinction between writing all entries from the supplied list to a single .xmp file,
// or write every entry to a separate file.
if (file.getFileName().toString().trim().equals(XMP_SPLIT_DIRECTORY_INDICATOR)) {
if (XMP_SPLIT_DIRECTORY_INDICATOR.equals(file.getFileName().toString().trim())) {
for (BibEntry entry : entries) {
// Avoid situations, where two citation keys are null
Path entryFile;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/logic/importer/Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ protected static Charset getCharset(BufferedInputStream bufferedInputStream) {
return defaultCharSet;
}

if (Arrays.stream(matches).anyMatch(charset -> "ASCII".equals(charset.getName()))) {
// if we have utf8 with 100 confidence we assume that the file is in utf8, more likely
if (Arrays.stream(matches).anyMatch(charset -> "ASCII".equals(charset.getName()) || ("UTF-8".equals(charset.getName()) && charset.getConfidence() == 100))) {
return defaultCharSet;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,6 @@ private boolean isAPSJournal(BibEntry entry, String doiAsString) {
}
String suffix = doiAsString.substring(doiAsString.lastIndexOf('/') + 1);
String organizationId = doiAsString.substring(doiAsString.indexOf('.') + 1, doiAsString.indexOf('/'));
return organizationId.equals(APS_JOURNAL_ORG_DOI_ID) && APS_SUFFIX_PATTERN.matcher(suffix).matches();
return APS_JOURNAL_ORG_DOI_ID.equals(organizationId) && APS_SUFFIX_PATTERN.matcher(suffix).matches();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void parseDatabaseID() throws IOException {
skipWhitespace();
String label = parseTextToken().trim();

if (label.equals(BibtexDatabaseWriter.DATABASE_ID_PREFIX)) {
if (BibtexDatabaseWriter.DATABASE_ID_PREFIX.equals(label)) {
skipWhitespace();
database.setSharedDatabaseID(parseTextToken().trim());
}
Expand Down Expand Up @@ -354,7 +354,7 @@ private void parseJabRefComment(Map<String, String> meta) {
// We remove all line breaks in the metadata
// These have been inserted to prevent too long lines when the file was saved, and are not part of the data.
String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", "");
if (comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())).equals(MetaData.META_FLAG)) {
if (MetaData.META_FLAG.equals(comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())))) {
if (comment.startsWith(MetaData.META_FLAG)) {
String rest = comment.substring(MetaData.META_FLAG.length());

Expand All @@ -367,8 +367,8 @@ private void parseJabRefComment(Map<String, String> meta) {
dumpTextReadSoFarToString();
}
}
} else if (comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length()))
.equals(MetaData.ENTRYTYPE_FLAG)) {
} else if (MetaData.ENTRYTYPE_FLAG
.equals(comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())))) {
// A custom entry type can also be stored in a
// "@comment"
Optional<BibEntryType> typ = MetaDataParser.parseCustomEntryType(comment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,13 @@ protected void writeString(String text, List<TextPosition> textPositions) {
}

private boolean isFarAway(TextPosition previous, TextPosition current) {
float XspaceThreshold = 3.0F;
float YspaceThreshold = previous.getFontSizeInPt() * 1.5F;
float XspaceThreshold = previous.getFontSizeInPt() * 3.0F;
float YspaceThreshold = previous.getFontSizeInPt() * 3.0F;
float Xgap = current.getXDirAdj() - (previous.getXDirAdj() + previous.getWidthDirAdj());
float Ygap = current.getYDirAdj() - (previous.getYDirAdj() - previous.getHeightDir());
return Xgap > XspaceThreshold && Ygap > YspaceThreshold;
float Ygap = current.getYDirAdj() - previous.getYDirAdj();
// For cases like paper titles spanning two or more lines, both X and Y gaps must exceed thresholds,
// so "&&" is used instead of "||".
return Math.abs(Xgap) > XspaceThreshold && Math.abs(Ygap) > YspaceThreshold;
}

private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition textPosition) {
Expand All @@ -258,28 +260,27 @@ private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition t
return true;
}
// The title usually don't in the bottom 10% of a page.
if ((textPosition.getPageHeight() - textPosition.getYDirAdj())
< (textPosition.getPageHeight() * 0.1)) {
return true;
}
// The title character usually stay together.
return isFarAway(previousTextPosition, textPosition);
return (textPosition.getPageHeight() - textPosition.getYDirAdj())
< (textPosition.getPageHeight() * 0.1);
}

private Optional<String> findLargestFontText(List<TextPosition> textPositions) {
Map<Float, StringBuilder> fontSizeTextMap = new TreeMap<>(Collections.reverseOrder());
Map<Float, TextPosition> lastPositionMap = new TreeMap<>(Collections.reverseOrder());
TextPosition previousTextPosition = null;
for (TextPosition textPosition : textPositions) {
float fontSize = textPosition.getFontSizeInPt();
// Exclude unwanted text based on heuristics
if (isUnwantedText(previousTextPosition, textPosition)) {
if (isUnwantedText(previousTextPosition, textPosition) ||
(lastPositionMap.containsKey(fontSize) && isFarAway(lastPositionMap.get(fontSize), textPosition))) {
continue;
}
float fontSize = textPosition.getFontSizeInPt();
fontSizeTextMap.putIfAbsent(fontSize, new StringBuilder());
if (previousTextPosition != null && isThereSpace(previousTextPosition, textPosition)) {
fontSizeTextMap.get(fontSize).append(" ");
}
fontSizeTextMap.get(fontSize).append(textPosition.getUnicode());
lastPositionMap.put(fontSize, textPosition);
previousTextPosition = textPosition;
}
for (Map.Entry<Float, StringBuilder> entry : fontSizeTextMap.entrySet()) {
Expand Down
Loading

0 comments on commit aa95a25

Please sign in to comment.