Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/main' into di
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/jabref/gui/fieldeditors/optioneditors/OptionEditor.java
  • Loading branch information
calixtus committed Jun 16, 2024
2 parents 6f46e3e + 87a5df9 commit 81f6e48
Show file tree
Hide file tree
Showing 30 changed files with 284 additions and 407 deletions.
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plugins {

id 'idea'

id 'org.openrewrite.rewrite' version '6.15.1'
id 'org.openrewrite.rewrite' version '6.16.0'
}

// Enable following for debugging
Expand Down Expand Up @@ -155,7 +155,7 @@ dependencies {
exclude group: 'commons-logging'
}

def luceneVersion = "9.10.0"
def luceneVersion = "9.11.0"
implementation "org.apache.lucene:lucene-core:$luceneVersion"
implementation "org.apache.lucene:lucene-queryparser:$luceneVersion"
implementation "org.apache.lucene:lucene-queries:$luceneVersion"
Expand Down Expand Up @@ -187,7 +187,7 @@ dependencies {
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.1'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.17.1'

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

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

Expand Down Expand Up @@ -298,7 +298,7 @@ dependencies {

implementation 'commons-io:commons-io:2.16.1'

testImplementation 'io.github.classgraph:classgraph:4.8.172'
testImplementation 'io.github.classgraph:classgraph:4.8.173'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.2'

Expand All @@ -316,7 +316,7 @@ dependencies {
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.11.1"))
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.12.0"))
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
rewrite("org.openrewrite.recipe:rewrite-logging-frameworks")
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks")
Expand Down Expand Up @@ -532,6 +532,7 @@ tasks.withType(Test) {
reports.html.outputLocation.set(file("${reporting.baseDir}/${name}"))
// Enable parallel tests. See https://docs.gradle.org/8.1/userguide/performance.html#execute_tests_in_parallel for details.
maxParallelForks = Runtime.runtime.availableProcessors() - 1
ignoreFailures = true
}

tasks.register('databaseTest', Test) {
Expand Down
1 change: 1 addition & 0 deletions docs/code-howtos/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ On top of basic unit testing, there are more ways to test a software:
| Functional | Dynamics, black box, positive and negative | [JUnit-QuickCheck](https://github.com/pholser/junit-quickcheck) | Random data generation | No, not intended, because other test kinds seem more helpful. |
| Functional | Dynamics, black box, positive and negative | [GraphWalker](https://graphwalker.github.io) | Model-based | No, because the BibDatabase doesn't need to be tests |
| Functional | Dynamics, black box, positive and negative | [TestFX](https://github.com/TestFX/TestFX) | GUI Tests | Yes |
| Functional | Dynamics, black box, negative | [Lincheck](https://github.com/JetBrains/lincheck) | Testing concurrent algorithms | No |
| Functional | Dynamics, white box, negative | [PIT](https://pitest.org) | Mutation | No |
| Functional | Dynamics, white box, positive and negative | [Mockito](https://site.mockito.org) | Mocking | Yes |
| Non-functional | Dynamics, black box, positive and negative | [JETM](http://jetm.void.fm), [Apache JMeter](https://jmeter.apache.org) | Performance (performance testing vs load testing respectively) | No |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Click "OK" to store the changes.

## Configure the Build System

Navigate to **File > Settings... > Build, Execution, Deployment > Build Tools > Gradle** and select the "Project SDK" as the Gradle JVM at the bottom. If that does not exist, just select a JDK 21.
Navigate to **File > Settings... > Build, Execution, Deployment > Build Tools > Gradle** and select the "Project SDK" as the Gradle JVM at the bottom. If that does not exist, just select JDK 21.

{% figure caption:"Gradle JVM is project SDK (showing JDK 21 as example)" %}
![Gradle JVM is project SDK](guidelines-intellij-settings-gradle-gradlejvm-is-projectjvm.png)
Expand All @@ -66,14 +66,14 @@ Then double click inside the cell "Compilation options" and enter following para
```

Press <kbd>Enter</kbd> to have the value really stored.
Otherwise, it seems like the setting is stored, but it is not there if you re-open this preference dialog.
Otherwise, it seems like the setting is stored, but it is not there if you reopen this preference dialog.
Then click on "Apply" to store the setting.

{% figure caption:"Resulting settings for module JabRef.main" %}
![Overridden compiler parameters](guidelines-overridden-compiler-parameters.png)
{% endfigure %}

If this step is omited, you will get: `java: package com.sun.javafx.scene.control is not visible (package com.sun.javafx.scene.control is declared in module javafx.controls, which does not export it to module org.jabref)`.
If this step is omitted, you will get: `java: package com.sun.javafx.scene.control is not visible (package com.sun.javafx.scene.control is declared in module javafx.controls, which does not export it to module org.jabref)`.

Enable annotation processors by navigating to **Build, Execution, Deployment > Compiler > Annotation processors** and check "Enable annotation processing"

Expand All @@ -84,7 +84,7 @@ Enable annotation processors by navigating to **Build, Execution, Deployment > C
## Using Gradle from within IntelliJ IDEA

{: .note }
Ensuring JabRef builds with Gradle should always the first step because, e.g. it generates additional sources that are required for compiling the code.
Ensuring JabRef builds with Gradle should always be the first step because, e.g. it generates additional sources that are required for compiling the code.

Open the Gradle Tool Window with the small button that can usually be found on the right side of IDEA or navigate to **View > Tool Windows > Gradle**.
In the Gradle Tool Window, press the "Reload All Gradle Projects" button to ensure that all settings are up-to-date with the setting changes.
Expand All @@ -93,7 +93,7 @@ In the Gradle Tool Window, press the "Reload All Gradle Projects" button to ensu
![Highlighted reload button](guidelines-gradle-tool-windows-refresh.png)
{% endfigure %}

After that, you can use the Gradle Tool Window to build all parts JabRef and run it.
After that, you can use the Gradle Tool Window to build all parts of JabRef and run it.
To do so, expand the JabRef project in the Gradle Tool Window and navigate to Tasks.
From there, you can build and run JabRef by double-clicking **JabRef > Tasks > application > run**.

Expand All @@ -102,7 +102,7 @@ From there, you can build and run JabRef by double-clicking **JabRef > Tasks > a
{% endfigure %}

The Gradle run window opens, shows compilation and then the output of JabRef.
The spinner will run as long as JabRef is opened.
The spinner will run as long as JabRef is open.

{% figure caption:"Gradle run Window" %}
![Gradle run window](guidelines-gradle-run-output.png)
Expand All @@ -129,7 +129,7 @@ In case there are difficulties later, this is the place to switch back to gradle

Click "OK" to close the preference dialog.

In the menubar, select **Build > Rebuild project**.
In the menu bar, select **Build > Rebuild project**.

IntelliJ now compiles JabRef.
This should happen without any error.
Expand All @@ -143,7 +143,7 @@ To run an example test from IntelliJ, we let IntelliJ create a launch configurat
Locate the class `BibEntryTest`:
Press <kbd>Ctrl</kbd>+<kbd>N</kbd>.
Then, the "Search for classes dialog" pops up.
Enter `bibenrytest`.
Enter `bibentrytest`.
Now, `BibEntryTest` should appear first:

{% figure caption:"IntelliJ search for class “BibEntryTest”" %}
Expand Down Expand Up @@ -177,7 +177,7 @@ You can also click on the debug symbol next to it to enable stopping at breakpoi

The tests are green after the run.
You can also use the play button there to re-execute the tests.
A right-click on "BibEntryTests" enables to start the debugger.
A right-click on "BibEntryTests" enables the debugger to start.

{% figure caption:"Run window for the BibEntry test case" %}
![Run window for the BibEntry test case](guidelines-intellij-tests-are-green.png)
Expand Down
3 changes: 1 addition & 2 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
jq
jq.exe
*.bib

# python
*.pyc
Expand Down
58 changes: 43 additions & 15 deletions scripts/bib-file-generator.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
# Creates "large-library.bib" with 100k entries.

# The file is written in UTF8 and makes use of the unicode character U+0304 (https://www.compart.com/en/unicode/U+0304)
# to create an overline on large roman numbers using the technicue "Vinculum" (https://en.wikipedia.org/wiki/Roman_numerals#Vinculum).
# The numbers are used in the journal title.

# For pseudonymization BibTeX files, org.jabref.logic.pseudonymization.PseudonymizationTest#pseudonymizeLibraryFiley can be used.

number_of_entries = 100000
file = open("generatedDatabase.bib", 'w')

for i in range(number_of_entries):
entry = """@article{%i,
author = {%i},
title = {%i},
journal = {%i},
volume = {%i},
year = {%i},
pages = {%i},
}""" % (i, i, i, i, i, i, i)
file.write(entry)
file.flush()
file.close()
number_of_entries = 100_000

# Adapted from: https://stackoverflow.com/a/50012689/873282
def int_to_roman(num):
_values = [
1000000, 900000, 500000, 400000, 100000, 90000, 50000, 40000, 10000, 9000, 5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]

_strings = [
'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]

result = ""
decimal = num

while decimal > 0:
for i in range(len(_values)):
if decimal >= _values[i]:
if _values[i] > 1000:
result += u'\u0304'.join(list(_strings[i])) + u'\u0304'
else:
result += _strings[i]
decimal -= _values[i]
break
return result

with open("generated-large-library.bib", 'w', encoding='utf-8') as file:
for i in range(1, number_of_entries + 1):
year = 1900 + (i - 1) % (2025 - 1900)
entry = f"""@article{{id{i:06d},
title = {{This is my title{i}}},
author = {{FirstnameA{i} LastnameA{i} and FirstnameB{i} LastnameB{i} and FirstnameC{i} LastnameC{i}}},
journal = {{Journal Title {int_to_roman(i)}}},
volume = {{{i}}},
year = {{{year}}},
}}
"""
file.write(entry)
11 changes: 0 additions & 11 deletions scripts/bib-file-generator.rb

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 18 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.autocompleter.SuggestionProviders;
import org.jabref.gui.fieldeditors.identifier.IdentifierEditor;
import org.jabref.gui.fieldeditors.optioneditors.MonthEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.OptionEditor;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.CustomFieldEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.EditorTypeEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.GenderEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.PaginationEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.PatentTypeEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.TypeEditorViewModel;
import org.jabref.gui.fieldeditors.optioneditors.mapbased.YesNoEditorViewModel;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.journals.JournalAbbreviationRepository;
Expand Down Expand Up @@ -98,11 +107,16 @@ public static FieldEditorFX getForField(final Field field,
return new CitationKeyEditor(field, suggestionProvider, fieldCheckers, databaseContext);
} else if (fieldProperties.contains(FieldProperty.MARKDOWN)) {
return new MarkdownEditor(field, suggestionProvider, fieldCheckers, preferences, undoManager);
} else if (fieldProperties.contains(FieldProperty.CUSTOM_FIELD) && !isMultiLine) {
return new OptionEditor<>(new CustomFieldEditorViewModel(field, suggestionProvider, fieldCheckers, undoManager, databaseContext));
} else {
// default
return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isMultiLine, undoManager);
// There was no specific editor found

// Check whether there are selectors defined for the field at hand
List<String> selectorValues = databaseContext.getMetaData().getContentSelectorValuesForField(field);
if (!isMultiLine && !selectorValues.isEmpty()) {
return new OptionEditor<>(new CustomFieldEditorViewModel(field, suggestionProvider, fieldCheckers, undoManager, selectorValues));
} else {
return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isMultiLine, undoManager);
}
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit 81f6e48

Please sign in to comment.