diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 05c03a4594f..eee63f64018 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -257,7 +257,7 @@ jobs:
uses: unsplash/comment-on-pr@master
if: steps.authors_check.outputs.newauthor == 'true'
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN_COMMENT_ON_PR }}
with:
msg: "${{ steps.authors_check.outputs.message }}"
check_for_duplicate_msg: true
diff --git a/.idea/runConfigurations/JabRef_Main.xml b/.idea/runConfigurations/JabRef_Main.xml
index d57c0fd5ac5..f6e0ca898ae 100644
--- a/.idea/runConfigurations/JabRef_Main.xml
+++ b/.idea/runConfigurations/JabRef_Main.xml
@@ -1,9 +1,9 @@
-
+
-
+
@@ -13,4 +13,4 @@
-
\ No newline at end of file
+
diff --git a/.mailmap b/.mailmap
index a755a5d1806..b03046749ac 100644
--- a/.mailmap
+++ b/.mailmap
@@ -47,6 +47,7 @@ Frédéric Darboux
Frédéric Darboux
Frédéric Darboux
Frédéric Darboux
+Frédéric Darboux
Florian Straßer
Gregor Herrmann
Hakan Duran hakova
diff --git a/.markdownlint.yml b/.markdownlint.yml
index 3ed5b253fa6..0ada157fae9 100644
--- a/.markdownlint.yml
+++ b/.markdownlint.yml
@@ -13,6 +13,9 @@ MD013: false
MD026:
punctuation: ".,;:!"
+# not supported by gitbook
+MD031: false
+
MD033:
# we have tags with ids and superscript
allowed_elements: ['a', 'sup']
diff --git a/AUTHORS b/AUTHORS
index 3a8b70a713e..c57cec7736e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -119,6 +119,7 @@ Ethan Harris
Fabian Bauer
Fabian Bieker
Fabiani Giovanni
+Fabio Marcos
Fabrice Dessaint
Fancy Zhang
Fedor Bezrukov
@@ -223,6 +224,7 @@ Lucas Beretti
Luciana de Melo e Abud
Lugduni Desrosiers
Luis Romero
+m-mauersberger
Mairieli Wessel
Malik Atalla
Malte Deiseroth
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d12ff9edf47..ac4b929ca22 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+
# Changelog
All notable changes to this project will be documented in this file.
@@ -13,15 +14,29 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added a query parser and mapping layer to enable conversion of queries formulated in simplified lucene syntax by the user into api queries. [#6799](https://github.com/JabRef/jabref/pull/6799)
- We added some basic functionality to customise the look of JabRef by importing a css theme file. [#5790](https://github.com/JabRef/jabref/issues/5790)
+- We added connection check function in network preference setting [#6560](https://github.com/JabRef/jabref/issues/6560)
### Changed
+- We restructured the 'File' tab and extracted some parts into the 'Linked files' tab [#6779](https://github.com/JabRef/jabref/pull/6779)
- JabRef now offers journal lists from . JabRef the lists which use a dot inside the abbreviations. [#5749](https://github.com/JabRef/jabref/pull/5749)
+- We removed two useless preferences in the groups preferences dialog. [#6836](https://github.com/JabRef/jabref/pull/6836)
+- Synchronization of SpecialFields to keywords is now disabled by default. [#6621](https://github.com/JabRef/jabref/issues/6621)
+- JabRef no longer opens the entry editor with the first entry on startup [#6855](https://github.com/JabRef/jabref/issues/6855)
+- We completed the rebranding of `bibtexkey` as `citationkey` which was started in JabRef 5.1.
+- JabRef no longer opens the entry editor with the first entry on startup [#6855](https://github.com/JabRef/jabref/issues/6855)
+- Fetch by ID: (long) "SAO/NASA Astrophysics Data System" replaced by (short) "SAO/NASA ADS" [#6876](https://github.com/JabRef/jabref/pull/6876)
+- We changed the title of the window "Manage field names and content": to have the same title as the corresponding menu item [#6895](https://github.com/JabRef/jabref/pull/6895)
### Fixed
-### Removed
+- We fixed an issue changing the icon link_variation_off that is not meaningful. [#6834][https://github.com/JabRef/jabref/issues/6834]
+- We fixed an issue where the `.sav` file was not deleted upon exiting JabRef. [#6109](https://github.com/JabRef/jabref/issues/6109)
+- We fixed a linked identifier icon inconsistency. [#6705](https://github.com/JabRef/jabref/issues/6705)
+- We fixed the wrong behavior that font size changes are not reflected in dialogs. [#6039](https://github.com/JabRef/jabref/issues/6039)
+- We fixed an issue where the sort order of the entry table was reset after a restart of JabRef [#6898](https://github.com/JabRef/jabref/pull/6898)
+### Removed
## [5.1] – 2020-08-30
diff --git a/build.gradle b/build.gradle
index fb234d6534e..eeb02422810 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,10 +13,10 @@ plugins {
id 'application'
id "com.simonharrer.modernizer" version '2.1.0-1'
id 'me.champeau.gradle.jmh' version '0.5.1'
- id 'com.github.ben-manes.versions' version '0.29.0'
+ id 'com.github.ben-manes.versions' version '0.30.0'
id 'org.javamodularity.moduleplugin' version '1.7.0'
id 'org.openjfx.javafxplugin' version '0.0.9'
- id 'org.beryx.jlink' version '2.21.3'
+ id 'org.beryx.jlink' version '2.21.4'
// nicer test outputs during running and completion
// Homepage: https://github.com/radarsh/gradle-test-logger-plugin
@@ -46,7 +46,7 @@ java {
}
application {
- mainClassName = "$moduleName/org.jabref.JabRefLauncher"
+ mainClassName = "$moduleName/org.jabref.gui.JabRefLauncher"
}
// TODO: Ugly workaround to temporarily ignore build errors to dependencies of latex2unicode
@@ -105,8 +105,8 @@ dependencies {
// Include all jar-files in the 'lib' folder as dependencies
implementation fileTree(dir: 'lib', includes: ['*.jar'])
- implementation 'org.apache.pdfbox:pdfbox:2.0.20'
- implementation 'org.apache.pdfbox:fontbox:2.0.20'
+ implementation 'org.apache.pdfbox:pdfbox:2.0.21'
+ implementation 'org.apache.pdfbox:fontbox:2.0.21'
implementation 'org.apache.pdfbox:xmpbox:2.0.20'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.8'
@@ -137,7 +137,7 @@ dependencies {
antlr4 'org.antlr:antlr4:4.8-1'
implementation 'org.antlr:antlr4-runtime:4.8-1'
- implementation (group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.6.1') {
+ implementation (group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.6.2') {
exclude group: 'org.apache.lucene', module: 'lucene-sandbox'
}
@@ -207,9 +207,10 @@ dependencies {
testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.14'
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT'
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT'
- testImplementation 'org.mockito:mockito-core:3.5.7'
+ testImplementation 'org.mockito:mockito-core:3.5.10'
testImplementation 'org.xmlunit:xmlunit-core:2.7.0'
testImplementation 'org.xmlunit:xmlunit-matchers:2.7.0'
+ testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.14.1'
testImplementation 'com.tngtech.archunit:archunit-junit5-api:0.14.1'
testImplementation "org.testfx:testfx-core:4.0.17-alpha-SNAPSHOT"
testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT"
@@ -442,6 +443,11 @@ test {
excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest'
}
+ moduleOptions {
+ // TODO: Remove this as soon as archunit is modularized
+ runOnClasspath = true
+ }
+
testLogging {
// set options for log level LIFECYCLE
// for debugging tests: add "STANDARD_OUT", "STANDARD_ERROR"
diff --git a/buildres/linux/JabRef.desktop b/buildres/linux/JabRef.desktop
index c2aae778161..8bbaff35f2f 100644
--- a/buildres/linux/JabRef.desktop
+++ b/buildres/linux/JabRef.desktop
@@ -9,4 +9,4 @@ Type=Application
DESKTOP_MIMES
Categories=DEPLOY_BUNDLE_CATEGORY
Keywords=bibtex;biblatex;latex;bibliography
-StartupWMClass=org.jabref.JabRefMain
+StartupWMClass=org.jabref.gui.JabRefMain
diff --git a/docs/.gitbook/assets/eclipse-create-run-config (1) (1).png b/docs/.gitbook/assets/eclipse-create-run-config (1) (1).png
new file mode 100644
index 00000000000..1412291a55a
Binary files /dev/null and b/docs/.gitbook/assets/eclipse-create-run-config (1) (1).png differ
diff --git a/docs/.gitbook/assets/eclipse-create-run-config (1).png b/docs/.gitbook/assets/eclipse-create-run-config (1).png
new file mode 100644
index 00000000000..1412291a55a
Binary files /dev/null and b/docs/.gitbook/assets/eclipse-create-run-config (1).png differ
diff --git a/docs/.gitbook/assets/grafik (1) (1).png b/docs/.gitbook/assets/grafik (1) (1).png
new file mode 100644
index 00000000000..c3b7615fdda
Binary files /dev/null and b/docs/.gitbook/assets/grafik (1) (1).png differ
diff --git a/docs/.gitbook/assets/intellij-enable-annotation-processing.png b/docs/.gitbook/assets/intellij-enable-annotation-processing.png
new file mode 100644
index 00000000000..784ce6cd19e
Binary files /dev/null and b/docs/.gitbook/assets/intellij-enable-annotation-processing.png differ
diff --git a/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (1) (1).png b/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (1) (1).png
new file mode 100644
index 00000000000..30fd74bba1c
Binary files /dev/null and b/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (1) (1).png differ
diff --git a/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (2).png b/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (2).png
new file mode 100644
index 00000000000..203ad5ad207
Binary files /dev/null and b/docs/.gitbook/assets/intellij-gradle-config-ignore-buildSrc (2).png differ
diff --git a/docs/.gitbook/assets/intellij-wrap-at-right-margin.png b/docs/.gitbook/assets/intellij-wrap-at-right-margin.png
new file mode 100644
index 00000000000..c3b7615fdda
Binary files /dev/null and b/docs/.gitbook/assets/intellij-wrap-at-right-margin.png differ
diff --git a/docs/README.md b/docs/README.md
index 6fdbda908c2..096a6147596 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,6 +1,6 @@
# Overview on Developing
-This page presents all development informatation around JabRef.
+This page presents all development information around JabRef.
## Starting point for newcomers
@@ -37,23 +37,11 @@ Without jlink, it is not possible to generate a fat jar any more. During develop
Diagram showing aspects of groups: [Groups.uml](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/Groups.uml).
-## Decision Records
+## Architectural Decision Records
-This log lists the decisions for JabRef.
+[Architectural decisions for JabRef](adr.md) are recorded.
-* [ADR-0000](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0000-use-markdown-architectural-decision-records.md) - Use Markdown Architectural Decision Records
-* [ADR-0001](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0001-use-crowdin-for-translations.md) - Use Crowdin for translations
-* [ADR-0002](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0002-use-slf4j-for-logging.md) - Use slf4j together with log4j2 for logging
-* [ADR-0003](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0003-use-gradle-as-build-tool.md) - Use Gradle as build tool
-* [ADR-0004](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0004-use-mariadb-connector.md) - Use MariaDB Connector
-* [ADR-0005](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0005-fully-support-utf8-only-for-latex-files.md) - Fully Support UTF-8 Only For LaTeX Files
-* [ADR-0006](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0006-only-translated-strings-in-language-file.md) - Only translated strings in language file
-* [ADR-0007](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0007-human-readable-changelog.md) - Provide a human-readable changelog
-* [ADR-0008](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0008-use-public-final-instead-of-getters.md) - Use public final instead of getters to offer access to immutable variables
-* [ADR-0009](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0009-use-plain-junit5-for-testing.md) - Use Plain JUnit5 for advanced test assertions
-* [ADR-0010](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/0010-use-h2-as-internal-database.md) - Use H2 as Internal SQL Database
-
-For new ADRs, please use [template.md](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/template.md) as basis. More information on MADR is available at [https://adr.github.io/madr/](https://adr.github.io/madr/). General information about architectural decision records is available at [https://adr.github.io/](https://adr.github.io/).
+For new ADRs, please use [template.md](https://github.com/JabRef/jabref/tree/3b3716b1e05a0d3273c886e102a8efe5e96472e0/docs/adr/template.md) as basis. More information on MADR is available at [https://adr.github.io/madr/](https://adr.github.io/madr/). General information about architectural decision records is available at [https://adr.github.io/](https://adr.github.io/). Add them to the [list of architectural decision records](adr.md).
## FAQ
diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md
index a3836d7d6ba..a9d5917e5e9 100644
--- a/docs/SUMMARY.md
+++ b/docs/SUMMARY.md
@@ -13,6 +13,7 @@
* [Code Quality](advanced-reading/code-quality.md)
* [Recommendations for UI design](advanced-reading/ui-recommendations.md)
* [Custom SVG icons](advanced-reading/custom-svg-icons.md)
+ * [Working on fetchers](advanced-reading/fetchers.md)
* [Creating a binary and debug it](advanced-reading/jpackage.md)
* [JabRef and Software Engineering](teaching.md)
* [Readings on Coding](readings-on-coding/README.md)
diff --git a/docs/adr.md b/docs/adr.md
index 8c8e4783f47..3907e985781 100644
--- a/docs/adr.md
+++ b/docs/adr.md
@@ -1,6 +1,27 @@
# Architectural Decisions
-This directory contains the architectural decisions for JabRef.
+Architectural decisions for JabRef:
-For new ADRs, please use [template.md](https://github.com/JabRef/jabref/tree/98e9fc3ddc7b59ca35101c7f37b183ca2e69d8a0/docs/adr/template.md) as basis. More information on the used format is available at [https://adr.github.io/madr/](https://adr.github.io/madr/). General information about architectural decision records is available at [https://adr.github.io/](https://adr.github.io/).
+* [ADR-0000](https://github.com/JabRef/jabref/tree/docs/adr/0000-use-markdown-architectural-decision-records.md) - Use Markdown Architectural Decision Records
+* [ADR-0001](https://github.com/JabRef/jabref/tree/docs/adr/0001-use-crowdin-for-translations.md) - Use Crowdin for translations
+* [ADR-0002](https://github.com/JabRef/jabref/tree/docs/adr/0002-use-slf4j-for-logging.md) - Use slf4j together with log4j2 for logging
+* [ADR-0003](https://github.com/JabRef/jabref/tree/docs/adr/0003-use-gradle-as-build-tool.md) - Use Gradle as build tool
+* [ADR-0004](https://github.com/JabRef/jabref/tree/docs/adr/0004-use-mariadb-connector.md) - Use MariaDB Connector
+* [ADR-0005](https://github.com/JabRef/jabref/tree/docs/adr/0005-fully-support-utf8-only-for-latex-files.md) - Fully Support UTF-8 Only For LaTeX Files
+* [ADR-0006](https://github.com/JabRef/jabref/tree/docs/adr/0006-only-translated-strings-in-language-file.md) - Only translated strings in language file
+* [ADR-0007](https://github.com/JabRef/jabref/tree/docs/adr/0007-human-readable-changelog.md) - Provide a human-readable changelog
+* [ADR-0008](https://github.com/JabRef/jabref/tree/docs/adr/0008-use-public-final-instead-of-getters.md) - Use public final instead of getters to offer access to immutable variables
+* [ADR-0009](https://github.com/JabRef/jabref/tree/docs/adr/0009-use-plain-junit5-for-testing.md) - Use Plain JUnit5 for advanced test assertions
+* [ADR-0010](https://github.com/JabRef/jabref/tree/docs/adr/0010-use-h2-as-internal-database.md) - Use H2 as Internal SQL Database
+* [ADR-0011](https://github.com/JabRef/jabref/tree/docs/adr/0011-test-external-links-in-documentation.md) - Test external links in documentation
+* [ADR-0012](https://github.com/JabRef/jabref/tree/docs/adr/0012-handle-different-bibEntry-formats-of-fetchers.md) - Handle different bibentry formats of fetchers by adding a layer
+* [ADR-0013](https://github.com/JabRef/jabref/tree/docs/adr/0013-add-native-support-biblatex-software.md) - Add Native Support for BibLatex-Sotware
+fix checkstyle in adr
+* [ADR-0014](https://github.com/JabRef/jabref/tree/docs/adr/0014-separate-URL-creation-to-enable-proper-logging.md) - Separate URL creation to enable proper logging
+* [ADR-0015](https://github.com/JabRef/jabref/tree/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md) - Query syntax design
+* [ADR-0016](https://github.com/JabRef/jabref/tree/docs/adr/0016-mutable-preferences-objects.md) - Mutable preferences objects
+* [ADR-0017](https://github.com/JabRef/jabref/tree/docs/adr/0017-allow-model-access-logic.md) - Allow org.jabref.model to access org.jabref.logic
+
+
+For new ADRs, please use [template.md](https://github.com/JabRef/jabref/tree/98e9fc3ddc7b59ca35101c7f37b183ca2e69d8a0/docs/adr/template.md) as basis. More information on the used format is available at [https://adr.github.io/madr/](https://adr.github.io/madr/). General information about architectural decision records is available at [https://adr.github.io/](https://adr.github.io/). Then add them to the above list.
diff --git a/docs/adr/0003-use-gradle-as-build-tool.md b/docs/adr/0003-use-gradle-as-build-tool.md
index 81000f31444..5dac1018032 100644
--- a/docs/adr/0003-use-gradle-as-build-tool.md
+++ b/docs/adr/0003-use-gradle-as-build-tool.md
@@ -38,7 +38,7 @@ Chosen option: "Gradle", because it is lean and fits our development style.
* Good, because [it offers custom dependency scopes](https://gradle.org/maven-vs-gradle/)
* Good, because [it has good community support](https://linuxhint.com/ant-vs-maven-vs-gradle/)
* Good, because [its performance can be 100 times more than maven's performance](https://gradle.org/gradle-vs-maven-performance/).
-* Bad, because [not that many plugins are available/maintained yet](https://blog.philipphauer.de/moving-back-from-gradle-to-maven/)
+* Bad, because [not that many plugins are available/maintained yet](https://phauer.com/2018/moving-back-from-gradle-to-maven/)
* Bad, because [it lacks a wide variety of application server integrations](http://pages.zeroturnaround.com/rs/zeroturnaround/images/java-build-tools-part-2.pdf)
* Bad, because [it has a medium popularity](http://pages.zeroturnaround.com/rs/zeroturnaround/images/java-build-tools-part-2.pdf)
* Bad, because [it allows custom build scripts which need to be debugged](https://www.softwareyoga.com/10-reasons-why-we-chose-maven-over-gradle/)
diff --git a/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md b/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md
index cb6a8f214fa..f25f161c2ff 100644
--- a/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md
+++ b/docs/adr/0015-support-an-abstract-query-syntax-for-query-conversion.md
@@ -27,10 +27,23 @@ For simplicitly, and lack of universal capabilities across fetchers, only basic
* `year` (for single year)
* `year-range` (for range e.g. `year-range:2012-2015`)
* The `journal`, `year`, and `year-range` fields should only be populated once in each query
+* The `year` and `year-range` fields are mutually exclusive
* Example:
* `author:"Igor Steinmacher" author:"Christoph Treude" year:2017` will be converted to
* `author:"Igor Steinmacher" AND author:"Christoph Treude" AND year:2017`
+The supported syntax can be expressed in EBNF as follows:
+
+Query := {Clause} \
+Clause:= \[Field\] Term \
+Field := author: | title: | journal: | year: | year-range: | default:\
+Term := Word | Phrase \
+
+Word can be derived to any series of non-whitespace characters.
+Phrases are multiple words wrapped in quotes and may contain white-space characters within the quotes.\
+Note: Even though this EBNF syntactically allows the creation of queries with year and year-range fields,
+such a query does not make sense semantically and therefore will not be executed.
+
### Positive Consequences
* Already tested
diff --git a/docs/adr/0016-mutable-preferences-objects.md b/docs/adr/0016-mutable-preferences-objects.md
new file mode 100644
index 00000000000..6abb70af9c1
--- /dev/null
+++ b/docs/adr/0016-mutable-preferences-objects.md
@@ -0,0 +1,16 @@
+# Mutable preferences objects
+
+## Context and Problem Statement
+
+To create an immutable preferences object every time seems to be a waste of time and computer memory.
+
+## Considered Options
+
+* Create a new object every time a preferences object should be altered by a with*-method, similar to a builder.
+* Alter the existing object and return it.
+
+## Decision Outcome
+
+Chosen option: "Alter the exiting object", because the preferences objects are just wrappers around the basic preferences framework of JDK. They
+should be mutable on-the-fly similar to objects with a Builder inside and to be stored immediatly again in the
+preferences.
diff --git a/docs/adr/0017-allow-model-access-logic.md b/docs/adr/0017-allow-model-access-logic.md
new file mode 100644
index 00000000000..5567fe198d4
--- /dev/null
+++ b/docs/adr/0017-allow-model-access-logic.md
@@ -0,0 +1,40 @@
+# Allow org.jabref.model to access org.jabref.logic
+
+## Context and Problem Statement
+
+- How to create a maintainable architecture?
+- How to split model, logic, and UI
+
+## Decision Drivers
+
+- New comers should find the architecture "split" natural
+- The architecture should be a help (and not a burden)
+
+## Considered Options
+
+- `org.jabref.model` uses `org.jabref.model` (and external libraries) only
+- `org.jabref.model` may use `org.jabref.logic` in defined cases
+- `org.jabref.model` and `org.jabref.logic` may access each other freely
+
+## Decision Outcome
+
+Chosen option: "`org.jabref.model` may use `org.jabref.logic` in defined cases", because comes out best \(see below\).
+
+## Pros and Cons of the Options
+
+### `org.jabref.model` uses `org.jabref.model` (and external libraries) only
+
+- Good, because clear separation of model and logic
+- Bad, because this leads to an [Anemic Domain Model](https://martinfowler.com/bliki/AnemicDomainModel.html)
+
+### `org.jabref.model` may use `org.jabref.logic` in defined cases
+
+- Good, because model and logic are still separated
+- Neutral, because each exception has to be discussed and agreed
+- Bad, because new comers have to be informed that there are certain (agreed) exceptions for model to access logic
+
+### `org.jabref.model` and `org.jabref.logic` may access each other freely
+
+- Bad, because may lead to spaghetti code
+- Bad, because coupling between model and logic is increased
+- Bad, because cohesion inside model is decreased
diff --git a/docs/adr/template.md b/docs/adr/template.md
index b07f46e2eb0..b4974469854 100644
--- a/docs/adr/template.md
+++ b/docs/adr/template.md
@@ -1,73 +1,67 @@
-# \[short title of solved problem and solution\]
+# MADR Templae
-* Status: \[proposed \| rejected \| accepted \| deprecated \| … \| superseded by [ADR-0005](0005-fully-support-utf8-only-for-latex-files.md)\]
-* Deciders: \[list everyone involved in the decision\]
-* Date: \[YYYY-MM-DD when the decision was last updated\]
+The template of [MADR](https://adr.github.io/madr/) is available at .
+You can omit the `<-- optional -->` parts, which lead to a very minimal ADR:
-Technical Story: \[description \| ticket/issue URL\]
+```markdown
+# [short title of solved problem and solution]
## Context and Problem Statement
-\[Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.\]
-
-## Decision Drivers
-
-* \[driver 1, e.g., a force, facing concern, …\]
-* \[driver 2, e.g., a force, facing concern, …\]
-* …
+[Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]
## Considered Options
-* \[option 1\]
-* \[option 2\]
-* \[option 3\]
-* …
+* [option 1]
+* [option 2]
+* [option 3]
+* …
## Decision Outcome
-Chosen option: "\[option 1\]", because \[justification. e.g., only option, which meets k.o. criterion decision driver \| which resolves force force \| … \| comes out best \(see below\)\].
-
-### Positive Consequences
+Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … ].
+```
-* \[e.g., improvement of quality attribute satisfaction, follow-up decisions required, …\]
-* …
+In case you want to include the pros and cons of the options, the template is as follows:
-### Negative Consequences
+```markdown
+# [short title of solved problem and solution]
-* \[e.g., compromising quality attribute, follow-up decisions required, …\]
-* …
-
-## Pros and Cons of the Options
+## Context and Problem Statement
-### \[option 1\]
+[Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]
-\[example \| description \| pointer to more information \| …\]
+## Considered Options
-* Good, because \[argument a\]
-* Good, because \[argument b\]
-* Bad, because \[argument c\]
-* …
+* [option 1]
+* [option 2]
+* [option 3]
+* …
-### \[option 2\]
+## Decision Outcome
-\[example \| description \| pointer to more information \| …\]
+Chosen option: "[option 1]", because comes out best (see below).
-* Good, because \[argument a\]
-* Good, because \[argument b\]
-* Bad, because \[argument c\]
-* …
+## Pros and Cons of the Options
-### \[option 3\]
+### [option 1]
-\[example \| description \| pointer to more information \| …\]
+* Good, because [argument a]
+* Good, because [argument b]
+* Bad, because [argument c]
+* …
-* Good, because \[argument a\]
-* Good, because \[argument b\]
-* Bad, because \[argument c\]
-* …
+### [option 2]
-## Links
+* Good, because [argument a]
+* Good, because [argument b]
+* Bad, because [argument c]
+* …
-* \[Link type\] \[Link to ADR\]
-* …
+### [option 3]
+* Good, because [argument a]
+* Good, because [argument b]
+* Bad, because [argument c]
+* …
+```
diff --git a/docs/advanced-reading/fetchers.md b/docs/advanced-reading/fetchers.md
index 47448f8daec..b9310a4f0d5 100644
--- a/docs/advanced-reading/fetchers.md
+++ b/docs/advanced-reading/fetchers.md
@@ -1,30 +1,24 @@
# Working on fetchers
-Fetchers are the implementation of the [search using online services](https://docs.jabref.org/collect/import-using-online-bibliographic-database).
-Some fetchers require API keys to get them working.
-To get the fetchers running in a JabRef development setup, the keys need to be placed in the respective enviornment variable.
-The following table lists the respective fetchers, where to get the key from and the environment variable where the key has to be placed.
+Fetchers are the implementation of the [search using online services](https://docs.jabref.org/collect/import-using-online-bibliographic-database). Some fetchers require API keys to get them working. To get the fetchers running in a JabRef development setup, the keys need to be placed in the respective enviornment variable. The following table lists the respective fetchers, where to get the key from and the environment variable where the key has to be placed.
| Service | Key Source | Environment Variable | Rate Limit |
-| -- | -- | -- | -- |
+| :--- | :--- | :--- | :--- |
| [IEEEXplore](https://docs.jabref.org/collect/import-using-online-bibliographic-database/ieeexplore) | [IEEE Xplore API portal](https://developer.ieee.org/) | `IEEEAPIKey` | 200 calls/day |
-| [MathSciNet](http://www.ams.org/mathscinet) | (none) | (none) | Depending on the current network |
+| [MathSciNet](http://www.ams.org/mathscinet) | \(none\) | \(none\) | Depending on the current network |
| [SAO/NASA Astrophysics Data System](https://docs.jabref.org/collect/import-using-online-bibliographic-database/ads) | [ADS UI](https://ui.adsabs.harvard.edu/user/settings/token) | `AstrophysicsDataSystemAPIKey` | 5000 calls/day |
-| [Springer Nature](https://docs.jabref.org/collect/import-using-online-bibliographic-database/springer) | [Springer Nature API Portal](https://dev.springernature.com/) | `SpringerNatureAPIKey`| 5000 calls/day |
-| [Zentralblatt Math](https://www.zbmath.org/) | (none) | (none) | Depending on the current network |
+| [Springer Nature](https://docs.jabref.org/collect/import-using-online-bibliographic-database/springer) | [Springer Nature API Portal](https://dev.springernature.com/) | `SpringerNatureAPIKey` | 5000 calls/day |
+| [Zentralblatt Math](https://www.zbmath.org/) | \(none\) | \(none\) | Depending on the current network |
-"Depending on the current network" means that it depends whether your request is routed through a network having paid access.
-For instance, some universities have subscriptions to MathSciNet.
+"Depending on the current network" means that it depends whether your request is routed through a network having paid access. For instance, some universities have subscriptions to MathSciNet.
-On Windows, you have to log-off and log-on to let IntelliJ know about the environment variable change.
-Execute the gradle task "processResources" in the group "others" within IntelliJ to ensure the values have been correctly written.
-Now, the fetcher tests should run without issues.
+On Windows, you have to log-off and log-on to let IntelliJ know about the environment variable change. Execute the gradle task "processResources" in the group "others" within IntelliJ to ensure the values have been correctly written. Now, the fetcher tests should run without issues.
## Background on embedding the keys in JabRef
The keys are placed into the `build.properties` file.
-```properties
+```text
springerNatureAPIKey=${springerNatureAPIKey}
```
@@ -40,6 +34,5 @@ The `BuildInfo` class reads from that file.
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.
+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.
+
diff --git a/docs/advanced-reading/jpackage.md b/docs/advanced-reading/jpackage.md
index 48f9aa88e45..709c97b0447 100644
--- a/docs/advanced-reading/jpackage.md
+++ b/docs/advanced-reading/jpackage.md
@@ -28,7 +28,7 @@ Sometimes issues with modularity only arise in the installed version and do not
3. Modify the `build\image\JabRef\runtime\bin\Jabref.bat` file, replace the last line with
```text
- pushd %DIR% & %JAVA_EXEC% -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -p "%~dp0/../app" -m org.jabref/org.jabref.JabRefLauncher %* & popd
+ pushd %DIR% & %JAVA_EXEC% -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -p "%~dp0/../app" -m org.jabref/org.jabref.gui.JabRefLauncher %* & popd
```
4. Open your IDE and add a "Remote Debugging Configuration" for `localhost:8000`
diff --git a/docs/getting-into-the-code/code-howtos.md b/docs/getting-into-the-code/code-howtos.md
index 512d78ad64d..b1e0ca97980 100644
--- a/docs/getting-into-the-code/code-howtos.md
+++ b/docs/getting-into-the-code/code-howtos.md
@@ -22,15 +22,14 @@ Principles:
* Catch and wrap all API exceptions \(such as `IOExceptions`\) and rethrow them
* Example:
- ```java
+ ```java
try {
// ...
} catch (IOException ioe) {
throw new JabRefException("Something went wrong...",
Localization.lang("Something went wrong...", ioe);
}
- ```
-
+ ```
* Never, ever throw and catch `Exception` or `Throwable`
* Errors should only be logged when they are finally caught \(i.e., logged only once\). See **Logging** for details.
* If the Exception message is intended to be shown to the User in the UI \(see below\) provide also a localizedMessage \(see `JabRefException`\).
@@ -52,7 +51,7 @@ TODO: Usage of status bar and Swing Dialogs
## Using the EventSystem
-### What the EventSystem is used for?
+### What the EventSystem is used for
Many times there is a need to provide an object on many locations simultaneously. This design pattern is quite similar to Java's Observer, but it is much simplier and readable while having the same functional sense.
diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md
index 429742ea298..9bac648c0e7 100644
--- a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md
+++ b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md
@@ -56,7 +56,7 @@ It is strongly recommend that you have git installed.
We suggest [IntelliJ IDEA](https://www.jetbrains.com/idea/) or [Eclipse \(for advanced users\)](https://eclipse.org/) \(`2020-03` or newer\).
-Under Ubuntu Linux, you can follow the [documentation from the Ubuntu Community](https://help.ubuntu.com/community/EclipseIDE#Download_Eclipse) or the [step-by-step guideline from Krizna](https://www.krizna.com/ubuntu/install-eclipse-in-ubuntu-12-04/) to install Eclipse. Under Windows, download it from [www.eclipse.org](http://www.eclipse.org/downloads/) and run the installer.
+On Ubuntu Linux, you can follow the [documentation from the Ubuntu Community](https://help.ubuntu.com/community/EclipseIDE#Download_Eclipse) or the [step-by-step guideline from Krizna](https://www.krizna.com/ubuntu/install-eclipse-in-ubuntu-12-04/) to install Eclipse. Under Windows, download it from [www.eclipse.org](http://www.eclipse.org/downloads/) and run the installer.
### Other Tooling
@@ -88,26 +88,22 @@ These steps are very important. They allow you to focus on the content and ensur
### Setup for IntelliJ IDEA
-IntelliJ IDEA fully supports Gradle as a build tool, but also has an internal build system which is usually faster. For JabRef, Gradle is required to make a full build but once set up, IntelliJ IDEA's internal system can be used for sub-sequent builds.
+We recommend to install IntelliJ IDEA using [JetBrains Toolbox App](https://www.jetbrains.com/toolbox-app/), because IDE updates are automatically installed.
-To configure IntelliJ IDEA for developing JabRef, you should first ensure that you have enabled both bundled plugins _Gradle_ and _Gradle Extension_
+IntelliJ IDEA fully supports Gradle as a build tool, but also has an internal build system which is usually faster. For JabRef, Gradle is required to make a full build but once set up, IntelliJ IDEA's internal system can be used for sub-sequent builds.
-* Navigate to **File \| Settings \| Plugins \| Installed** and check that you have
+To configure IntelliJ IDEA for developing JabRef, you should first ensure that you have enabled both bundled plugins _Gradle_ and _Gradle Extension_:
- the _Gradle_ and _Gradle Extension_ enabled.
+* Navigate to **File \| Settings \| Plugins \| Installed** and check that you have the _Gradle_ and _Gradle Extension_ enabled.
After that, you can open `jabref/build.gradle` as a project. It is crucial that Java 14 is used consistently for the JabRef project which includes ensuring the right settings for your project structure, Gradle build, and run configurations.
-* Ensure you have a Java 14 SDK configured by navigating to
-
- **File \| Project Structure \| Platform Settings \| SDKs**. If you don't have one, add a new Java JDK and point it to the
-
- location of a JDK 14.
+Ensure you have a Java 14 SDK configured by navigating to **File \| Project Structure \| Platform Settings \| SDKs**. If you don't have one, add a new Java JDK and point it to the location of a JDK 14:
* Navigate to **File \| Project Structure \| Project** and ensure that the projects' SDK is Java 14
* Navigate to **File \| Settings \| Build, Execution, Deployment \| Build Tools \| Gradle** and select the Java 14 SDK as the Gradle JVM at the bottom.
-To prepare IntelliJ's build system two additional steps are required
+To prepare IntelliJ's build system two additional steps are required:
* Navigate to **File \| Settings \| Build, Execution, Deployment \| Compiler \| Java Compiler**, and under "Override compiler parameters per-module" add \(\[+\]\) the following compiler arguments for the `JabRef.main` module:
@@ -118,16 +114,20 @@ To prepare IntelliJ's build system two additional steps are required
* Enable annotation processors by navigating to **File \| Settings \| Build, Execution, Deployment \| Compiler \| Annotation processors** and check "Enable annotation processing"
+ ![Enable annotation processing](../.gitbook/assets/intellij-enable-annotation-processing.png)
+
To have autoformat working properly in the context of line wrapping, "Wrap at right margin" has to be disabled as shown below. Details are found in [IntelliJ issue 240517](https://youtrack.jetbrains.com/issue/IDEA-240517).
-![Disable wrapping at right margin to prevent JavaDoc to be wrapped](../.gitbook/assets/grafik%20%281%29.png)
+![Disable wrapping at right margin to prevent JavaDoc to be wrapped](../.gitbook/assets/intellij-wrap-at-right-margin.png)
#### Using Gradle from within IntelliJ IDEA
Ensuring JabRef builds with Gradle should always the first step because, e.g. it generates additional sources that are required for compiling the code. After adjusting all settings mentioned earlier, your first step should be to
* 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 "Reimport All Gradle Projects" button to ensure that all settings are up-to-date with the setting changes.
+* 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.
After that, you can use the Gradle Tool Window to build all parts JabRef and run it. To do so, expand the JabRef project in the Gradle Tool Window and navigate to Tasks. From there, you can
@@ -137,6 +137,8 @@ After that a new entry called "jabref \[run\]" will appear in the run configurat
#### Using IntelliJ's internal build system
+**Note that these steps do not work on IntelliJ 2020.x.**. You have to keep using gradle for executing tasks. See [IDEA-249391](https://youtrack.jetbrains.com/issue/IDEA-249391) for details.
+
You should use IntelliJ IDEA's internal build system for compiling and running JabRef during development, because it is usually more responsive. Thereby, **it's important** that you understand that JabRef relies on generated sources which are only build through Gradle. Therefore, to build or update these dependencies you need to run the `assemble` Gradle task at least once.
To use IntelliJ IDEA's internal build system when you build JabRef through **Build \| Build Project** or use the provided "JabRef Main" run configuration, ensure that
@@ -144,37 +146,39 @@ To use IntelliJ IDEA's internal build system when you build JabRef through **Bui
* In **File \| Settings \| Build, Execution, Deployment \| Build Tools \| Gradle** the setting "Build and run using" and "Test using" is set to "IntelliJ IDEA".
* Ignore the Gradle project "buildSrc" by clicking the button **Select Project Data To Import** in the Gradle Tool Window and unchecking the folder "buildSrc".
- ![Ignore the Gradle project "buildSrc"](../.gitbook/assets/intellij-gradle-config-ignore-buildSrc%20%281%29.png)
+ ![Ignore the Gradle project "buildSrc"](../.gitbook/assets/intellij-gradle-config-ignore-buildSrc%20%282%29.png)
+
+* Delete `org.jabref.gui.logging.plugins.Log4jPlugins` \(location: `generated\org\jabref\gui\logging\plugins\Log4jPlugins.java`\). Otherwise, you will see folowing error:
+
+ ```text
+ Error:java: Unable to create Plugin Service Class org.jabref.gui.logging.plugins.Log4jPlugins
+ ```
+
+ or following error:
+
+ ```text
+ Error:(16, 25) java: package org.jabref.search does not exist
+ ```
Essentially, you now have the best of both worlds: You can run Gradle tasks using the Gradle Tool Window and unless you haven't made changes to input files that generate sources, you can compile and run with IntelliJ's faster internal build system.
+In case all steps are followed, and there are still issues with `SearchBaseVisitor` \(e.g., `Error:(16, 25) java: package org.jabref.search does not exist`\), you have to delete `generated\org\jabref\gui\logging\plugins\Log4jPlugins.java`. This is independet of having enabled or disabled Annotation Processing \(see above at "Enable Annotation Processing"\).
+
#### Using JabRef's code style
Contributions to JabRef's source code need to have a code formatting that is consistent with existing source code. For that purpose, JabRef provides code-style and check-style definitions.
* Install the [CheckStyle-IDEA plugin](http://plugins.jetbrains.com/plugin/1065?pr=idea), it can be found via the plug-in repository:
-
- 1. Navigate to **File \| Settings \| Plugins \| Marketplace** and search for "Checkstyle" and choose "CheckStyle-IDEA"
- 2. Close the settings afterwards and restart IntelliJ
-
+ 1. Navigate to **File \| Settings \| Plugins \| Marketplace** and search for "Checkstyle" and choose "CheckStyle-IDEA"
+ 2. Close the settings afterwards and restart IntelliJ
* Go to **File \| Settings \| Editor \| Code Style**
* Click on the settings wheel \(next to the scheme chooser\), then click "Import Scheme"
* Select the IntelliJ configuration file `config/IntelliJ Code Style.xml`
-* Go to **File \| Settings \| Tools \| Checkstyle \| Configuration File**
-
- 1. Import the CheckStyle configuration file by clicking the \[+\] button
- 2. For the description provide "JabRef"
- 3. Click "Browse" and choose `config/checkstyle/checkstyle.xml`
- 4. Click "Next" and "Finish"
- 5. Activate the CheckStyle configuration file by ticking it in the list
- 6. Ensure that the [latest CheckStyle version](https://checkstyle.org/releasenotes.html) is selected \(8.36 or higher\). 8.36 is required for Java 14.
- 7. Set the "Scan Scope" to "Only Java sources \(including tests\)
- 8. Save settings by clicking "OK"
- 9. Your configuration should now look like this:
-
- ```text
- ![checkstyle settings](../.gitbook/assets/intellij-checkstyle-settings.png)
- ```
+* Go to **File \| Settings \| Tools \| Checkstyle \| Configuration File** 1. Import the CheckStyle configuration file by clicking the \[+\] button 2. For the description provide "JabRef" 3. Click "Browse" and choose `config/checkstyle/checkstyle.xml` 4. Click "Next" and "Finish" 5. Activate the CheckStyle configuration file by ticking it in the list 6. Ensure that the [latest CheckStyle version](https://checkstyle.org/releasenotes.html) is selected \(8.36 or higher\). 8.36 is required for Java 14. 7. Set the "Scan Scope" to "Only Java sources \(including tests\) 8. Save settings by clicking "OK" 9. Your configuration should now look like this:
+
+ ```text
+ ![checkstyle settings](../.gitbook/assets/intellij-checkstyle-settings.png)
+ ```
### Setup for Eclipse
@@ -188,10 +192,10 @@ Make sure your Eclipse installation us up to date, Eclipse JEE 2020-03 or newer
3. Open or import the existing project in Eclipse as Java project.
* Remark: Importing it as gradle project will not work correctly.
* Refresh the project in Eclipse
-4. Create a run/debug configuration for the main class `org.jabref.JabRefLauncher` and/or for `org.jabref.JabRefMain` \(both can be used equivalently\)
+4. Create a run/debug configuration for the main class `org.jabref.gui.JabRefLauncher` and/or for `org.jabref.gui.JabRefMain` \(both can be used equivalently\)
* Remark: The run/debug configuration needs to be added by right clicking the class \(e.g. JabRefLauncher or JabRefMain\) otherwise it will not work.
- ![Creating the run/debug configuration by right clicking on the class](../.gitbook/assets/eclipse-create-run-config.png)
+ ![Creating the run/debug configuration by right clicking on the class](../.gitbook/assets/eclipse-create-run-config%20%281%29%20%281%29.png)
* In the tab "Arguments" of the run/debug configuration, enter the following runtime VM arguments:
@@ -213,6 +217,7 @@ Make sure your Eclipse installation us up to date, Eclipse JEE 2020-03 or newer
--add-exports javafx.web/com.sun.webkit=org.controlsfx.controls
--add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls
--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix
+ --add-exports javafx.graphics/com.sun.javafx.stage=com.jfoenix
--add-exports com.oracle.truffle.regex/com.oracle.truffle.regex=org.graalvm.truffle
--patch-module org.jabref=build/resources/main
```
diff --git a/docs/getting-into-the-code/high-level-documentation.md b/docs/getting-into-the-code/high-level-documentation.md
index eb4d80521db..84e5295ae70 100644
--- a/docs/getting-into-the-code/high-level-documentation.md
+++ b/docs/getting-into-the-code/high-level-documentation.md
@@ -35,5 +35,5 @@ All packages and classes which are currently not part of these packages \(we are
## Most Important Classes and their Relation
-Both GUI and CLI are started via the `JabRefMain` which will in turn call `JabRef` which then decides whether the GUI \(`JabRefFrame`\) or the CLI \(`JabRefCLI` and a lot of code in `JabRef`\) will be started. The `JabRefFrame` represents the Window which contains a `SidePane` on the left used for the fetchers/groups Each tab is a `BasePanel` which has a `SearchBar` at the top, a `MainTable` at the center and a `PreviewPanel` or an `EntryEditor` at the bottom. Any right click on the `MainTable` is handled by the `RightClickMenu`. Each `BasePanel` holds a `BibDatabaseContext` consisting of a `BibDatabase` and the `MetaData`, which are the only relevant data of the currently shown database. A `BibDatabase` has a list of `BibEntries`. Each `BibEntry` has a key, a bibtex key and a key/value store for the fields with their values. Interpreted data \(such as the type or the file field\) is stored in the `TypedBibentry` type. The user can change the `JabRefPreferences` through the `PreferencesDialog`.
+Both GUI and CLI are started via the `JabRefMain` which will in turn call `JabRef` which then decides whether the GUI \(`JabRefFrame`\) or the CLI \(`JabRefCLI` and a lot of code in `JabRef`\) will be started. The `JabRefFrame` represents the Window which contains a `SidePane` on the left used for the fetchers/groups Each tab is a `BasePanel` which has a `SearchBar` at the top, a `MainTable` at the center and a `PreviewPanel` or an `EntryEditor` at the bottom. Any right click on the `MainTable` is handled by the `RightClickMenu`. Each `BasePanel` holds a `BibDatabaseContext` consisting of a `BibDatabase` and the `MetaData`, which are the only relevant data of the currently shown database. A `BibDatabase` has a list of `BibEntries`. Each `BibEntry` has an ID, a citation key and a key/value store for the fields with their values. Interpreted data \(such as the type or the file field\) is stored in the `TypedBibentry` type. The user can change the `JabRefPreferences` through the `PreferencesDialog`.
diff --git a/docs/teaching.md b/docs/teaching.md
index 5c6d408cc84..41017b7a257 100644
--- a/docs/teaching.md
+++ b/docs/teaching.md
@@ -12,8 +12,13 @@ We recommend to start early and constantly, since students working earlier and m
2. Be aware that from the first pull request to the final acceptance the typical time needed is two weeks.
3. Be aware that JabRef tries to achieve high code quality. This leads to code reviews requiring actions from the contributors. This also applies for code of students. Read on at our [Development Strategy](getting-into-the-code/development-strategy.md) for more details.
4. Choose tasks from one of the following boards. Write a comment on each issue so that it can be reserved for your course.
+ * Candidates for university projects: [https://github.com/JabRef/jabref/projects/9](https://github.com/JabRef/jabref/projects/9)
+ * This board categorizes in small, medium, and large features
* Feature Board: [https://github.com/JabRef/jabref/projects/7](https://github.com/JabRef/jabref/projects/7)
+ * This is a general feature board. Recommended, if the board above is empty or you did not find something suitable
* Bug Board: [https://github.com/JabRef/jabref/projects/5](https://github.com/JabRef/jabref/projects/5)
+ * This is an excellent board to find issues training the maintainance knowledge which is essential for industry work
+ * General "good first issues". The JabRef team tags issues as [good first issues](https://github.com/jabref/jabref/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) to indicate open tasks offering a good start into the JabRef code. These issues are more a list of random bugs and features. For a more structured comparison of the opened tasks, we recommend the projectd boards listed above.
5. Be aware that the difficulty of bugs and feature vary. A task should be chosen with care. The JabRef team can help here: The majority of the team has experiences in teaching
6. Get in touch with the JabRef team to discuss details. We offer email, skype, [gitter.im](https://gitter.im/JabRef/jabref), discord. Get in touch with [@koppor](https://github.com/koppor/) to find the right channel and to start forming the success of your course.
diff --git a/mlc_config.json b/mlc_config.json
index 91ac75cfd09..4ad20beb329 100644
--- a/mlc_config.json
+++ b/mlc_config.json
@@ -3,6 +3,9 @@
{
"pattern": "^CONTRIBUTING\\.md"
},
+ {
+ "pattern": "^https://codecov\\.io/"
+ },
{
"pattern": "^https://dl\\.acm\\.org"
},
diff --git a/scripts/generate-authors.sh b/scripts/generate-authors.sh
index c2e1108e47e..6f00f12bb62 100755
--- a/scripts/generate-authors.sh
+++ b/scripts/generate-authors.sh
@@ -58,5 +58,5 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.."
# co-authors
coauthors=$(git log -i --grep=co-authored-by | grep -i "co-authored-by" | sed "s/.*co-authored-by: \(.*\)/\1/I" | sed "s/ <.*//")
- echo -e "$authors\n$(git log --format='%aN')\n$coauthors" | grep -v "\[bot\]" | grep -v "JabRef" | grep -v "Siedlerchr" | grep -v "^Christoph$" | grep -v "^Mootez$" | grep -v "oscargus" | grep -v "dependabot" | grep -v "github actions" | grep -v "igorsteinmacher" | grep -v "halirutan" | grep -v "matthiasgeiger" | grep -v "Gitter Badger" | grep -v "gdstewart" | LC_ALL=C.UTF-8 sort --unique --ignore-case
+ echo -e "$authors\n$(git log --format='%aN')\n$coauthors" | grep -v "\[bot\]" | grep -v "JabRef" | grep -v "Siedlerchr" | grep -v "^Christoph$" | grep -v "^Mootez$" | grep -v "oscargus" | grep -v "dependabot" | grep -v "github actions" | grep -v "igorsteinmacher" | grep -v "halirutan" | grep -v "matthiasgeiger" | grep -v "Gitter Badger" | grep -v "gdstewart" | grep -v "chenyuheng" | LC_ALL=C.UTF-8 sort --unique --ignore-case
} > AUTHORS
diff --git a/snap/local/JabRef-launcher b/snap/local/JabRef-launcher
index c65a6120820..469bca8698b 100755
--- a/snap/local/JabRef-launcher
+++ b/snap/local/JabRef-launcher
@@ -1,3 +1,3 @@
#! /bin/sh
DIR="$SNAP/lib/runtime/bin"
-"$DIR/java" -p "$DIR/../app" -m org.jabref/org.jabref.JabRefLauncher "$@"
\ No newline at end of file
+"$DIR/java" -p "$DIR/../app" -m org.jabref/org.jabref.gui.JabRefLauncher "$@"
diff --git a/src/jmh/java/org/jabref/benchmarks/Benchmarks.java b/src/jmh/java/org/jabref/benchmarks/Benchmarks.java
index a4d12e698ce..31935438c71 100644
--- a/src/jmh/java/org/jabref/benchmarks/Benchmarks.java
+++ b/src/jmh/java/org/jabref/benchmarks/Benchmarks.java
@@ -7,7 +7,7 @@
import java.util.Random;
import java.util.stream.Collectors;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.exporter.BibtexDatabaseWriter;
import org.jabref.logic.exporter.SavePreferences;
import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter;
@@ -55,7 +55,7 @@ public void init() throws Exception {
Random randomizer = new Random();
for (int i = 0; i < 1000; i++) {
BibEntry entry = new BibEntry();
- entry.setCiteKey("id" + i);
+ entry.setCitationKey("id" + i);
entry.setField(StandardField.TITLE, "This is my title " + i);
entry.setField(StandardField.AUTHOR, "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
entry.setField(StandardField.JOURNAL, "Journal Title " + i);
diff --git a/src/main/java/org/jabref/architecture/AllowedToUseAwt.java b/src/main/java/org/jabref/architecture/AllowedToUseAwt.java
new file mode 100644
index 00000000000..d4cdb549485
--- /dev/null
+++ b/src/main/java/org/jabref/architecture/AllowedToUseAwt.java
@@ -0,0 +1,10 @@
+package org.jabref.architecture;
+
+/**
+ * Annotation to indicate that this logic class can access AWT
+ */
+public @interface AllowedToUseAwt {
+
+ // The rationale
+ String value();
+}
diff --git a/src/main/java/org/jabref/architecture/AllowedToUseLogic.java b/src/main/java/org/jabref/architecture/AllowedToUseLogic.java
new file mode 100644
index 00000000000..ed6be5be7c4
--- /dev/null
+++ b/src/main/java/org/jabref/architecture/AllowedToUseLogic.java
@@ -0,0 +1,10 @@
+package org.jabref.architecture;
+
+/**
+ * Annotation to indicate that this logic class can be used in the model package.
+ */
+public @interface AllowedToUseLogic {
+
+ // The rationale
+ String value();
+}
diff --git a/src/main/java/org/jabref/cli/ArgumentProcessor.java b/src/main/java/org/jabref/cli/ArgumentProcessor.java
index a5d723cfcdb..eeee79c1366 100644
--- a/src/main/java/org/jabref/cli/ArgumentProcessor.java
+++ b/src/main/java/org/jabref/cli/ArgumentProcessor.java
@@ -11,11 +11,11 @@
import java.util.Set;
import java.util.prefs.BackingStoreException;
-import org.jabref.Globals;
-import org.jabref.JabRefException;
+import org.jabref.gui.Globals;
import org.jabref.gui.externalfiles.AutoSetFileLinksUtil;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.undo.NamedCompound;
+import org.jabref.logic.JabRefException;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.exporter.AtomicFileWriter;
import org.jabref.logic.exporter.BibDatabaseWriter;
@@ -48,6 +48,7 @@
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.strings.StringUtil;
+import org.jabref.model.util.DummyFileUpdateMonitor;
import org.jabref.preferences.SearchPreferences;
import com.google.common.base.Throwables;
@@ -83,7 +84,7 @@ private static Optional importToOpenBase(String argument) {
}
private static Optional importBibtexToOpenBase(String argument) {
- BibtexParser parser = new BibtexParser(Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
+ BibtexParser parser = new BibtexParser(Globals.prefs.getImportFormatPreferences(), new DummyFileUpdateMonitor());
try {
List entries = parser.parseEntries(argument);
ParserResult result = new ParserResult(entries);
@@ -143,7 +144,7 @@ private static Optional importFile(Path file, String importFormat)
// * means "guess the format":
System.out.println(Localization.lang("Importing in unknown format") + ": " + file);
- ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file, Globals.getFileUpdateMonitor());
+ ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file, new DummyFileUpdateMonitor());
System.out.println(Localization.lang("Format used") + ": " + importResult.format);
return Optional.of(importResult.parserResult);
@@ -273,7 +274,7 @@ private boolean exportMatches(List loaded) {
// export new database
Optional exporter = Globals.exportFactory.getExporterByName(formatName);
- if (!exporter.isPresent()) {
+ if (exporter.isEmpty()) {
System.err.println(Localization.lang("Unknown export format") + ": " + formatName);
} else {
// We have an TemplateExporter instance:
@@ -387,7 +388,7 @@ private boolean generateAux(List loaded, String[] data) {
private void saveDatabase(BibDatabase newBase, String subName) {
try {
System.out.println(Localization.lang("Saving") + ": " + subName);
- SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences();
+ SavePreferences prefs = Globals.prefs.getSavePreferences();
AtomicFileWriter fileWriter = new AtomicFileWriter(Path.of(subName), prefs.getEncoding());
BibDatabaseWriter databaseWriter = new BibtexDatabaseWriter(fileWriter, prefs, Globals.entryTypesManager);
databaseWriter.saveDatabase(new BibDatabaseContext(newBase));
@@ -435,7 +436,7 @@ private void exportFile(List loaded, String[] data) {
.getFileDirectories(Globals.prefs.getFilePreferences());
System.out.println(Localization.lang("Exporting") + ": " + data[0]);
Optional exporter = Globals.exportFactory.getExporterByName(data[1]);
- if (!exporter.isPresent()) {
+ if (exporter.isEmpty()) {
System.err.println(Localization.lang("Unknown export format") + ": " + data[1]);
} else {
// We have an exporter:
@@ -458,10 +459,10 @@ private void importPreferences() {
Globals.entryTypesManager.addCustomOrModifiedTypes(Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
List customExporters = Globals.prefs.getCustomExportFormats(Globals.journalAbbreviationRepository);
- LayoutFormatterPreferences layoutPreferences = Globals.prefs
- .getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
- SavePreferences savePreferences = Globals.prefs.loadForExportFromPreferences();
- XmpPreferences xmpPreferences = Globals.prefs.getXMPPreferences();
+ LayoutFormatterPreferences layoutPreferences =
+ Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
+ SavePreferences savePreferences = Globals.prefs.getSavePreferencesForExport();
+ XmpPreferences xmpPreferences = Globals.prefs.getXmpPreferences();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
} catch (JabRefException ex) {
LOGGER.error("Cannot import preferences", ex);
@@ -495,7 +496,11 @@ private void automaticallySetFileLinks(List loaded) {
for (ParserResult parserResult : loaded) {
BibDatabase database = parserResult.getDatabase();
LOGGER.info(Localization.lang("Automatically setting file links"));
- AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(parserResult.getDatabaseContext(), Globals.prefs.getFilePreferences(), Globals.prefs.getAutoLinkPreferences(), ExternalFileTypes.getInstance());
+ AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(
+ parserResult.getDatabaseContext(),
+ Globals.prefs.getFilePreferences(),
+ Globals.prefs.getAutoLinkPreferences(),
+ ExternalFileTypes.getInstance());
util.linkAssociatedFiles(database.getEntries(), new NamedCompound(""));
}
}
@@ -534,7 +539,7 @@ private Optional fetch(String fetchCommand) {
Optional selectedFetcher = fetchers.stream()
.filter(fetcher -> fetcher.getName().equalsIgnoreCase(engine))
.findFirst();
- if (!selectedFetcher.isPresent()) {
+ if (selectedFetcher.isEmpty()) {
System.out.println(Localization.lang("Could not find fetcher '%0'", engine));
System.out.println(Localization.lang("The following fetchers are available:"));
diff --git a/src/main/java/org/jabref/cli/AuxCommandLine.java b/src/main/java/org/jabref/cli/AuxCommandLine.java
index 00cb424fb54..61f4c133008 100644
--- a/src/main/java/org/jabref/cli/AuxCommandLine.java
+++ b/src/main/java/org/jabref/cli/AuxCommandLine.java
@@ -3,9 +3,9 @@
import java.nio.file.Path;
import org.jabref.gui.auximport.AuxParserResultViewModel;
+import org.jabref.logic.auxparser.AuxParser;
+import org.jabref.logic.auxparser.AuxParserResult;
import org.jabref.logic.auxparser.DefaultAuxParser;
-import org.jabref.model.auxparser.AuxParser;
-import org.jabref.model.auxparser.AuxParserResult;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.strings.StringUtil;
diff --git a/src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java b/src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java
index 6db58af18c0..207f523753c 100644
--- a/src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java
+++ b/src/main/java/org/jabref/cli/CrossrefFetcherEvaluator.java
@@ -9,7 +9,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.fetcher.CrossRef;
diff --git a/src/main/java/org/jabref/cli/JabRefCLI.java b/src/main/java/org/jabref/cli/JabRefCLI.java
index f9b0b4d4cbf..e9d26874b00 100644
--- a/src/main/java/org/jabref/cli/JabRefCLI.java
+++ b/src/main/java/org/jabref/cli/JabRefCLI.java
@@ -2,7 +2,7 @@
import java.util.List;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.apache.commons.cli.CommandLine;
diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css
index 1b9dee1176b..2ad2009d218 100644
--- a/src/main/java/org/jabref/gui/Base.css
+++ b/src/main/java/org/jabref/gui/Base.css
@@ -1173,3 +1173,18 @@ We want to have a look that matches our icons in the tool-bar */
TextFlow * {
-fx-fill: -fx-text-background-color;
}
+
+.chips-pane > .editor {
+ -fx-pref-height: 30px;
+ -fx-padding: 0px 0px 0px -8px;
+ -fx-margin: 0em;
+}
+
+.searchBar:invalid {
+ -fx-background-color: rgba(240, 128, 128, 0.5);
+}
+
+.searchBar:unsupported {
+ -fx-background-color: rgba(255, 159, 67, 0.5);
+
+}
diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java
index eacb550283a..e98e641a73b 100644
--- a/src/main/java/org/jabref/gui/BasePanel.java
+++ b/src/main/java/org/jabref/gui/BasePanel.java
@@ -12,7 +12,6 @@
import javafx.scene.control.SplitPane;
import javafx.scene.layout.StackPane;
-import org.jabref.Globals;
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.autocompleter.PersonNameSuggestionProvider;
import org.jabref.gui.autocompleter.SuggestionProviders;
@@ -33,6 +32,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.FileAnnotationCache;
import org.jabref.logic.search.SearchQuery;
+import org.jabref.logic.shared.DatabaseLocation;
import org.jabref.logic.util.UpdateField;
import org.jabref.model.FieldChange;
import org.jabref.model.database.BibDatabase;
@@ -40,7 +40,6 @@
import org.jabref.model.database.event.BibDatabaseContextChangedEvent;
import org.jabref.model.database.event.EntriesAddedEvent;
import org.jabref.model.database.event.EntriesRemovedEvent;
-import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.event.EntriesEventSource;
import org.jabref.model.entry.event.EntryChangedEvent;
@@ -120,8 +119,6 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
this.getDatabase().registerListener(new UpdateTimestampListener(Globals.prefs));
this.entryEditor = new EntryEditor(this, externalFileTypes);
- // Open entry editor for first entry on start up.
- Platform.runLater(this::clearAndSelectFirst);
}
@Subscribe
@@ -614,7 +611,7 @@ public void copy() {
}
public void paste() {
- mainTable.paste();
+ mainTable.paste(this.bibDatabaseContext.getMode());
}
public void cut() {
diff --git a/src/main/java/org/jabref/gui/BasePanelPreferences.java b/src/main/java/org/jabref/gui/BasePanelPreferences.java
index 595bfc81740..bc95224afa6 100644
--- a/src/main/java/org/jabref/gui/BasePanelPreferences.java
+++ b/src/main/java/org/jabref/gui/BasePanelPreferences.java
@@ -3,7 +3,6 @@
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
-import org.jabref.Globals;
import org.jabref.gui.autocompleter.AutoCompletePreferences;
import org.jabref.gui.entryeditor.EntryEditorPreferences;
import org.jabref.gui.keyboard.KeyBindingRepository;
diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java
index ba680353434..78f9e7aa39a 100644
--- a/src/main/java/org/jabref/gui/ClipBoardManager.java
+++ b/src/main/java/org/jabref/gui/ClipBoardManager.java
@@ -19,7 +19,7 @@
import javafx.scene.input.DataFormat;
import javafx.scene.input.MouseButton;
-import org.jabref.Globals;
+import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.logic.bibtex.BibEntryWriter;
import org.jabref.logic.bibtex.FieldWriter;
import org.jabref.logic.importer.FetcherException;
@@ -37,6 +37,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllowedToUseAwt("Requires ava.awt.datatransfer.Clipboard")
public class ClipBoardManager {
public static final DataFormat XML = new DataFormat("application/xml");
diff --git a/src/main/java/org/jabref/gui/DefaultInjector.java b/src/main/java/org/jabref/gui/DefaultInjector.java
index b485c9db34b..aefc1b4f232 100644
--- a/src/main/java/org/jabref/gui/DefaultInjector.java
+++ b/src/main/java/org/jabref/gui/DefaultInjector.java
@@ -4,8 +4,6 @@
import javax.swing.undo.UndoManager;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java
index 2de294e1ce1..f304238b688 100644
--- a/src/main/java/org/jabref/gui/EntryTypeView.java
+++ b/src/main/java/org/jabref/gui/EntryTypeView.java
@@ -18,7 +18,6 @@
import javafx.scene.layout.FlowPane;
import javafx.stage.Screen;
-import org.jabref.Globals;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ControlHelper;
import org.jabref.gui.util.IconValidationDecorator;
diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java
index 2326c66cf7e..926ad996e08 100644
--- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java
+++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java
@@ -14,12 +14,12 @@
import javafx.concurrent.Task;
import javafx.concurrent.Worker;
-import org.jabref.Globals;
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
-import org.jabref.logic.bibtex.DuplicateCheck;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
+import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.IdBasedFetcher;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.importer.fetcher.DoiFetcher;
import org.jabref.logic.l10n.Localization;
@@ -147,6 +147,8 @@ public void runFetcherWorker() {
Optional result = fetcherWorker.getValue();
if (result.isPresent()) {
final BibEntry entry = result.get();
+ ImportCleanup cleanup = new ImportCleanup(basePanel.getBibDatabaseContext().getMode());
+ cleanup.doPostCleanup(entry);
Optional duplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(basePanel.getDatabase(), entry, basePanel.getBibDatabaseContext().getMode());
if ((duplicate.isPresent())) {
DuplicateResolverDialog dialog = new DuplicateResolverDialog(entry, duplicate.get(), DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, basePanel.getBibDatabaseContext(), stateManager);
diff --git a/src/main/java/org/jabref/gui/FXDialog.java b/src/main/java/org/jabref/gui/FXDialog.java
index f0d071ae74f..f1c93adbdee 100644
--- a/src/main/java/org/jabref/gui/FXDialog.java
+++ b/src/main/java/org/jabref/gui/FXDialog.java
@@ -8,7 +8,6 @@
import javafx.stage.Modality;
import javafx.stage.Stage;
-import org.jabref.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.keyboard.KeyBindingRepository;
diff --git a/src/main/java/org/jabref/FallbackExceptionHandler.java b/src/main/java/org/jabref/gui/FallbackExceptionHandler.java
similarity index 97%
rename from src/main/java/org/jabref/FallbackExceptionHandler.java
rename to src/main/java/org/jabref/gui/FallbackExceptionHandler.java
index 0c0a4cb4391..b053a5f9be2 100644
--- a/src/main/java/org/jabref/FallbackExceptionHandler.java
+++ b/src/main/java/org/jabref/gui/FallbackExceptionHandler.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
import org.jabref.gui.util.DefaultTaskExecutor;
diff --git a/src/main/java/org/jabref/Globals.java b/src/main/java/org/jabref/gui/Globals.java
similarity index 97%
rename from src/main/java/org/jabref/Globals.java
rename to src/main/java/org/jabref/gui/Globals.java
index 8663a282b13..db851799580 100644
--- a/src/main/java/org/jabref/Globals.java
+++ b/src/main/java/org/jabref/gui/Globals.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
import java.awt.GraphicsEnvironment;
import java.util.Optional;
@@ -6,8 +6,7 @@
import javafx.stage.Screen;
-import org.jabref.gui.ClipBoardManager;
-import org.jabref.gui.StateManager;
+import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.gui.keyboard.KeyBindingRepository;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.DefaultFileUpdateMonitor;
@@ -33,6 +32,7 @@
* @deprecated try to use {@link StateManager} and {@link org.jabref.preferences.PreferencesService}
*/
@Deprecated
+@AllowedToUseAwt("Requires AWT for headless check")
public class Globals {
/**
@@ -131,6 +131,7 @@ public static FileUpdateMonitor getFileUpdateMonitor() {
public static void shutdownThreadPools() {
TASK_EXECUTOR.shutdown();
+ fileUpdateMonitor.shutdown();
JabRefExecutorService.INSTANCE.shutdownEverything();
}
diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/gui/JabRefExecutorService.java
similarity index 77%
rename from src/main/java/org/jabref/JabRefExecutorService.java
rename to src/main/java/org/jabref/gui/JabRefExecutorService.java
index a90668d9bd2..f60285e46ff 100644
--- a/src/main/java/org/jabref/JabRefExecutorService.java
+++ b/src/main/java/org/jabref/gui/JabRefExecutorService.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
import java.util.Collection;
import java.util.Collections;
@@ -22,24 +22,29 @@
public class JabRefExecutorService {
public static final JabRefExecutorService INSTANCE = new JabRefExecutorService();
+
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefExecutorService.class);
+
private final ExecutorService executorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setName("JabRef CachedThreadPool");
thread.setUncaughtExceptionHandler(new FallbackExceptionHandler());
return thread;
});
+
private final ExecutorService lowPriorityExecutorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setName("JabRef LowPriorityCachedThreadPool");
thread.setUncaughtExceptionHandler(new FallbackExceptionHandler());
return thread;
});
+
private final Timer timer = new Timer("timer", true);
+
private Thread remoteThread;
private JabRefExecutorService() {
- }
+ }
public void execute(Runnable command) {
Objects.requireNonNull(command);
@@ -132,13 +137,16 @@ public void submit(TimerTask timerTask, long millisecondsDelay) {
timer.schedule(timerTask, millisecondsDelay);
}
+ /**
+ * Shuts everything down. After termination, this method returns.
+ */
public void shutdownEverything() {
- // those threads will be allowed to finish
- this.executorService.shutdown();
- // those threads will be interrupted in their current task
- this.lowPriorityExecutorService.shutdownNow();
// kill the remote thread
stopRemoteThread();
+
+ gracefullyShutdown(this.executorService);
+ gracefullyShutdown(this.lowPriorityExecutorService);
+
timer.cancel();
}
@@ -164,4 +172,28 @@ public void run() {
}
}
}
+
+ /**
+ * Shuts down the provided executor service by first trying a normal shutdown, then waiting for the shutdown and then forcibly shutting it down.
+ * Returns if the status of the shut down is known.
+ */
+ public static void gracefullyShutdown(ExecutorService executorService) {
+ try {
+ // This is non-blocking. See https://stackoverflow.com/a/57383461/873282.
+ executorService.shutdown();
+ if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
+ LOGGER.debug("One minute passed, {} still not completed. Trying forced shutdown.", executorService.toString());
+ // those threads will be interrupted in their current task
+ executorService.shutdownNow();
+ if (executorService.awaitTermination(60, TimeUnit.SECONDS)) {
+ LOGGER.debug("One minute passed again - forced shutdown of {} worked.", executorService.toString());
+ } else {
+ LOGGER.error("{} did not terminate", executorService.toString());
+ }
+ }
+ } catch (InterruptedException ie) {
+ executorService.shutdownNow();
+ Thread.currentThread().interrupt();
+ }
+ }
}
diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java
index a7590558a1c..3fcbca23310 100644
--- a/src/main/java/org/jabref/gui/JabRefFrame.java
+++ b/src/main/java/org/jabref/gui/JabRefFrame.java
@@ -46,8 +46,6 @@
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
@@ -125,16 +123,17 @@
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
import org.jabref.logic.importer.IdFetcher;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.shared.DatabaseLocation;
import org.jabref.logic.undo.AddUndoableActionEvent;
import org.jabref.logic.undo.UndoChangeEvent;
import org.jabref.logic.undo.UndoRedoEvent;
import org.jabref.logic.util.OS;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;
@@ -218,9 +217,7 @@ private void initDragAndDrop() {
}
});
- this.getScene().setOnDragExited(event -> {
- tabbedPane.getTabs().remove(dndIndicator);
- });
+ this.getScene().setOnDragExited(event -> tabbedPane.getTabs().remove(dndIndicator));
this.getScene().setOnDragDropped(event -> {
tabbedPane.getTabs().remove(dndIndicator);
@@ -792,7 +789,7 @@ private MenuBar createMenu() {
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager))
);
- if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
+ if (Globals.prefs.getSpecialFieldsPreferences().isSpecialFieldsEnabled()) {
edit.getItems().addAll(
new SeparatorMenuItem(),
// ToDo: SpecialField needs the active BasePanel to mark it as changed.
@@ -1033,7 +1030,7 @@ public void addParserResult(ParserResult parserResult, boolean focusPanel) {
} else {
// only add tab if DB is not already open
Optional panel = getBasePanelList().stream()
- .filter(p -> p.getBibDatabaseContext().getDatabasePath().equals(parserResult.getFile()))
+ .filter(p -> p.getBibDatabaseContext().getDatabasePath().equals(parserResult.getPath()))
.findFirst();
if (panel.isPresent()) {
@@ -1092,7 +1089,7 @@ public void updateAllTabTitles() {
Optional file = getBasePanelAt(i).getBibDatabaseContext().getDatabasePath();
if (file.isPresent()) {
- if (!uniqPath.equals(file.get().getFileName()) && uniqPath.contains(File.separator)) {
+ if (!uniqPath.equals(file.get().getFileName().toString()) && uniqPath.contains(File.separator)) {
// remove filename
uniqPath = uniqPath.substring(0, uniqPath.lastIndexOf(File.separator));
tabbedPane.getTabs().get(i).setText(getBasePanelAt(i).getTabTitle() + " \u2014 " + uniqPath);
@@ -1189,6 +1186,8 @@ private boolean readyForAutosave(BibDatabaseContext context) {
*/
private void addImportedEntries(final BasePanel panel, final ParserResult parserResult) {
BackgroundTask task = BackgroundTask.wrap(() -> parserResult);
+ ImportCleanup cleanup = new ImportCleanup(panel.getBibDatabaseContext().getMode());
+ cleanup.doPostCleanup(parserResult.getDatabase().getEntries());
ImportEntriesDialog dialog = new ImportEntriesDialog(panel.getBibDatabaseContext(), task);
dialog.setTitle(Localization.lang("Import"));
dialog.showAndWait();
diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java
similarity index 98%
rename from src/main/java/org/jabref/JabRefGUI.java
rename to src/main/java/org/jabref/gui/JabRefGUI.java
index fd228609a3d..4cdbb7850fa 100644
--- a/src/main/java/org/jabref/JabRefGUI.java
+++ b/src/main/java/org/jabref/gui/JabRefGUI.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
import java.io.File;
import java.sql.SQLException;
@@ -11,8 +11,6 @@
import javafx.stage.Screen;
import javafx.stage.Stage;
-import org.jabref.gui.BasePanel;
-import org.jabref.gui.JabRefFrame;
import org.jabref.gui.dialogs.BackupUIManager;
import org.jabref.gui.help.VersionWorker;
import org.jabref.gui.icon.IconTheme;
@@ -23,9 +21,9 @@
import org.jabref.logic.importer.OpenDatabase;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.shared.DatabaseNotSupportedException;
import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException;
import org.jabref.logic.shared.exception.NotASharedDatabaseException;
-import org.jabref.model.database.shared.DatabaseNotSupportedException;
import org.jabref.preferences.JabRefPreferences;
import impl.org.controlsfx.skin.DecorationPane;
diff --git a/src/main/java/org/jabref/JabRefLauncher.java b/src/main/java/org/jabref/gui/JabRefLauncher.java
similarity index 91%
rename from src/main/java/org/jabref/JabRefLauncher.java
rename to src/main/java/org/jabref/gui/JabRefLauncher.java
index f5e5ba0e3c0..67a1a1803b5 100644
--- a/src/main/java/org/jabref/JabRefLauncher.java
+++ b/src/main/java/org/jabref/gui/JabRefLauncher.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
/**
* JabRef launcher: This just starts JabRefMain. It is there because to have the name consistent to other Java applications.
diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/gui/JabRefMain.java
similarity index 94%
rename from src/main/java/org/jabref/JabRefMain.java
rename to src/main/java/org/jabref/gui/JabRefMain.java
index e004d0e1627..826c561587f 100644
--- a/src/main/java/org/jabref/JabRefMain.java
+++ b/src/main/java/org/jabref/gui/JabRefMain.java
@@ -1,4 +1,4 @@
-package org.jabref;
+package org.jabref.gui;
import java.net.Authenticator;
@@ -9,8 +9,8 @@
import org.jabref.cli.ArgumentProcessor;
import org.jabref.cli.JabRefCLI;
-import org.jabref.gui.FXDialog;
import org.jabref.gui.remote.JabRefMessageHandler;
+import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyAuthenticator;
@@ -165,10 +165,14 @@ private static void applyPreferences(JabRefPreferences preferences) {
// Build list of Import and Export formats
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(),
- Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
+ Globals.prefs.getXmpPreferences(), Globals.getFileUpdateMonitor());
Globals.entryTypesManager.addCustomOrModifiedTypes(preferences.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
- Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationRepository);
+ Globals.exportFactory = ExporterFactory.create(
+ Globals.prefs.getCustomExportFormats(Globals.journalAbbreviationRepository),
+ Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository),
+ Globals.prefs.getSavePreferencesForExport(),
+ Globals.prefs.getXmpPreferences());
// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());
diff --git a/src/main/java/org/jabref/gui/SendAsEMailAction.java b/src/main/java/org/jabref/gui/SendAsEMailAction.java
index 15118bea93d..2ba19e6798f 100644
--- a/src/main/java/org/jabref/gui/SendAsEMailAction.java
+++ b/src/main/java/org/jabref/gui/SendAsEMailAction.java
@@ -8,7 +8,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.jabref.Globals;
+import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.desktop.JabRefDesktop;
@@ -34,6 +34,7 @@
* are opened. This feature is disabled by default and can be switched on at
* preferences/external programs
*/
+@AllowedToUseAwt("Requires AWT to send an email")
public class SendAsEMailAction extends SimpleCommand {
private static final Logger LOGGER = LoggerFactory.getLogger(SendAsEMailAction.class);
diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java
index 55b55d4f795..472589044e3 100644
--- a/src/main/java/org/jabref/gui/SidePaneManager.java
+++ b/src/main/java/org/jabref/gui/SidePaneManager.java
@@ -7,7 +7,6 @@
import java.util.Map;
import java.util.stream.Stream;
-import org.jabref.Globals;
import org.jabref.gui.groups.GroupSidePane;
import org.jabref.gui.importer.fetcher.WebSearchPane;
import org.jabref.gui.openoffice.OpenOfficeSidePanel;
diff --git a/src/main/java/org/jabref/gui/actions/JabRefAction.java b/src/main/java/org/jabref/gui/actions/JabRefAction.java
index c017c979e06..5d1fbd10e28 100644
--- a/src/main/java/org/jabref/gui/actions/JabRefAction.java
+++ b/src/main/java/org/jabref/gui/actions/JabRefAction.java
@@ -5,7 +5,7 @@
import javafx.beans.binding.Bindings;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.keyboard.KeyBindingRepository;
import de.saxsys.mvvmfx.utils.commands.Command;
diff --git a/src/main/java/org/jabref/gui/autocompleter/BibEntrySuggestionProvider.java b/src/main/java/org/jabref/gui/autocompleter/BibEntrySuggestionProvider.java
index 3cf297c71c1..a69b8a3b1c1 100644
--- a/src/main/java/org/jabref/gui/autocompleter/BibEntrySuggestionProvider.java
+++ b/src/main/java/org/jabref/gui/autocompleter/BibEntrySuggestionProvider.java
@@ -13,7 +13,7 @@
import org.controlsfx.control.textfield.AutoCompletionBinding;
/**
- * Delivers possible completions as a list of {@link BibEntry} based on their cite key.
+ * Delivers possible completions as a list of {@link BibEntry} based on their citation key.
*/
public class BibEntrySuggestionProvider extends SuggestionProvider {
@@ -25,7 +25,7 @@ public BibEntrySuggestionProvider(BibDatabase database) {
@Override
protected Equivalence getEquivalence() {
- return Equivalence.equals().onResultOf(BibEntry::getCiteKeyOptional);
+ return Equivalence.equals().onResultOf(BibEntry::getCitationKey);
}
@Override
@@ -36,7 +36,7 @@ protected Comparator getComparator() {
@Override
protected boolean isMatch(BibEntry entry, AutoCompletionBinding.ISuggestionRequest request) {
String userText = request.getUserText();
- return entry.getCiteKeyOptional()
+ return entry.getCitationKey()
.map(key -> StringUtil.containsIgnoreCase(key, userText))
.orElse(false);
}
diff --git a/src/main/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProvider.java b/src/main/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProvider.java
index dc2299fa685..01e56ff5350 100644
--- a/src/main/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProvider.java
+++ b/src/main/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProvider.java
@@ -1,5 +1,7 @@
package org.jabref.gui.autocompleter;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
@@ -22,4 +24,14 @@ public ContentSelectorSuggestionProvider(SuggestionProvider suggestionPr
public Stream getSource() {
return Stream.concat(contentSelectorValues.stream(), suggestionProvider.getSource());
}
+
+ @Override
+ public Collection getPossibleSuggestions() {
+ List suggestions = new ArrayList<>();
+ if (suggestionProvider != null) {
+ suggestions.addAll(suggestionProvider.getPossibleSuggestions());
+ }
+ suggestions.addAll(contentSelectorValues);
+ return suggestions;
+ }
}
diff --git a/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java b/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java
index 8d6bba4633a..341c9ef8f5e 100644
--- a/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java
+++ b/src/main/java/org/jabref/gui/autocompleter/SuggestionProvider.java
@@ -60,6 +60,16 @@ public final Collection provideSuggestions(ISuggestionRequest request) {
protected abstract Equivalence getEquivalence();
+ public Collection getPossibleSuggestions() {
+ Comparator comparator = getComparator().reversed();
+ Equivalence equivalence = getEquivalence();
+ return getSource().map(equivalence::wrap) // Need to do a bit of acrobatic as there is no distinctBy method
+ .distinct()
+ .map(Equivalence.Wrapper::get)
+ .sorted(comparator)
+ .collect(Collectors.toList());
+ }
+
/**
* Get the comparator to order the suggestions
*/
diff --git a/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java b/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java
index 1d4a039735f..47e1309fc1c 100644
--- a/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java
+++ b/src/main/java/org/jabref/gui/autocompleter/SuggestionProviders.java
@@ -32,10 +32,9 @@ public SuggestionProvider> getForField(Field field) {
Set fieldProperties = field.getProperties();
if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonNameSuggestionProvider(field, database);
- } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
+ } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK) || fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new BibEntrySuggestionProvider(database);
- } else if (fieldProperties.contains(FieldProperty.JOURNAL_NAME)
- || StandardField.PUBLISHER.equals(field)) {
+ } else if (fieldProperties.contains(FieldProperty.JOURNAL_NAME) || StandardField.PUBLISHER.equals(field)) {
return new JournalsSuggestionProvider(field, database, abbreviationRepository);
} else {
return new WordSuggestionProvider(field, database);
diff --git a/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java b/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java
index e30753c8542..d565151eb71 100644
--- a/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java
+++ b/src/main/java/org/jabref/gui/auximport/AuxParserResultViewModel.java
@@ -1,7 +1,7 @@
package org.jabref.gui.auximport;
+import org.jabref.logic.auxparser.AuxParserResult;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.auxparser.AuxParserResult;
public class AuxParserResultViewModel {
diff --git a/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java b/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java
index ccbf6c53c29..518b09efc2b 100644
--- a/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java
+++ b/src/main/java/org/jabref/gui/auximport/FromAuxDialog.java
@@ -16,11 +16,11 @@
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.FileDialogConfiguration;
+import org.jabref.logic.auxparser.AuxParser;
+import org.jabref.logic.auxparser.AuxParserResult;
import org.jabref.logic.auxparser.DefaultAuxParser;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.StandardFileType;
-import org.jabref.model.auxparser.AuxParser;
-import org.jabref.model.auxparser.AuxParserResult;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.PreferencesService;
diff --git a/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java b/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java
index 1bf6ea2cd46..a7181ba3ae1 100644
--- a/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java
+++ b/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java
@@ -8,8 +8,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.externalfiles.ImportHandler;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
diff --git a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java
index e051ff2dcbb..4b33b9de97b 100644
--- a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java
+++ b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternDialog.java
@@ -2,11 +2,11 @@
import javafx.scene.control.ButtonType;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.BaseDialog;
+import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern;
import org.jabref.model.metadata.MetaData;
public class CitationKeyPatternDialog extends BaseDialog {
diff --git a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java
index c9114dc89dd..56f98b88e26 100644
--- a/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java
+++ b/src/main/java/org/jabref/gui/citationkeypattern/CitationKeyPatternPanel.java
@@ -10,15 +10,15 @@
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
+import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern;
+import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPattern;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern;
-import org.jabref.model.bibtexkeypattern.DatabaseCitationKeyPattern;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.EntryType;
diff --git a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java
index 208d8216a15..4173db5cc65 100644
--- a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java
+++ b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java
@@ -2,8 +2,8 @@
import java.util.List;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
@@ -68,15 +68,14 @@ public static boolean confirmOverwriteKeys(DialogService dialogService) {
private void checkOverwriteKeysChosen() {
// We don't want to generate keys for entries which already have one thus remove the entries
if (Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) {
- entries.removeIf(BibEntry::hasCiteKey);
- // if we're going to override some cite keys warn the user about it
- } else if (entries.parallelStream().anyMatch(BibEntry::hasCiteKey)) {
+ entries.removeIf(BibEntry::hasCitationKey);
+ // if we're going to override some citation keys warn the user about it
+ } else if (entries.parallelStream().anyMatch(BibEntry::hasCitationKey)) {
boolean overwriteKeys = confirmOverwriteKeys(dialogService);
- // The user doesn't want to override cite keys
+ // The user doesn't want to override citation keys
if (!overwriteKeys) {
isCanceled = true;
- return;
}
}
}
@@ -87,7 +86,7 @@ private void generateKeys() {
}
stateManager.getActiveDatabase().ifPresent(databaseContext -> {
- // generate the new cite keys for each entry
+ // generate the new citation keys for each entry
final NamedCompound compound = new NamedCompound(Localization.lang("Autogenerate citation keys"));
CitationKeyGenerator keyGenerator =
new CitationKeyGenerator(databaseContext, Globals.prefs.getCitationKeyPatternPreferences());
@@ -97,7 +96,7 @@ private void generateKeys() {
}
compound.end();
- // register the undo event only if new cite keys were generated
+ // register the undo event only if new citation keys were generated
if (compound.hasEdits()) {
frame.getUndoManager().addEdit(compound);
}
diff --git a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeySingleAction.java b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeySingleAction.java
index 43e2acbe1ef..b66beef36be 100644
--- a/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeySingleAction.java
+++ b/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeySingleAction.java
@@ -32,7 +32,7 @@ public GenerateCitationKeySingleAction(BibEntry entry, BibDatabaseContext databa
@Override
public void execute() {
- if (!entry.hasCiteKey() || GenerateCitationKeyAction.confirmOverwriteKeys(dialogService)) {
+ if (!entry.hasCitationKey() || GenerateCitationKeyAction.confirmOverwriteKeys(dialogService)) {
new CitationKeyGenerator(databaseContext, preferencesService.getCitationKeyPatternPreferences())
.generateAndSetKey(entry)
.ifPresent(change -> undoManager.addEdit(new UndoableKeyChange(change)));
diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java
index fe59b6e3294..1fa40af1f84 100644
--- a/src/main/java/org/jabref/gui/cleanup/CleanupAction.java
+++ b/src/main/java/org/jabref/gui/cleanup/CleanupAction.java
@@ -3,8 +3,8 @@
import java.util.List;
import java.util.Optional;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java
index 83d9e810b05..20d3648e940 100644
--- a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java
+++ b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java
@@ -6,7 +6,7 @@
import org.jabref.logic.cleanup.CleanupPreset;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.metadata.FilePreferences;
+import org.jabref.preferences.FilePreferences;
public class CleanupDialog extends BaseDialog {
diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java
index 3ea9fa7c8c7..3d94fee18bc 100644
--- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java
+++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java
@@ -14,11 +14,11 @@
import org.jabref.gui.commonfxcontrols.FieldFormatterCleanupsPanel;
import org.jabref.logic.cleanup.CleanupPreset;
+import org.jabref.logic.cleanup.FieldFormatterCleanups;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.cleanup.FieldFormatterCleanups;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.field.StandardField;
-import org.jabref.model.metadata.FilePreferences;
+import org.jabref.preferences.FilePreferences;
import com.airhacks.afterburner.views.ViewLoader;
diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java
index 469d5e3fd2c..f09de7c2bdd 100644
--- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java
+++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java
@@ -5,7 +5,7 @@
import java.util.Collections;
import java.util.List;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.bibtex.comparator.BibDatabaseDiff;
import org.jabref.logic.bibtex.comparator.BibEntryDiff;
import org.jabref.logic.bibtex.comparator.BibStringDiff;
diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
index 6c1b8e2c55f..6181129601b 100644
--- a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
+++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java
@@ -20,7 +20,7 @@ public class DatabaseChangeMonitor implements FileUpdateListener {
private final BibDatabaseContext database;
private final FileUpdateMonitor fileMonitor;
private final List listeners;
- private TaskExecutor taskExecutor;
+ private final TaskExecutor taskExecutor;
public DatabaseChangeMonitor(BibDatabaseContext database, FileUpdateMonitor fileMonitor, TaskExecutor taskExecutor) {
this.database = database;
diff --git a/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java b/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java
index ea28f4e9d1d..6e5e0d8b456 100644
--- a/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java
+++ b/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java
@@ -2,8 +2,8 @@
import javafx.scene.Node;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableInsertEntries;
@@ -17,7 +17,7 @@ class EntryAddChangeViewModel extends DatabaseChangeViewModel {
public EntryAddChangeViewModel(BibEntry entry) {
super();
- this.name = entry.getCiteKeyOptional()
+ this.name = entry.getCitationKey()
.map(key -> Localization.lang("Added entry") + ": '" + key + '\'')
.orElse(Localization.lang("Added entry"));
this.entry = entry;
diff --git a/src/main/java/org/jabref/gui/collab/EntryChangeViewModel.java b/src/main/java/org/jabref/gui/collab/EntryChangeViewModel.java
index cc303b27178..bbb006da2cc 100644
--- a/src/main/java/org/jabref/gui/collab/EntryChangeViewModel.java
+++ b/src/main/java/org/jabref/gui/collab/EntryChangeViewModel.java
@@ -25,7 +25,7 @@ public EntryChangeViewModel(BibEntry entry, BibEntry newEntry) {
this.oldEntry = entry;
this.newEntry = newEntry;
- name = entry.getCiteKeyOptional()
+ name = entry.getCitationKey()
.map(key -> Localization.lang("Modified entry") + ": '" + key + '\'')
.orElse(Localization.lang("Modified entry"));
}
diff --git a/src/main/java/org/jabref/gui/collab/EntryDeleteChangeViewModel.java b/src/main/java/org/jabref/gui/collab/EntryDeleteChangeViewModel.java
index 4ffdedf3575..ff6adfd3fce 100644
--- a/src/main/java/org/jabref/gui/collab/EntryDeleteChangeViewModel.java
+++ b/src/main/java/org/jabref/gui/collab/EntryDeleteChangeViewModel.java
@@ -2,8 +2,8 @@
import javafx.scene.Node;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableRemoveEntries;
@@ -22,7 +22,7 @@ class EntryDeleteChangeViewModel extends DatabaseChangeViewModel {
public EntryDeleteChangeViewModel(BibEntry entry) {
super(Localization.lang("Deleted entry"));
- this.name = entry.getCiteKeyOptional()
+ this.name = entry.getCitationKey()
.map(key -> Localization.lang("Deleted entry") + ": '" + key + '\'')
.orElse(Localization.lang("Deleted entry"));
this.entry = entry;
diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java
index 42b28084211..ac61606744c 100644
--- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanel.java
@@ -13,11 +13,11 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.ValueTableCellFactory;
+import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.EntryType;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
@@ -32,7 +32,7 @@ public class CitationKeyPatternPanel extends TableView entryTypeList, AbstractCitationKeyPattern keyPattern) {
+ public CitationKeyPatternPanel(PreferencesService preferences, Collection entryTypeList, AbstractCitationKeyPattern keyPattern) {
super();
viewModel = new CitationKeyPatternPanelViewModel(preferences, entryTypeList, keyPattern);
diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java
index 6f906b98c38..fa3a1978b29 100644
--- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternPanelViewModel.java
@@ -9,11 +9,11 @@
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
+import org.jabref.logic.citationkeypattern.AbstractCitationKeyPattern;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.bibtexkeypattern.AbstractCitationKeyPattern;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.EntryType;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
public class CitationKeyPatternPanelViewModel {
@@ -38,9 +38,9 @@ public class CitationKeyPatternPanelViewModel {
private final ObjectProperty defaultItemProperty = new SimpleObjectProperty<>();
private final AbstractCitationKeyPattern initialKeyPattern;
private final Collection bibEntryTypeList;
- private final JabRefPreferences preferences;
+ private final PreferencesService preferences;
- public CitationKeyPatternPanelViewModel(JabRefPreferences preferences, Collection entryTypeList, AbstractCitationKeyPattern initialKeyPattern) {
+ public CitationKeyPatternPanelViewModel(PreferencesService preferences, Collection entryTypeList, AbstractCitationKeyPattern initialKeyPattern) {
this.preferences = preferences;
this.bibEntryTypeList = entryTypeList;
this.initialKeyPattern = initialKeyPattern;
@@ -72,12 +72,12 @@ public void setValues() {
}
public void setItemToDefaultPattern(CitationKeyPatternPanelItemModel item) {
- item.setPattern((String) preferences.defaults.get(JabRefPreferences.DEFAULT_CITATION_KEY_PATTERN));
+ item.setPattern(preferences.getDefaultsDefaultCitationKeyPattern());
}
public void resetAll() {
patternListProperty.forEach(item -> item.setPattern(""));
- defaultItemProperty.getValue().setPattern((String) preferences.defaults.get(JabRefPreferences.DEFAULT_CITATION_KEY_PATTERN));
+ defaultItemProperty.getValue().setPattern(preferences.getDefaultsDefaultCitationKeyPattern());
}
public ListProperty patternListProperty() {
diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java
index d0ded8f1863..ed6df61fce5 100644
--- a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanel.java
@@ -18,9 +18,9 @@
import org.jabref.gui.util.FieldsUtil;
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.gui.util.ViewModelListCellFactory;
+import org.jabref.logic.cleanup.FieldFormatterCleanup;
+import org.jabref.logic.cleanup.Formatter;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.cleanup.FieldFormatterCleanup;
-import org.jabref.model.cleanup.Formatter;
import org.jabref.model.entry.field.Field;
import com.airhacks.afterburner.views.ViewLoader;
diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java
index 24258baa7ac..b5169b5b69d 100644
--- a/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java
+++ b/src/main/java/org/jabref/gui/commonfxcontrols/FieldFormatterCleanupsPanelViewModel.java
@@ -9,11 +9,11 @@
import javafx.collections.FXCollections;
import javafx.scene.control.SelectionModel;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.NoSelectionModel;
import org.jabref.logic.cleanup.Cleanups;
-import org.jabref.model.cleanup.FieldFormatterCleanup;
-import org.jabref.model.cleanup.Formatter;
+import org.jabref.logic.cleanup.FieldFormatterCleanup;
+import org.jabref.logic.cleanup.Formatter;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
index 943411735d4..24c28e38097 100644
--- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
+++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java
@@ -6,8 +6,8 @@
import javafx.concurrent.Task;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.DirectoryDialogConfiguration;
diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java
index a9cf049c565..1e12a4efa53 100644
--- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java
+++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java
@@ -14,7 +14,7 @@
import javafx.concurrent.Task;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.logic.util.io.FileUtil;
diff --git a/src/main/java/org/jabref/gui/copyfiles/CopySingleFileAction.java b/src/main/java/org/jabref/gui/copyfiles/CopySingleFileAction.java
index 98d330d1482..0981032c29a 100644
--- a/src/main/java/org/jabref/gui/copyfiles/CopySingleFileAction.java
+++ b/src/main/java/org/jabref/gui/copyfiles/CopySingleFileAction.java
@@ -4,8 +4,8 @@
import java.util.Optional;
import java.util.function.BiFunction;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.io.FileUtil;
diff --git a/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java b/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java
index 2e91b67a4b7..14addc7ea20 100644
--- a/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java
@@ -50,7 +50,7 @@ public Field fromString(String string) {
}
};
- private final ObservableList fieldsForAdding = FXCollections.observableArrayList(FieldFactory.getStandardFielsdsWithBibTexKey());
+ private final ObservableList fieldsForAdding = FXCollections.observableArrayList(FieldFactory.getStandardFieldsWithCitationKey());
private final ObjectProperty selectedEntryType = new SimpleObjectProperty<>();
private final ObjectProperty selectedFieldToAdd = new SimpleObjectProperty<>();
private final StringProperty entryTypeToAdd = new SimpleStringProperty("");
diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
index fee12ffa38e..3ae0a346f02 100644
--- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
+++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
@@ -10,8 +10,8 @@
import java.util.Optional;
import java.util.regex.Pattern;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.desktop.os.DefaultDesktop;
import org.jabref.gui.desktop.os.Linux;
import org.jabref.gui.desktop.os.NativeDesktop;
diff --git a/src/main/java/org/jabref/gui/desktop/os/DefaultDesktop.java b/src/main/java/org/jabref/gui/desktop/os/DefaultDesktop.java
index 457503ae272..5cb41e0d0f2 100644
--- a/src/main/java/org/jabref/gui/desktop/os/DefaultDesktop.java
+++ b/src/main/java/org/jabref/gui/desktop/os/DefaultDesktop.java
@@ -5,9 +5,12 @@
import java.io.IOException;
import java.nio.file.Path;
+import org.jabref.architecture.AllowedToUseAwt;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllowedToUseAwt("Requires AWT to open a file")
public class DefaultDesktop implements NativeDesktop {
private static final Logger LOGGER = LoggerFactory.getLogger(NativeDesktop.class);
diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java
index ee1881af803..e501d3ba620 100644
--- a/src/main/java/org/jabref/gui/desktop/os/Linux.java
+++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java
@@ -8,7 +8,7 @@
import java.util.Locale;
import java.util.Optional;
-import org.jabref.JabRefExecutorService;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.util.StreamGobbler;
diff --git a/src/main/java/org/jabref/gui/desktop/os/OSX.java b/src/main/java/org/jabref/gui/desktop/os/OSX.java
index 57f145f7460..b48c8bef411 100644
--- a/src/main/java/org/jabref/gui/desktop/os/OSX.java
+++ b/src/main/java/org/jabref/gui/desktop/os/OSX.java
@@ -6,9 +6,11 @@
import java.nio.file.Path;
import java.util.Optional;
+import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
+@AllowedToUseAwt("Requires AWT to open a file")
public class OSX implements NativeDesktop {
@Override
diff --git a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java
index a1d6da59753..660995a0795 100644
--- a/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java
+++ b/src/main/java/org/jabref/gui/dialogs/AutosaveUiManager.java
@@ -1,7 +1,7 @@
package org.jabref.gui.dialogs;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
+import org.jabref.gui.Globals;
import org.jabref.gui.exporter.SaveDatabaseAction;
import org.jabref.model.database.event.AutosaveEvent;
diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java
index 48097879406..dc32be00a35 100644
--- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java
+++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java
@@ -16,8 +16,8 @@
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
-import org.jabref.Globals;
import org.jabref.gui.AbstractViewModel;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
diff --git a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java
index 0bfb3f7775a..5ad9a3b528c 100644
--- a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java
+++ b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java
@@ -8,6 +8,8 @@
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
+import org.jabref.architecture.AllowedToUseAwt;
+
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
@@ -17,6 +19,7 @@
/**
* Represents the view model of a pdf page backed by a {@link PDPage}.
*/
+@AllowedToUseAwt("Requires AWT due to PDFBox")
public class PdfDocumentPageViewModel extends DocumentPageViewModel {
private final PDPage page;
diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java
index eeb4528de9f..b0bdb122ea1 100644
--- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java
+++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java
@@ -11,10 +11,10 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
@@ -25,7 +25,7 @@
import org.jabref.gui.undo.UndoableRemoveEntries;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
-import org.jabref.logic.bibtex.DuplicateCheck;
+import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
diff --git a/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java b/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java
index bbc936366ed..459df55a595 100644
--- a/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java
+++ b/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java
@@ -4,8 +4,8 @@
import javafx.scene.control.TextArea;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.identifier.DOI;
diff --git a/src/main/java/org/jabref/gui/edit/CopyMoreAction.java b/src/main/java/org/jabref/gui/edit/CopyMoreAction.java
index 5f982b01da3..ac138cf5a85 100644
--- a/src/main/java/org/jabref/gui/edit/CopyMoreAction.java
+++ b/src/main/java/org/jabref/gui/edit/CopyMoreAction.java
@@ -6,9 +6,9 @@
import java.util.Optional;
import java.util.stream.Collectors;
-import org.jabref.Globals;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefDialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
@@ -104,8 +104,8 @@ private void copyKey() {
// Collect all non-null keys.
List keys = entries.stream()
- .filter(entry -> entry.getCiteKeyOptional().isPresent())
- .map(entry -> entry.getCiteKeyOptional().get())
+ .filter(entry -> entry.getCitationKey().isPresent())
+ .map(entry -> entry.getCitationKey().get())
.collect(Collectors.toList());
if (keys.isEmpty()) {
@@ -131,8 +131,8 @@ private void copyCiteKey() {
// Collect all non-null keys.
List keys = entries.stream()
- .filter(entry -> entry.getCiteKeyOptional().isPresent())
- .map(entry -> entry.getCiteKeyOptional().get())
+ .filter(entry -> entry.getCitationKey().isPresent())
+ .map(entry -> entry.getCitationKey().get())
.collect(Collectors.toList());
if (keys.isEmpty()) {
@@ -161,7 +161,7 @@ private void copyKeyAndTitle() {
List entries = stateManager.getSelectedEntries();
// ToDo: this string should be configurable to allow arbitrary exports
- StringReader layoutString = new StringReader("\\bibtexkey - \\begin{title}\\format[RemoveBrackets]{\\title}\\end{title}\n");
+ StringReader layoutString = new StringReader("\\citationkey - \\begin{title}\\format[RemoveBrackets]{\\title}\\end{title}\n");
Layout layout;
try {
layout = new LayoutHelper(layoutString, preferencesService.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository)).getLayoutFromText();
@@ -175,7 +175,7 @@ private void copyKeyAndTitle() {
int entriesWithKeys = 0;
// Collect all non-null keys.
for (BibEntry entry : entries) {
- if (entry.hasCiteKey()) {
+ if (entry.hasCitationKey()) {
entriesWithKeys++;
keyAndTitle.append(layout.doLayout(entry, stateManager.getActiveDatabase().get().getDatabase()));
}
@@ -209,7 +209,7 @@ private void copyKeyAndLink() {
StringBuilder keyAndLink = new StringBuilder();
List entriesWithKey = entries.stream()
- .filter(BibEntry::hasCiteKey)
+ .filter(BibEntry::hasCitationKey)
.collect(Collectors.toList());
if (entriesWithKey.isEmpty()) {
@@ -218,7 +218,7 @@ private void copyKeyAndLink() {
}
for (BibEntry entry : entriesWithKey) {
- String key = entry.getCiteKeyOptional().get();
+ String key = entry.getCitationKey().get();
String url = entry.getField(StandardField.URL).orElse("");
keyAndLink.append(url.isEmpty() ? key : String.format("%s", url, key));
keyAndLink.append(OS.NEWLINE);
diff --git a/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java b/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java
index 3cf44e966fb..7c2809813d7 100644
--- a/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java
+++ b/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java
@@ -105,7 +105,7 @@ public void saveChanges() {
return;
}
- if (preferences.isKeywordSyncEnabled() && !keywordsToAdd.isEmpty()) {
+ if (preferences.getSpecialFieldsPreferences().isKeywordSyncEnabled() && !keywordsToAdd.isEmpty()) {
SpecialFieldsUtils.synchronizeSpecialFields(keywordsToAdd, keywordsToRemove);
}
@@ -125,11 +125,9 @@ private NamedCompound updateKeywords(List entries, KeywordList keyword
// put keywords back
Optional change = entry.putKeywords(keywords, preferences.getKeywordDelimiter());
- if (change.isPresent()) {
- ce.addEdit(new UndoableFieldChange(change.get()));
- }
+ change.ifPresent(fieldChange -> ce.addEdit(new UndoableFieldChange(fieldChange)));
- if (preferences.isKeywordSyncEnabled()) {
+ if (preferences.getSpecialFieldsPreferences().isKeywordSyncEnabled()) {
SpecialFieldsUtils.syncSpecialFieldsFromKeywords(entry, preferences.getKeywordDelimiter());
}
}
diff --git a/src/main/java/org/jabref/gui/edit/MassSetFieldsDialog.java b/src/main/java/org/jabref/gui/edit/MassSetFieldsDialog.java
index 496c9f648c6..785b571ceb3 100644
--- a/src/main/java/org/jabref/gui/edit/MassSetFieldsDialog.java
+++ b/src/main/java/org/jabref/gui/edit/MassSetFieldsDialog.java
@@ -62,7 +62,7 @@ public class MassSetFieldsDialog extends BaseDialog {
this.undoManager = undoManager;
init();
- this.setTitle("Set/clear/append/rename fields");
+ this.setTitle(Localization.lang("Manage field names & content"));
this.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
this.setResultConverter(button -> {
if (button == ButtonType.OK) {
diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
index 780a953f988..068e9ecd41d 100644
--- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
+++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
@@ -25,9 +25,9 @@
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction;
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab;
diff --git a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java
index 760ad6edf80..03dc9fa06ab 100644
--- a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java
+++ b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java
@@ -76,7 +76,7 @@ public void init(BibEntry entry) {
cancelSearch();
currentEntry = entry;
- Optional citeKey = entry.getCiteKeyOptional();
+ Optional citeKey = entry.getCitationKey();
if (citeKey.isPresent()) {
startSearch(citeKey.get());
diff --git a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
index 039e229d508..d381159649b 100644
--- a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
+++ b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
@@ -18,12 +18,15 @@
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.util.BackgroundTask;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.fetcher.MrDLibFetcher;
import org.jabref.logic.l10n.Localization;
+import org.jabref.model.database.BibDatabase;
+import org.jabref.model.database.BibDatabaseModeDetection;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.preferences.JabRefPreferences;
@@ -67,6 +70,8 @@ private StackPane getRelatedArticlesPane(BibEntry entry) {
.wrap(() -> fetcher.performSearch(entry))
.onRunning(() -> progress.setVisible(true))
.onSuccess(relatedArticles -> {
+ ImportCleanup cleanup = new ImportCleanup(BibDatabaseModeDetection.inferMode(new BibDatabase(List.of(entry))));
+ cleanup.doPostCleanup(relatedArticles);
progress.setVisible(false);
root.getChildren().add(getRelatedArticleInfo(relatedArticles, fetcher));
})
diff --git a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java
index 749a21ba131..aba1aca5363 100644
--- a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java
+++ b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java
@@ -19,8 +19,8 @@
import javafx.scene.control.Tooltip;
import javafx.scene.input.InputMethodRequests;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.SimpleCommand;
@@ -278,10 +278,10 @@ private void storeSource(BibEntry outOfFocusEntry, String text) {
NamedCompound compound = new NamedCompound(Localization.lang("source edit"));
BibEntry newEntry = database.getEntries().get(0);
- String newKey = newEntry.getCiteKeyOptional().orElse(null);
+ String newKey = newEntry.getCitationKey().orElse(null);
if (newKey != null) {
- outOfFocusEntry.setCiteKey(newKey);
+ outOfFocusEntry.setCitationKey(newKey);
} else {
outOfFocusEntry.clearCiteKey();
}
diff --git a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java
index 5ae41bd4c24..d98e5e59d91 100644
--- a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java
+++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabViewModel.java
@@ -16,8 +16,8 @@
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
-import org.jabref.Globals;
import org.jabref.gui.AbstractViewModel;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.FileAnnotationCache;
diff --git a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
index 924adeacbc3..116c84e14c7 100644
--- a/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/exporter/CreateModifyExporterDialogViewModel.java
@@ -70,7 +70,7 @@ public ExporterViewModel saveExporter() {
// Create a new exporter to be returned to ExportCustomizationDialogViewModel, which requested it
LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(repository);
- SavePreferences savePreferences = preferences.loadForExportFromPreferences();
+ SavePreferences savePreferences = preferences.getSavePreferencesForExport();
TemplateExporter format = new TemplateExporter(name.get(), layoutFile.get(), extension.get(),
layoutPreferences, savePreferences);
format.setCustomExport(true);
diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java
index 3a9534fcf65..70f4e5adca0 100644
--- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java
+++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java
@@ -7,8 +7,8 @@
import javafx.stage.FileChooser;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.BackgroundTask;
@@ -53,8 +53,8 @@ public ExportCommand(JabRefFrame frame, boolean selectedOnly, JabRefPreferences
public void execute() {
List customExporters = preferences.getCustomExportFormats(Globals.journalAbbreviationRepository);
LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
- SavePreferences savePreferences = preferences.loadForExportFromPreferences();
- XmpPreferences xmpPreferences = preferences.getXMPPreferences();
+ SavePreferences savePreferences = preferences.getSavePreferencesForExport();
+ XmpPreferences xmpPreferences = preferences.getXmpPreferences();
// Get list of exporters and sort before adding to file dialog
List exporters = Globals.exportFactory.getExporters().stream()
diff --git a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
index 02ade4ac4bc..b40ff5cb952 100644
--- a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
+++ b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java
@@ -13,10 +13,10 @@
import javafx.scene.input.ClipboardContent;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.BackgroundTask;
diff --git a/src/main/java/org/jabref/gui/exporter/SaveAction.java b/src/main/java/org/jabref/gui/exporter/SaveAction.java
index eadd350770a..2a80a25148d 100644
--- a/src/main/java/org/jabref/gui/exporter/SaveAction.java
+++ b/src/main/java/org/jabref/gui/exporter/SaveAction.java
@@ -1,6 +1,6 @@
package org.jabref.gui.exporter;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
diff --git a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java
index 0e9770c034f..4c2c1dd69a3 100644
--- a/src/main/java/org/jabref/gui/exporter/SaveAllAction.java
+++ b/src/main/java/org/jabref/gui/exporter/SaveAllAction.java
@@ -1,8 +1,8 @@
package org.jabref.gui.exporter;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
index 8abfc0dfc18..42c5a572c48 100644
--- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
+++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
@@ -28,11 +28,11 @@
import org.jabref.logic.exporter.SavePreferences;
import org.jabref.logic.l10n.Encodings;
import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.shared.DatabaseLocation;
import org.jabref.logic.shared.prefs.SharedDatabasePreferences;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.event.ChangePropagation;
-import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.preferences.JabRefPreferences;
@@ -166,7 +166,7 @@ private Optional askForSavePath() {
private boolean save(BibDatabaseContext bibDatabaseContext, SaveDatabaseMode mode) {
Optional databasePath = bibDatabaseContext.getDatabasePath();
- if (!databasePath.isPresent()) {
+ if (databasePath.isEmpty()) {
Optional savePath = askForSavePath();
if (!savePath.isPresent()) {
return false;
@@ -216,10 +216,10 @@ private boolean save(Path targetPath, SaveDatabaseMode mode) {
}
private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding, SavePreferences.DatabaseSaveType saveType) throws SaveException {
- SavePreferences preferences = this.preferences.loadForSaveFromPreferences()
+ SavePreferences preferences = this.preferences.getSavePreferences()
.withEncoding(encoding)
.withSaveType(saveType);
- try (AtomicFileWriter fileWriter = new AtomicFileWriter(file, preferences.getEncoding(), preferences.makeBackup())) {
+ try (AtomicFileWriter fileWriter = new AtomicFileWriter(file, preferences.getEncoding(), preferences.shouldMakeBackup())) {
BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(fileWriter, preferences, entryTypesManager);
if (selectedOnly) {
diff --git a/src/main/java/org/jabref/gui/exporter/WriteXMPAction.java b/src/main/java/org/jabref/gui/exporter/WriteXMPAction.java
index 90ed161d558..51570c8fdfa 100644
--- a/src/main/java/org/jabref/gui/exporter/WriteXMPAction.java
+++ b/src/main/java/org/jabref/gui/exporter/WriteXMPAction.java
@@ -20,9 +20,9 @@
import javafx.scene.paint.Color;
import javafx.stage.Stage;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.FXDialog;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.util.BackgroundTask;
@@ -117,7 +117,7 @@ private void writeXMP() {
.collect(Collectors.toList());
Platform.runLater(() -> optionsDialog.getProgressArea()
- .appendText(entry.getCiteKeyOptional().orElse(Localization.lang("undefined")) + "\n"));
+ .appendText(entry.getCitationKey().orElse(Localization.lang("undefined")) + "\n"));
if (files.isEmpty()) {
skipped++;
@@ -127,7 +127,7 @@ private void writeXMP() {
for (Path file : files) {
if (Files.exists(file)) {
try {
- XmpUtilWriter.writeXmp(file, entry, database, Globals.prefs.getXMPPreferences());
+ XmpUtilWriter.writeXmp(file, entry, database, Globals.prefs.getXmpPreferences());
Platform.runLater(
() -> optionsDialog.getProgressArea().appendText(" " + Localization.lang("OK") + ".\n"));
entriesChanged++;
diff --git a/src/main/java/org/jabref/gui/externalfiles/AutoLinkFilesAction.java b/src/main/java/org/jabref/gui/externalfiles/AutoLinkFilesAction.java
index 505137edc35..487e9250a33 100644
--- a/src/main/java/org/jabref/gui/externalfiles/AutoLinkFilesAction.java
+++ b/src/main/java/org/jabref/gui/externalfiles/AutoLinkFilesAction.java
@@ -52,8 +52,12 @@ public void execute() {
List entries = stateManager.getSelectedEntries();
final NamedCompound nc = new NamedCompound(Localization.lang("Automatically set file links"));
- AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(database, preferences.getFilePreferences(), preferences.getAutoLinkPreferences(), ExternalFileTypes.getInstance());
- Task> linkFilesTask = new Task>() {
+ AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(
+ database,
+ preferences.getFilePreferences(),
+ preferences.getAutoLinkPreferences(),
+ ExternalFileTypes.getInstance());
+ Task> linkFilesTask = new Task<>() {
@Override
protected List call() {
diff --git a/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java b/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java
index f771d0bed44..70927daa0a6 100644
--- a/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java
+++ b/src/main/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtil.java
@@ -14,17 +14,17 @@
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableFieldChange;
import org.jabref.gui.util.DefaultTaskExecutor;
+import org.jabref.logic.bibtex.FileFieldWriter;
import org.jabref.logic.util.io.AutoLinkPreferences;
import org.jabref.logic.util.io.FileFinder;
import org.jabref.logic.util.io.FileFinders;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.FileFieldWriter;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.StandardField;
-import org.jabref.model.metadata.FilePreferences;
import org.jabref.model.util.FileHelper;
+import org.jabref.preferences.FilePreferences;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/org/jabref/gui/externalfiles/DownloadFullTextAction.java b/src/main/java/org/jabref/gui/externalfiles/DownloadFullTextAction.java
index 73bf06cce21..019678e7d84 100644
--- a/src/main/java/org/jabref/gui/externalfiles/DownloadFullTextAction.java
+++ b/src/main/java/org/jabref/gui/externalfiles/DownloadFullTextAction.java
@@ -10,8 +10,8 @@
import javafx.concurrent.Task;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
@@ -126,7 +126,7 @@ private void downloadFullTexts(Map> downloads, BibDataba
addLinkedFileFromURL(databaseContext, result.get(), entry, dir.get());
} else {
dialogService.notify(Localization.lang("No full text document found for entry %0.",
- entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ entry.getCitationKey().orElse(Localization.lang("undefined"))));
}
}
}
@@ -150,7 +150,7 @@ private void addLinkedFileFromURL(BibDatabaseContext databaseContext, URL url, B
databaseContext,
Globals.TASK_EXECUTOR,
dialogService,
- preferences.getXMPPreferences(),
+ preferences.getXmpPreferences(),
preferences.getFilePreferences(),
ExternalFileTypes.getInstance());
@@ -164,11 +164,11 @@ private void addLinkedFileFromURL(BibDatabaseContext databaseContext, URL url, B
ExternalFileTypes.getInstance());
entry.addFile(downloadedFile);
dialogService.notify(Localization.lang("Finished downloading full text document for entry %0.",
- entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ entry.getCitationKey().orElse(Localization.lang("undefined"))));
});
downloadTask.titleProperty().set(Localization.lang("Downloading"));
downloadTask.messageProperty().set(
- Localization.lang("Fulltext for") + ": " + entry.getCiteKeyOptional().orElse(Localization.lang("New entry")));
+ Localization.lang("Fulltext for") + ": " + entry.getCitationKey().orElse(Localization.lang("New entry")));
downloadTask.showToUser(true);
Globals.TASK_EXECUTOR.execute(downloadTask);
} catch (MalformedURLException exception) {
@@ -176,7 +176,7 @@ private void addLinkedFileFromURL(BibDatabaseContext databaseContext, URL url, B
}
} else {
dialogService.notify(Localization.lang("Full text document for entry %0 already linked.",
- entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ entry.getCitationKey().orElse(Localization.lang("undefined"))));
}
}
}
diff --git a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java
index 657ece362e5..2c5dfa66571 100644
--- a/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java
+++ b/src/main/java/org/jabref/gui/externalfiles/ExternalFilesEntryLinker.java
@@ -14,7 +14,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
-import org.jabref.model.metadata.FilePreferences;
+import org.jabref.preferences.FilePreferences;
public class ExternalFilesEntryLinker {
diff --git a/src/main/java/org/jabref/gui/externalfiles/FindUnlinkedFilesDialog.java b/src/main/java/org/jabref/gui/externalfiles/FindUnlinkedFilesDialog.java
index ceaea36f3d2..cbef3f235f6 100644
--- a/src/main/java/org/jabref/gui/externalfiles/FindUnlinkedFilesDialog.java
+++ b/src/main/java/org/jabref/gui/externalfiles/FindUnlinkedFilesDialog.java
@@ -35,8 +35,8 @@
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.importer.UnlinkedFilesCrawler;
@@ -57,7 +57,7 @@
import org.slf4j.LoggerFactory;
/**
- * GUI Dialog for the feature "Find unlinked files".
+ * GUI Dialog for the feature "Search for unlinked local files".
*/
public class FindUnlinkedFilesDialog extends BaseDialog {
@@ -77,7 +77,7 @@ public class FindUnlinkedFilesDialog extends BaseDialog {
public FindUnlinkedFilesDialog(BibDatabaseContext database, DialogService dialogService, CountingUndoManager undoManager) {
super();
- this.setTitle(Localization.lang("Find unlinked files"));
+ this.setTitle(Localization.lang("Search for unlinked local files"));
this.dialogService = dialogService;
databaseContext = database;
diff --git a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java
index 9ffed42bc07..dcb570a82cd 100644
--- a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java
+++ b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java
@@ -8,13 +8,14 @@
import javax.swing.undo.CompoundEdit;
import javax.swing.undo.UndoManager;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.undo.UndoableInsertEntries;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.externalfiles.ExternalFilesContentImporter;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.util.UpdateField;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.FieldChange;
@@ -107,7 +108,8 @@ private BibEntry createEmptyEntryWithLink(Path file) {
public void importEntries(List entries) {
// TODO: Add undo/redo
// undoManager.addEdit(new UndoableInsertEntries(panel.getDatabase(), entries));
-
+ ImportCleanup cleanup = new ImportCleanup(database.getMode());
+ cleanup.doPostCleanup(entries);
database.getDatabase().insertEntries(entries);
// Set owner/timestamp
@@ -115,7 +117,7 @@ public void importEntries(List entries) {
preferencesService.getOwnerPreferences(),
preferencesService.getTimestampPreferences());
- // Generate bibtex keys
+ // Generate citation keys
generateKeys(entries);
// Add to group
diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java
index 485a050523c..1fca8528a39 100644
--- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java
+++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java
@@ -10,8 +10,8 @@
import java.util.Set;
import java.util.TreeSet;
-import org.jabref.Globals;
-import org.jabref.model.entry.FileFieldWriter;
+import org.jabref.gui.Globals;
+import org.jabref.logic.bibtex.FileFieldWriter;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.strings.StringUtil;
import org.jabref.model.util.FileHelper;
diff --git a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java
index 064b8808bdf..a2d47b08a68 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/AbstractEditorViewModel.java
@@ -7,8 +7,8 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
-import org.jabref.JabRefGUI;
import org.jabref.gui.AbstractViewModel;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.undo.UndoableFieldChange;
import org.jabref.gui.util.BindingsHelper;
@@ -23,7 +23,6 @@
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
import de.saxsys.mvvmfx.utils.validation.Validator;
-import org.apache.commons.lang3.StringUtils;
import org.controlsfx.control.textfield.AutoCompletionBinding;
public class AbstractEditorViewModel extends AbstractViewModel {
@@ -66,10 +65,10 @@ public void bindToEntry(BibEntry entry) {
newValue -> {
if (newValue != null) {
// Controlsfx uses hardcoded \n for multiline fields, but JabRef stores them in OS Newlines format
- String oldValue = entry.getField(field).map(value -> value.replace(OS.NEWLINE, "\n")).orElse(null);
+ String oldValue = entry.getField(field).map(value -> value.replace(OS.NEWLINE, "\n").trim()).orElse(null);
// Autosave and save action trigger the entry editor to reload the fields, so we have to
// check for changes here, otherwise the cursor position is annoyingly reset every few seconds
- if (!(newValue.trim()).equals(StringUtils.trim(oldValue))) {
+ if (!(newValue.trim()).equals(oldValue)) {
entry.setField(field, newValue);
UndoManager undoManager = JabRefGUI.getMainFrame().getUndoManager();
undoManager.addEdit(new UndoableFieldChange(entry, field, oldValue, newValue));
diff --git a/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.fxml
index 5e38d8c98ab..fcb4b34414c 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.fxml
+++ b/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.fxml
@@ -6,5 +6,5 @@
-
+
diff --git a/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.java b/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.java
index 7f1ac67d27a..84c8e73429a 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/CitationKeyEditor.java
@@ -22,8 +22,8 @@
public class CitationKeyEditor extends HBox implements FieldEditorFX {
private final JabRefPreferences preferences;
- @FXML private CitationKeyEditorViewModel viewModel;
- @FXML private Button generateCiteKeyButton;
+ @FXML private final CitationKeyEditorViewModel viewModel;
+ @FXML private Button generateCitationKeyButton;
@FXML private EditorTextField textField;
public CitationKeyEditor(Field field,
@@ -61,12 +61,12 @@ public CitationKeyEditorViewModel getViewModel() {
public void bindToEntry(BibEntry entry) {
viewModel.bindToEntry(entry);
- // Configure cite key button
+ // Configure button to generate citation key
new ActionFactory(preferences.getKeyBindingRepository())
.configureIconButton(
StandardActions.GENERATE_CITE_KEY,
viewModel.getGenerateCiteKeyCommand(),
- generateCiteKeyButton);
+ generateCitationKeyButton);
}
@Override
diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
index f0c0d9f4467..a342e9c74e6 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
@@ -14,6 +14,7 @@
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.model.database.BibDatabaseContext;
+import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.FieldProperty;
@@ -27,6 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressWarnings("unchecked")
public class FieldEditors {
private static final Logger LOGGER = LoggerFactory.getLogger(FieldEditors.class);
@@ -83,9 +85,9 @@ public static FieldEditorFX getForField(final Field field,
return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers));
}
} else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) {
- return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
+ return new LinkedEntriesEditor(field, databaseContext, (SuggestionProvider) suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
- return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
+ return new LinkedEntriesEditor(field, databaseContext, (SuggestionProvider) suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isMultiLine);
} else if (StandardField.KEYWORDS.equals(field)) {
@@ -98,7 +100,6 @@ public static FieldEditorFX getForField(final Field field,
}
}
- @SuppressWarnings("unchecked")
private static SuggestionProvider> getSuggestionProvider(Field field, SuggestionProviders suggestionProviders, MetaData metaData) {
SuggestionProvider> suggestionProvider = suggestionProviders.getForField(field);
diff --git a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java
index b85942e0c25..7c18e322bfd 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java
@@ -8,8 +8,8 @@
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
-import org.jabref.JabRefGUI;
import org.jabref.gui.DialogService;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.mergeentries.FetchAndMergeEntry;
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml
index d473486a222..4b75bbe6311 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java
index 9568cfce925..3067ee36a11 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java
@@ -1,13 +1,14 @@
package org.jabref.gui.fieldeditors;
+import java.util.stream.Collectors;
+
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.layout.HBox;
-import org.jabref.gui.autocompleter.AutoCompletionTextInputBinding;
import org.jabref.gui.autocompleter.SuggestionProvider;
-import org.jabref.gui.util.component.TagBar;
+import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
@@ -15,27 +16,38 @@
import org.jabref.model.entry.field.Field;
import com.airhacks.afterburner.views.ViewLoader;
+import com.jfoenix.controls.JFXChip;
+import com.jfoenix.controls.JFXChipView;
+import com.jfoenix.controls.JFXDefaultChip;
public class LinkedEntriesEditor extends HBox implements FieldEditorFX {
@FXML
private final LinkedEntriesEditorViewModel viewModel;
@FXML
- private TagBar linkedEntriesBar;
+ private JFXChipView chipView;
- public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, SuggestionProvider> suggestionProvider, FieldCheckers fieldCheckers) {
+ public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, SuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) {
this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers);
ViewLoader.view(this)
.root(this)
.load();
- linkedEntriesBar.setFieldProperties(field.getProperties());
- linkedEntriesBar.setStringConverter(viewModel.getStringConverter());
- linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink));
+ chipView.setConverter(viewModel.getStringConverter());
+ var autoCompletionItemFactory = new ViewModelListCellFactory()
+ .withText(ParsedEntryLink::getKey);
+ chipView.getAutoCompletePopup().setSuggestionsCellFactory(autoCompletionItemFactory);
+ chipView.getAutoCompletePopup().setCellLimit(5);
+ chipView.getSuggestions().addAll(suggestionProvider.getPossibleSuggestions().stream().map(ParsedEntryLink::new).collect(Collectors.toList()));
+
+ chipView.setChipFactory((view, item) -> {
+ JFXChip chip = new JFXDefaultChip<>(view, item);
+ chip.setOnMouseClicked(event -> viewModel.jumpToEntry(item));
+ return chip;
+ });
- AutoCompletionTextInputBinding.autoComplete(linkedEntriesBar.getInputTextField(), viewModel::complete, viewModel.getStringConverter());
- Bindings.bindContentBidirectional(linkedEntriesBar.tagsProperty(), viewModel.linkedEntriesProperty());
+ Bindings.bindContentBidirectional(chipView.getChips(), viewModel.linkedEntriesProperty());
}
public LinkedEntriesEditorViewModel getViewModel() {
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditorViewModel.java
index cdd2f3c9581..947294e5234 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditorViewModel.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditorViewModel.java
@@ -1,8 +1,5 @@
package org.jabref.gui.fieldeditors;
-import java.util.Collection;
-import java.util.stream.Collectors;
-
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
@@ -12,13 +9,10 @@
import org.jabref.gui.util.BindingsHelper;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.EntryLinkList;
import org.jabref.model.entry.ParsedEntryLink;
import org.jabref.model.entry.field.Field;
-import org.controlsfx.control.textfield.AutoCompletionBinding;
-
public class LinkedEntriesEditorViewModel extends AbstractEditorViewModel {
private final BibDatabaseContext databaseContext;
@@ -36,20 +30,12 @@ public LinkedEntriesEditorViewModel(Field field, SuggestionProvider> suggestio
newText -> EntryLinkList.parse(newText, databaseContext.getDatabase()));
}
- @Override
- @SuppressWarnings("unchecked")
- public Collection complete(AutoCompletionBinding.ISuggestionRequest request) {
- // We have to cast the BibEntries from the BibEntrySuggestionProvider to ParsedEntryLink
- Collection bibEntries = (Collection) super.complete(request);
- return bibEntries.stream().map(ParsedEntryLink::new).collect(Collectors.toList());
- }
-
public ListProperty linkedEntriesProperty() {
return linkedEntries;
}
public StringConverter getStringConverter() {
- return new StringConverter() {
+ return new StringConverter<>() {
@Override
public String toString(ParsedEntryLink linkedEntry) {
@@ -61,7 +47,7 @@ public String toString(ParsedEntryLink linkedEntry) {
@Override
public ParsedEntryLink fromString(String key) {
- return databaseContext.getDatabase().getEntryByKey(key).map(ParsedEntryLink::new).orElse(null);
+ return new ParsedEntryLink(key, databaseContext.getDatabase());
}
};
}
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
index 7e4dafd5f04..07a25bf4254 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
@@ -45,10 +45,10 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
-import org.jabref.model.metadata.FilePreferences;
import org.jabref.model.strings.StringUtil;
import org.jabref.model.util.FileHelper;
import org.jabref.model.util.OptionalUtil;
+import org.jabref.preferences.FilePreferences;
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
@@ -449,7 +449,7 @@ public void download() {
downloadProgress.bind(downloadTask.workDonePercentageProperty());
downloadTask.titleProperty().set(Localization.lang("Downloading"));
downloadTask.messageProperty().set(
- Localization.lang("Fulltext for") + ": " + entry.getCiteKeyOptional().orElse(Localization.lang("New entry")));
+ Localization.lang("Fulltext for") + ": " + entry.getCitationKey().orElse(Localization.lang("New entry")));
downloadTask.showToUser(true);
taskExecutor.execute(downloadTask);
} catch (MalformedURLException exception) {
@@ -465,7 +465,7 @@ public BackgroundTask prepareDownloadTask(Path targetDirectory, URLDownloa
String suggestedTypeName = externalFileType.getName();
linkedFile.setFileType(suggestedTypeName);
String suggestedName = linkedFileHandler.getSuggestedFileName(externalFileType.getExtension());
- String fulltextDir = FileUtil.createDirNameFromPattern(databaseContext.getDatabase(), entry, filePreferences.getFileDirPattern());
+ String fulltextDir = FileUtil.createDirNameFromPattern(databaseContext.getDatabase(), entry, filePreferences.getFileDirectoryPattern());
suggestedName = FileNameUniqueness.getNonOverWritingFileName(targetDirectory.resolve(fulltextDir), suggestedName);
return targetDirectory.resolve(fulltextDir).resolve(suggestedName);
})
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
index 4f79ed45d4b..63e80affa7e 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
@@ -25,9 +25,9 @@
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.DragAndDropDataFormats;
+import org.jabref.gui.Globals;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.copyfiles.CopySingleFileAction;
import org.jabref.gui.icon.IconTheme;
diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java
index 23b8c6b7dc5..e4ec2b9e3a2 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java
@@ -27,14 +27,14 @@
import org.jabref.gui.util.BindingsHelper;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.TaskExecutor;
+import org.jabref.logic.bibtex.FileFieldWriter;
import org.jabref.logic.importer.FulltextFetchers;
+import org.jabref.logic.importer.util.FileFieldParser;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.FileFieldParser;
-import org.jabref.model.entry.FileFieldWriter;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.Field;
import org.jabref.model.util.FileHelper;
@@ -101,7 +101,15 @@ public LinkedFileViewModel fromFile(Path file) {
List fileDirectories = databaseContext.getFileDirectoriesAsPaths(preferences.getFilePreferences());
LinkedFile linkedFile = fromFile(file, fileDirectories, externalFileTypes);
- return new LinkedFileViewModel(linkedFile, entry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), externalFileTypes);
+ return new LinkedFileViewModel(
+ linkedFile,
+ entry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ preferences.getFilePreferences(),
+ externalFileTypes);
}
public boolean isFulltextLookupInProgress() {
@@ -114,7 +122,15 @@ public BooleanProperty fulltextLookupInProgressProperty() {
private List parseToFileViewModel(String stringValue) {
return FileFieldParser.parse(stringValue).stream()
- .map(linkedFile -> new LinkedFileViewModel(linkedFile, entry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), externalFileTypes))
+ .map(linkedFile -> new LinkedFileViewModel(
+ linkedFile,
+ entry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ preferences.getFilePreferences(),
+ externalFileTypes))
.collect(Collectors.toList());
}
@@ -137,7 +153,15 @@ public void addNewFile() {
List fileDirectories = databaseContext.getFileDirectoriesAsPaths(preferences.getFilePreferences());
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(newFile -> {
LinkedFile newLinkedFile = fromFile(newFile, fileDirectories, externalFileTypes);
- files.add(new LinkedFileViewModel(newLinkedFile, entry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), externalFileTypes));
+ files.add(new LinkedFileViewModel(
+ newLinkedFile,
+ entry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ preferences.getFilePreferences(),
+ externalFileTypes));
});
}
@@ -159,11 +183,23 @@ public void bindToEntry(BibEntry entry) {
private List findAssociatedNotLinkedFiles(BibEntry entry) {
List result = new ArrayList<>();
- AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(databaseContext, preferences.getFilePreferences(), preferences.getAutoLinkPreferences(), ExternalFileTypes.getInstance());
+ AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(
+ databaseContext,
+ preferences.getFilePreferences(),
+ preferences.getAutoLinkPreferences(),
+ ExternalFileTypes.getInstance());
try {
List linkedFiles = util.findAssociatedNotLinkedFiles(entry);
for (LinkedFile linkedFile : linkedFiles) {
- LinkedFileViewModel newLinkedFile = new LinkedFileViewModel(linkedFile, entry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), externalFileTypes);
+ LinkedFileViewModel newLinkedFile = new LinkedFileViewModel(
+ linkedFile,
+ entry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ preferences.getFilePreferences(),
+ externalFileTypes);
newLinkedFile.markAsAutomaticallyFound();
result.add(newLinkedFile);
}
@@ -206,7 +242,15 @@ public void addFromURL() {
}
private void addFromURL(URL url) {
- LinkedFileViewModel onlineFile = new LinkedFileViewModel(new LinkedFile(url, ""), entry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), preferences.getFilePreferences(), externalFileTypes);
+ LinkedFileViewModel onlineFile = new LinkedFileViewModel(
+ new LinkedFile(url, ""),
+ entry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ preferences.getFilePreferences(),
+ externalFileTypes);
files.add(onlineFile);
onlineFile.download();
}
diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java
index 6539516b776..66465ef95aa 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/CaseChangeMenu.java
@@ -10,11 +10,11 @@
import javafx.scene.control.Menu;
import javafx.scene.control.Tooltip;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
+import org.jabref.logic.cleanup.Formatter;
import org.jabref.logic.formatter.Formatters;
import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.cleanup.Formatter;
class CaseChangeMenu extends Menu {
diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java
index 1bf5a1cd5ed..8e6743933b4 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ConversionMenu.java
@@ -6,9 +6,9 @@
import javafx.scene.control.Menu;
import javafx.scene.control.Tooltip;
+import org.jabref.logic.cleanup.Formatter;
import org.jabref.logic.formatter.Formatters;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.cleanup.Formatter;
/**
* Menu to show up on right-click in a text field for converting text formats
diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java
index b6b8df62bc3..53376639fbb 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java
@@ -12,7 +12,7 @@
import javafx.scene.control.TextInputControl;
import javafx.scene.control.Tooltip;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.edit.CopyDoiUrlAction;
diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java
index 85e4f8f46a1..0ebd8f1126e 100644
--- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java
+++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java
@@ -8,12 +8,12 @@
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TextInputControl;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
+import org.jabref.logic.cleanup.Formatter;
import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.protectedterms.ProtectedTermsList;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
-import org.jabref.model.cleanup.Formatter;
class ProtectedTermsMenu extends Menu {
diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
index 1eac8d42172..e7a183f1d27 100644
--- a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
@@ -22,8 +22,8 @@
import javafx.scene.control.ButtonType;
import javafx.scene.paint.Color;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.FileDialogConfiguration;
diff --git a/src/main/java/org/jabref/gui/groups/GroupsPreferences.java b/src/main/java/org/jabref/gui/groups/GroupsPreferences.java
new file mode 100644
index 00000000000..6006e8ea2b7
--- /dev/null
+++ b/src/main/java/org/jabref/gui/groups/GroupsPreferences.java
@@ -0,0 +1,36 @@
+package org.jabref.gui.groups;
+
+public class GroupsPreferences {
+
+ private final GroupViewMode groupViewMode;
+ private final boolean shouldAutoAssignGroup;
+ private final boolean shouldDisplayGroupCount;
+ private final Character keywordSeparator;
+
+ public GroupsPreferences(GroupViewMode groupViewMode,
+ boolean shouldAutoAssignGroup,
+ boolean shouldDisplayGroupCount,
+ Character keywordSeparator) {
+
+ this.groupViewMode = groupViewMode;
+ this.shouldAutoAssignGroup = shouldAutoAssignGroup;
+ this.shouldDisplayGroupCount = shouldDisplayGroupCount;
+ this.keywordSeparator = keywordSeparator;
+ }
+
+ public GroupViewMode getGroupViewMode() {
+ return groupViewMode;
+ }
+
+ public boolean shouldAutoAssignGroup() {
+ return shouldAutoAssignGroup;
+ }
+
+ public boolean shouldDisplayGroupCount() {
+ return shouldDisplayGroupCount;
+ }
+
+ public Character getKeywordDelimiter() {
+ return keywordSeparator;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/help/NewVersionDialog.java b/src/main/java/org/jabref/gui/help/NewVersionDialog.java
index a28a654b349..5c61943d2aa 100644
--- a/src/main/java/org/jabref/gui/help/NewVersionDialog.java
+++ b/src/main/java/org/jabref/gui/help/NewVersionDialog.java
@@ -7,7 +7,7 @@
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.desktop.JabRefDesktop;
import org.jabref.gui.util.BaseDialog;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/icon/IconTheme.java b/src/main/java/org/jabref/gui/icon/IconTheme.java
index f7143eb7155..649632aae4e 100644
--- a/src/main/java/org/jabref/gui/icon/IconTheme.java
+++ b/src/main/java/org/jabref/gui/icon/IconTheme.java
@@ -300,7 +300,9 @@ public enum JabRefIcons implements JabRefIcon {
REMOVE_ABBREVIATION(MaterialDesignIcon.PLAYLIST_MINUS),
NEW_ENTRY_FROM_PLAIN_TEXT(MaterialDesignIcon.PLUS_BOX),
REMOTE_DATABASE(MaterialDesignIcon.DATABASE),
- HOME(MaterialDesignIcon.HOME);
+ HOME(MaterialDesignIcon.HOME),
+ LINK(MaterialDesignIcon.LINK),
+ LINK_VARIANT(MaterialDesignIcon.LINK_VARIANT);
private final JabRefIcon icon;
diff --git a/src/main/java/org/jabref/gui/importer/ImportAction.java b/src/main/java/org/jabref/gui/importer/ImportAction.java
index d49010cb6fc..8dae27690a6 100644
--- a/src/main/java/org/jabref/gui/importer/ImportAction.java
+++ b/src/main/java/org/jabref/gui/importer/ImportAction.java
@@ -8,14 +8,15 @@
import java.util.Optional;
import java.util.stream.Collectors;
-import org.jabref.Globals;
-import org.jabref.JabRefException;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.TaskExecutor;
+import org.jabref.logic.JabRefException;
+import org.jabref.logic.database.DatabaseMerger;
import org.jabref.logic.importer.ImportException;
import org.jabref.logic.importer.ImportFormatReader;
import org.jabref.logic.importer.Importer;
@@ -23,12 +24,6 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.UpdateField;
import org.jabref.model.database.BibDatabase;
-import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.BibtexString;
-import org.jabref.model.groups.AllEntriesGroup;
-import org.jabref.model.groups.ExplicitGroup;
-import org.jabref.model.groups.GroupHierarchyType;
-import org.jabref.model.metadata.ContentSelector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -135,55 +130,15 @@ private ParserResult mergeImportResults(List entries = parserResult.getDatabase().getEntries();
- resultDatabase.insertEntries(entries);
+ resultDatabase.insertEntries(parserResult.getDatabase().getEntries());
if (ImportFormatReader.BIBTEX_FORMAT.equals(importResult.format)) {
// additional treatment of BibTeX
- // merge into existing database
-
- // Merge strings
- for (BibtexString bibtexString : parserResult.getDatabase().getStringValues()) {
- String bibtexStringName = bibtexString.getName();
- if (resultDatabase.hasStringByName(bibtexStringName)) {
- String importedContent = bibtexString.getContent();
- String existingContent = resultDatabase.getStringByName(bibtexStringName).get().getContent();
- if (!importedContent.equals(existingContent)) {
- LOGGER.warn("String contents differ for {}: {} != {}", bibtexStringName, importedContent, existingContent);
- // TODO: decide what to do here (in case the same string exits)
- }
- } else {
- resultDatabase.addString(bibtexString);
- }
- }
-
- // Merge groups
- // Adds the specified node as a child of the current root. The group contained in newGroups must not be of
- // type AllEntriesGroup, since every tree has exactly one AllEntriesGroup (its root). The newGroups are
- // inserted directly, i.e. they are not deepCopy()'d.
- parserResult.getMetaData().getGroups().ifPresent(newGroups -> {
- // ensure that there is always only one AllEntriesGroup in the resulting database
- // "Rename" the AllEntriesGroup of the imported database to "Imported"
- if (newGroups.getGroup() instanceof AllEntriesGroup) {
- // create a dummy group
- try {
- // This will cause a bug if the group already exists
- // There will be group where the two groups are merged
- String newGroupName = importResult.parserResult.getFile().map(File::getName).orElse("unknown");
- ExplicitGroup group = new ExplicitGroup("Imported " + newGroupName, GroupHierarchyType.INDEPENDENT,
- Globals.prefs.getKeywordDelimiter());
- newGroups.setGroup(group);
- group.add(parserResult.getDatabase().getEntries());
- } catch (IllegalArgumentException e) {
- LOGGER.error("Problem appending entries to group", e);
- }
- }
- result.getMetaData().getGroups().ifPresent(newGroups::moveTo);
- });
-
- for (ContentSelector selector : parserResult.getMetaData().getContentSelectorList()) {
- result.getMetaData().addContentSelector(selector);
- }
+ new DatabaseMerger().mergeMetaData(
+ result.getMetaData(),
+ parserResult.getMetaData(),
+ importResult.parserResult.getFile().map(File::getName).orElse("unknown"),
+ parserResult.getDatabase().getEntries());
}
// TODO: collect errors into ParserResult, because they are currently ignored (see caller of this method)
}
diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java
index 8eb8284ca35..ff405f2f94a 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCommand.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java
@@ -8,8 +8,8 @@
import javafx.stage.FileChooser;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
index c6f2f5f2b3b..2eb2c2e4e50 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
@@ -6,7 +6,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.EntryTypeFactory;
diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomizationDialogViewModel.java b/src/main/java/org/jabref/gui/importer/ImportCustomizationDialogViewModel.java
index 90ac43ee424..468428821a0 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCustomizationDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCustomizationDialogViewModel.java
@@ -9,9 +9,9 @@
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
-import org.jabref.Globals;
import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.importer.fileformat.CustomImporter;
import org.jabref.logic.l10n.Localization;
@@ -120,7 +120,10 @@ public void removeSelectedImporter() {
public void saveToPrefs() {
Globals.prefs.customImports.clear();
Globals.prefs.customImports.addAll(importers);
- Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor());
+ Globals.IMPORT_FORMAT_READER.resetImportFormats(
+ Globals.prefs.getImportFormatPreferences(),
+ Globals.prefs.getXmpPreferences(),
+ Globals.getFileUpdateMonitor());
}
public ListProperty selectedImportersProperty() {
diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java b/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java
index 4d22ee4433d..0d98779b57a 100644
--- a/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java
+++ b/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java
@@ -21,8 +21,8 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.BackgroundTask;
diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
index 2c12cd4cda4..7b2bdd92be2 100644
--- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
@@ -1,5 +1,6 @@
package org.jabref.gui.importer;
+import java.io.File;
import java.util.List;
import java.util.Optional;
@@ -10,42 +11,30 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import org.jabref.Globals;
-import org.jabref.JabRefGUI;
import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.StateManager;
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
import org.jabref.gui.externalfiles.ImportHandler;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
-import org.jabref.gui.groups.GroupTreeNodeViewModel;
-import org.jabref.gui.groups.UndoableAddOrRemoveGroup;
-import org.jabref.gui.undo.NamedCompound;
-import org.jabref.gui.undo.UndoableInsertEntries;
-import org.jabref.gui.undo.UndoableInsertString;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.TaskExecutor;
-import org.jabref.logic.bibtex.DuplicateCheck;
+import org.jabref.logic.database.DatabaseMerger;
+import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.BibtexString;
import org.jabref.model.entry.LinkedFile;
-import org.jabref.model.groups.GroupTreeNode;
-import org.jabref.model.metadata.FilePreferences;
-import org.jabref.model.metadata.MetaData;
import org.jabref.model.util.FileUpdateMonitor;
+import org.jabref.preferences.FilePreferences;
import org.jabref.preferences.PreferencesService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public class ImportEntriesViewModel extends AbstractViewModel {
- private static final Logger LOGGER = LoggerFactory.getLogger(ImportEntriesViewModel.class);
-
private final StringProperty message;
private final TaskExecutor taskExecutor;
private final BibDatabaseContext databaseContext;
@@ -61,7 +50,14 @@ public class ImportEntriesViewModel extends AbstractViewModel {
* @param databaseContext the database to import into
* @param task the task executed for parsing the selected files(s).
*/
- public ImportEntriesViewModel(BackgroundTask task, TaskExecutor taskExecutor, BibDatabaseContext databaseContext, DialogService dialogService, UndoManager undoManager, PreferencesService preferences, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor) {
+ public ImportEntriesViewModel(BackgroundTask task,
+ TaskExecutor taskExecutor,
+ BibDatabaseContext databaseContext,
+ DialogService dialogService,
+ UndoManager undoManager,
+ PreferencesService preferences,
+ StateManager stateManager,
+ FileUpdateMonitor fileUpdateMonitor) {
this.taskExecutor = taskExecutor;
this.databaseContext = databaseContext;
this.dialogService = dialogService;
@@ -94,9 +90,9 @@ public ObservableList getEntries() {
}
public boolean hasDuplicate(BibEntry entry) {
- return findInternalDuplicate(entry).isPresent()
- ||
- new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()).isPresent();
+ return findInternalDuplicate(entry).isPresent() ||
+ new DuplicateCheck(Globals.entryTypesManager)
+ .containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()).isPresent();
}
/**
@@ -132,71 +128,33 @@ public void importEntries(List entriesToImport, boolean shouldDownload
}
// Remember the selection in the dialog
- FilePreferences filePreferences = preferences.getFilePreferences();
- filePreferences.setShouldDownloadLinkedFiles(shouldDownloadFiles);
+ FilePreferences filePreferences = preferences.getFilePreferences()
+ .withShouldDownloadLinkedFiles(shouldDownloadFiles);
preferences.storeFilePreferences(filePreferences);
if (shouldDownloadFiles) {
for (BibEntry bibEntry : entriesToImport) {
for (LinkedFile linkedFile : bibEntry.getFiles()) {
- LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(linkedFile, bibEntry, databaseContext, taskExecutor, dialogService, preferences.getXMPPreferences(), filePreferences, ExternalFileTypes.getInstance());
+ LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(
+ linkedFile,
+ bibEntry,
+ databaseContext,
+ taskExecutor,
+ dialogService,
+ preferences.getXmpPreferences(),
+ filePreferences,
+ ExternalFileTypes.getInstance());
linkedFileViewModel.download();
}
}
}
- NamedCompound namedCompound = new NamedCompound(Localization.lang("Import file"));
- namedCompound.addEdit(new UndoableInsertEntries(databaseContext.getDatabase(), entriesToImport));
-
- // merge strings into target database
- for (BibtexString bibtexString : parserResult.getDatabase().getStringValues()) {
- String bibtexStringName = bibtexString.getName();
- if (databaseContext.getDatabase().hasStringByName(bibtexStringName)) {
- String importedContent = bibtexString.getContent();
- String existingContent = databaseContext.getDatabase().getStringByName(bibtexStringName).get().getContent();
- if (!importedContent.equals(existingContent)) {
- LOGGER.warn("String contents differ for {}: {} != {}", bibtexStringName, importedContent, existingContent);
- // TODO: decide what to do here (in case the same string exits)
- }
- } else {
- databaseContext.getDatabase().addString(bibtexString);
- // FIXME: this prevents this method to be moved to logic - we need to implement a new undo/redo data model
- namedCompound.addEdit(new UndoableInsertString(databaseContext.getDatabase(), bibtexString));
- }
- }
-
- // copy content selectors to target database
- MetaData targetMetada = databaseContext.getMetaData();
- parserResult.getMetaData()
- .getContentSelectorList()
- .forEach(targetMetada::addContentSelector);
- // TODO undo of content selectors (currently not implemented)
-
- // copy groups to target database
- parserResult.getMetaData().getGroups().ifPresent(
- newGroupsTreeNode -> {
- if (targetMetada.getGroups().isPresent()) {
- GroupTreeNode groupTreeNode = targetMetada.getGroups().get();
- newGroupsTreeNode.moveTo(groupTreeNode);
- namedCompound.addEdit(
- new UndoableAddOrRemoveGroup(
- new GroupTreeNodeViewModel(groupTreeNode),
- new GroupTreeNodeViewModel(newGroupsTreeNode),
- UndoableAddOrRemoveGroup.ADD_NODE));
- } else {
- // target does not contain any groups, so we can just use the new groups
- targetMetada.setGroups(newGroupsTreeNode);
- namedCompound.addEdit(
- new UndoableAddOrRemoveGroup(
- new GroupTreeNodeViewModel(newGroupsTreeNode),
- new GroupTreeNodeViewModel(newGroupsTreeNode),
- UndoableAddOrRemoveGroup.ADD_NODE));
- }
- }
- );
+ new DatabaseMerger().mergeStrings(databaseContext.getDatabase(), parserResult.getDatabase());
+ new DatabaseMerger().mergeMetaData(databaseContext.getMetaData(),
+ parserResult.getMetaData(),
+ parserResult.getFile().map(File::getName).orElse("unknown"),
+ parserResult.getDatabase().getEntries());
- namedCompound.end();
- Globals.undoManager.addEdit(namedCompound);
JabRefGUI.getMainFrame().getCurrentBasePanel().markBaseChanged();
}
diff --git a/src/main/java/org/jabref/gui/importer/NewEntryAction.java b/src/main/java/org/jabref/gui/importer/NewEntryAction.java
index 638b6ba40a5..6221b335413 100644
--- a/src/main/java/org/jabref/gui/importer/NewEntryAction.java
+++ b/src/main/java/org/jabref/gui/importer/NewEntryAction.java
@@ -4,9 +4,9 @@
import java.util.Map;
import java.util.Optional;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.EntryTypeView;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/importer/UnlinkedPDFFileFilter.java b/src/main/java/org/jabref/gui/importer/UnlinkedPDFFileFilter.java
index 6404e716c8d..f374fe5fd1a 100644
--- a/src/main/java/org/jabref/gui/importer/UnlinkedPDFFileFilter.java
+++ b/src/main/java/org/jabref/gui/importer/UnlinkedPDFFileFilter.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.io.FileFilter;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.util.io.DatabaseFileLookup;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
diff --git a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java
index 867e2b8565b..86c50d19051 100644
--- a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java
@@ -3,8 +3,8 @@
import java.util.List;
import java.util.stream.Collectors;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
+import org.jabref.gui.Globals;
import org.jabref.gui.importer.ImportCustomEntryTypesDialog;
import org.jabref.logic.importer.ParserResult;
import org.jabref.model.database.BibDatabaseMode;
diff --git a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentConfirmationDialog.java b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentConfirmationDialog.java
index f9fc3559985..ece4bb4e079 100644
--- a/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentConfirmationDialog.java
+++ b/src/main/java/org/jabref/gui/importer/actions/MergeReviewIntoCommentConfirmationDialog.java
@@ -19,7 +19,7 @@ public MergeReviewIntoCommentConfirmationDialog(DialogService dialogService) {
public boolean askUserForMerge(List conflicts) {
String bibKeys = conflicts
.stream()
- .map(BibEntry::getCiteKeyOptional)
+ .map(BibEntry::getCitationKey)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.joining(",\n"));
diff --git a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
index cf78a65f58d..467675a6a00 100644
--- a/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java
@@ -11,10 +11,10 @@
import java.util.Objects;
import java.util.Optional;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.BasePanelPreferences;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.dialogs.BackupUIManager;
@@ -27,10 +27,10 @@
import org.jabref.logic.importer.OpenDatabase;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.shared.DatabaseNotSupportedException;
import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException;
import org.jabref.logic.shared.exception.NotASharedDatabaseException;
import org.jabref.logic.util.StandardFileType;
-import org.jabref.model.database.shared.DatabaseNotSupportedException;
import org.jabref.preferences.JabRefPreferences;
import org.slf4j.Logger;
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/LookupIdentifierAction.java b/src/main/java/org/jabref/gui/importer/fetcher/LookupIdentifierAction.java
index 31c03ca36fc..65bfba288aa 100644
--- a/src/main/java/org/jabref/gui/importer/fetcher/LookupIdentifierAction.java
+++ b/src/main/java/org/jabref/gui/importer/fetcher/LookupIdentifierAction.java
@@ -5,7 +5,7 @@
import javax.swing.undo.UndoManager;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.Action;
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
index 64b005c2f1b..30c3c260c4c 100644
--- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
+++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
@@ -70,7 +70,16 @@ protected Node createContentPane() {
// Create text field for query input
TextField query = SearchTextField.create();
- query.setOnAction(event -> viewModel.search());
+ query.getStyleClass().add("searchBar");
+ query.textProperty().addListener((observable, oldValue, newValue) -> viewModel.validateQueryStringAndGiveColorFeedback(query, newValue));
+ query.focusedProperty().addListener((observable, oldValue, newValue) -> {
+ if (newValue) {
+ viewModel.validateQueryStringAndGiveColorFeedback(query, query.getText());
+ } else {
+ viewModel.setPseudoClassToValid(query);
+ }
+ });
+
viewModel.queryProperty().bind(query.textProperty());
// Create button that triggers search
diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java
index 342d7e61fc3..a51aeb51fca 100644
--- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java
@@ -1,6 +1,9 @@
package org.jabref.gui.importer.fetcher;
+import java.util.Optional;
import java.util.SortedSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
@@ -10,6 +13,9 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import javafx.css.PseudoClass;
+import javafx.scene.control.TextField;
+import javafx.scene.control.Tooltip;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
@@ -17,8 +23,10 @@
import org.jabref.gui.util.BackgroundTask;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.ParserResult;
+import org.jabref.logic.importer.QueryParser;
import org.jabref.logic.importer.SearchBasedFetcher;
import org.jabref.logic.importer.WebFetchers;
+import org.jabref.logic.importer.fetcher.ComplexSearchQuery;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.strings.StringUtil;
import org.jabref.preferences.JabRefPreferences;
@@ -32,6 +40,8 @@ public class WebSearchPaneViewModel {
private final StringProperty query = new SimpleStringProperty();
private final JabRefFrame frame;
private final DialogService dialogService;
+ private final Pattern queryPattern;
+ private final Pattern laxQueryPattern;
public WebSearchPaneViewModel(ImportFormatPreferences importPreferences, JabRefFrame frame, JabRefPreferences preferences, DialogService dialogService) {
// TODO: Rework so that we don't rely on JabRefFrame and not the complete preferences
@@ -52,6 +62,13 @@ public WebSearchPaneViewModel(ImportFormatPreferences importPreferences, JabRefF
int newIndex = fetchers.indexOf(newFetcher);
preferences.putInt(JabRefPreferences.SELECTED_FETCHER_INDEX, newIndex);
});
+
+ String allowedFields = "((author|journal|title|year|year-range):\\s?)?";
+ // Either a single word, or a phrase with quotes, or a year-range
+ String allowedTermText = "(((\\d{4}-\\d{4})|(\\w+)|(\"\\w+[^\"]*\"))\\s?)+";
+ queryPattern = Pattern.compile("^(" + allowedFields + allowedTermText + ")+$");
+ String laxFields = "(\\w+:\\s?)?";
+ laxQueryPattern = Pattern.compile("^(" + laxFields + allowedTermText + ")+$");
}
public ObservableList getFetchers() {
@@ -91,13 +108,57 @@ public void search() {
SearchBasedFetcher activeFetcher = getSelectedFetcher();
- BackgroundTask task = BackgroundTask.wrap(() -> new ParserResult(activeFetcher.performSearch(getQuery().trim())))
- .withInitialMessage(Localization.lang("Processing %0", getQuery()));
-
+ BackgroundTask task;
+ QueryParser queryParser = new QueryParser();
+ Optional generatedQuery = queryParser.parseQueryStringIntoComplexQuery(getQuery());
+ if (generatedQuery.isPresent()) {
+ task = BackgroundTask.wrap(() -> new ParserResult(activeFetcher.performComplexSearch(generatedQuery.get())))
+ .withInitialMessage(Localization.lang("Processing %0", getQuery()));
+ } else {
+ task = BackgroundTask.wrap(() -> new ParserResult(activeFetcher.performSearch(getQuery().trim())))
+ .withInitialMessage(Localization.lang("Processing %0", getQuery()));
+ }
task.onFailure(dialogService::showErrorDialogAndWait);
ImportEntriesDialog dialog = new ImportEntriesDialog(frame.getCurrentBasePanel().getBibDatabaseContext(), task);
dialog.setTitle(activeFetcher.getName());
dialog.showAndWait();
}
+
+ public void validateQueryStringAndGiveColorFeedback(TextField querySource, String queryString) {
+ Matcher queryValidation = queryPattern.matcher(queryString.strip());
+ if (!queryString.strip().isBlank() && !queryValidation.matches()) {
+ Matcher laxQueryValidation = laxQueryPattern.matcher(queryString.strip());
+ if (laxQueryValidation.matches()) {
+ setPseudoClassToUnsupported(querySource);
+ querySource.setTooltip(new Tooltip(Localization.lang("This query uses unsupported fields.")));
+ } else {
+ setPseudoClassToInvalid(querySource);
+ querySource.setTooltip(new Tooltip(Localization.lang("This query uses unsupported syntax.")));
+ }
+ } else if (containsYearAndYearRange(queryString)) {
+ setPseudoClassToInvalid(querySource);
+ querySource.setTooltip(new Tooltip(Localization.lang("The query cannot contain a year and year-range field.")));
+ } else {
+ setPseudoClassToValid(querySource);
+ }
+ }
+
+ private void setPseudoClassToUnsupported(TextField querySource) {
+ querySource.pseudoClassStateChanged(PseudoClass.getPseudoClass("invalid"), false);
+ querySource.pseudoClassStateChanged(PseudoClass.getPseudoClass("unsupported"), true);
+ }
+
+ public void setPseudoClassToValid(TextField querySource) {
+ querySource.pseudoClassStateChanged(PseudoClass.getPseudoClass("invalid"), false);
+ querySource.pseudoClassStateChanged(PseudoClass.getPseudoClass("unsupported"), false);
+ }
+
+ private void setPseudoClassToInvalid(TextField querySource) {
+ querySource.pseudoClassStateChanged(PseudoClass.getPseudoClass("invalid"), true);
+ }
+
+ private boolean containsYearAndYearRange(String queryString) {
+ return queryString.toLowerCase().contains("year:") && queryString.toLowerCase().contains("year-range:");
+ }
}
diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java
index 9c296288b6f..d74fd516063 100644
--- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java
+++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckAction.java
@@ -6,9 +6,9 @@
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
-import org.jabref.Globals;
import org.jabref.gui.Dialog;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java
index 3901c37006a..26de42d4bf3 100644
--- a/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java
+++ b/src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java
@@ -62,7 +62,7 @@ private void initialize() {
messagesTable.getSelectionModel().getSelectedItems().addListener(this::onSelectionChanged);
messagesTable.setItems(viewModel.getMessages());
- keyColumn.setCellValueFactory(row -> new ReadOnlyStringWrapper(row.getValue().getEntry().getCiteKeyOptional().orElse("")));
+ keyColumn.setCellValueFactory(row -> new ReadOnlyStringWrapper(row.getValue().getEntry().getCitationKey().orElse("")));
fieldColumn.setCellValueFactory(row -> new ReadOnlyStringWrapper(row.getValue().getField().getDisplayName()));
messageColumn.setCellValueFactory(row -> new ReadOnlyStringWrapper(row.getValue().getMessage()));
diff --git a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
index 7ca1e09cea2..6fd9421e2ac 100644
--- a/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
+++ b/src/main/java/org/jabref/gui/journals/AbbreviateAction.java
@@ -7,9 +7,9 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java
index 9de0c673925..deb27d04913 100644
--- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java
+++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java
@@ -12,8 +12,8 @@
import javafx.scene.control.TableView;
import javafx.scene.control.cell.TextFieldTableCell;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ControlHelper;
diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java
index 9f87403d97a..89a42d021cf 100644
--- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java
+++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsViewModel.java
@@ -20,7 +20,6 @@
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.Abbreviation;
-import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.journals.JournalAbbreviationPreferences;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
@@ -109,7 +108,7 @@ public SimpleBooleanProperty isLoadingProperty() {
*/
void addBuiltInList() {
BackgroundTask
- .wrap(JournalAbbreviationLoader::getBuiltInAbbreviations)
+ .wrap(journalAbbreviationRepository::getAllLoaded)
.onRunning(() -> isLoading.setValue(true))
.onSuccess(result -> {
isLoading.setValue(false);
@@ -271,10 +270,6 @@ private void setCurrentAbbreviationNameAndAbbreviationIfValid(String name, Strin
shouldWriteLists = true;
}
- private void setCurrentAbbreviationNameAndAbbreviationIfValid(String name, String abbreviation) {
- setCurrentAbbreviationNameAndAbbreviationIfValid(name, abbreviation, "");
- }
-
/**
* Method to delete the abbreviation set in the currentAbbreviation property. The currentAbbreviationProperty will
* be set to the previous or next abbreviation in the abbreviations property if applicable. Else it will be set to
@@ -336,7 +331,7 @@ public void selectLastJournalFile() {
/**
* This method first saves all external files to its internal list, then writes all abbreviations to their files and
* finally updates the abbreviations auto complete. It basically calls {@link #saveExternalFilesList()}, {@link
- * #saveJournalAbbreviationFiles() } and finally {@link JournalAbbreviationLoader#update(JournalAbbreviationPreferences)}.
+ * #saveJournalAbbreviationFiles() }}.
*/
public void save() {
BackgroundTask.wrap(() -> {
diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java
index cffd70d7f6e..e6afb160540 100644
--- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java
+++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java
@@ -37,7 +37,7 @@ public enum KeyBinding {
ENTRY_EDITOR_PREVIOUS_PANEL("Entry editor, previous panel", Localization.lang("Entry editor, previous panel"), "ctrl+shift+TAB", KeyBindingCategory.VIEW),
FILE_LIST_EDITOR_MOVE_ENTRY_DOWN("File list editor, move entry down", Localization.lang("File list editor, move entry down"), "ctrl+DOWN", KeyBindingCategory.VIEW),
FILE_LIST_EDITOR_MOVE_ENTRY_UP("File list editor, move entry up", Localization.lang("File list editor, move entry up"), "ctrl+UP", KeyBindingCategory.VIEW),
- FIND_UNLINKED_FILES("Find unlinked files", Localization.lang("Find unlinked files"), "shift+F7", KeyBindingCategory.QUALITY),
+ FIND_UNLINKED_FILES("Search for unlinked local files", Localization.lang("Search for unlinked local files"), "shift+F7", KeyBindingCategory.QUALITY),
FOCUS_ENTRY_TABLE("Focus entry table", Localization.lang("Focus entry table"), "alt+1", KeyBindingCategory.VIEW),
HELP("Help", Localization.lang("Help"), "F1", KeyBindingCategory.FILE),
IMPORT_INTO_CURRENT_DATABASE("Import into current library", Localization.lang("Import into current library"), "ctrl+I", KeyBindingCategory.FILE),
diff --git a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java
index 80a11f70b63..a05c2ef2c7c 100644
--- a/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java
@@ -18,12 +18,12 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.logic.cleanup.Cleanups;
+import org.jabref.logic.cleanup.FieldFormatterCleanup;
+import org.jabref.logic.cleanup.FieldFormatterCleanups;
import org.jabref.logic.l10n.Encodings;
-import org.jabref.model.cleanup.FieldFormatterCleanup;
-import org.jabref.model.cleanup.FieldFormatterCleanups;
+import org.jabref.logic.shared.DatabaseLocation;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
-import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.InternalField;
diff --git a/src/main/java/org/jabref/gui/logging/ApplicationInsightsAppender.java b/src/main/java/org/jabref/gui/logging/ApplicationInsightsAppender.java
index 6cd5bd2e05d..ca02546ed9d 100644
--- a/src/main/java/org/jabref/gui/logging/ApplicationInsightsAppender.java
+++ b/src/main/java/org/jabref/gui/logging/ApplicationInsightsAppender.java
@@ -1,6 +1,6 @@
package org.jabref.gui.logging;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.logic.logging.LogMessages;
import com.microsoft.applicationinsights.telemetry.ExceptionTelemetry;
diff --git a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java
index 1d368e5496c..75a72b4cdf3 100644
--- a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java
+++ b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java
@@ -14,9 +14,9 @@
import javafx.beans.value.ObservableValue;
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
+import org.jabref.logic.importer.util.FileFieldParser;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
-import org.jabref.model.entry.FileFieldParser;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.OrFields;
diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java
index e646b56b286..c1c5cab22ab 100644
--- a/src/main/java/org/jabref/gui/maintable/MainTable.java
+++ b/src/main/java/org/jabref/gui/maintable/MainTable.java
@@ -24,10 +24,10 @@
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.DragAndDropDataFormats;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.edit.EditAction;
@@ -40,9 +40,11 @@
import org.jabref.gui.util.CustomLocalDragboard;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.ViewModelTableRowFactory;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.model.database.BibDatabaseContext;
+import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.database.event.EntriesAddedEvent;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;
@@ -105,7 +107,8 @@ public MainTable(MainTableDataModel model,
panel,
dialogService,
stateManager,
- preferencesService))
+ preferencesService,
+ Globals.clipboardManager))
.setOnDragDetected(this::handleOnDragDetected)
.setOnDragDropped(this::handleOnDragDropped)
.setOnDragOver(this::handleOnDragOver)
@@ -114,7 +117,20 @@ public MainTable(MainTableDataModel model,
.install(this);
this.getSortOrder().clear();
- mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
+
+ /* KEEP for debugging purposes
+ for (var colModel : mainTablePreferences.getColumnPreferences().getColumnSortOrder()) {
+ for (var col : this.getColumns()) {
+ var tablecColModel = ((MainTableColumn>) col).getModel();
+ if (tablecColModel.equals(colModel)) {
+ LOGGER.debug("Adding sort order for col {} ", col);
+ this.getSortOrder().add(col);
+ break;
+ }
+ }
+ }
+ */
+ mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel ->
this.getColumns().stream()
.map(column -> (MainTableColumn>) column)
.filter(column -> column.getModel().equals(columnModel))
@@ -157,7 +173,7 @@ public MainTable(MainTableDataModel model,
* The {@link MainTable} will scroll to the cell with the same starting column value and typed string
*
* @param sortedColumn The sorted column in {@link MainTable}
- * @param keyEvent The pressed character
+ * @param keyEvent The pressed character
*/
private void jumpToSearchKey(TableColumn sortedColumn, KeyEvent keyEvent) {
@@ -271,14 +287,15 @@ private void clearAndSelectLast() {
scrollTo(getItems().size() - 1);
}
- public void paste() {
+ public void paste(BibDatabaseMode bibDatabaseMode) {
// Find entries in clipboard
List entriesToAdd = Globals.clipboardManager.extractData();
+ ImportCleanup cleanup = new ImportCleanup(bibDatabaseMode);
+ cleanup.doPostCleanup(entriesToAdd);
panel.insertEntries(entriesToAdd);
if (!entriesToAdd.isEmpty()) {
this.requestFocus();
}
-
}
private void handleOnDragOver(TableRow row, BibEntryTableViewModel item, DragEvent event) {
diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java
index cb1bd9fa113..0edf1dbde17 100644
--- a/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java
+++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnModel.java
@@ -138,7 +138,7 @@ public String getName() {
public String getDisplayName() {
if ((Type.ICON_COLUMNS.contains(typeProperty.getValue()) && qualifierProperty.getValue().isBlank())
- || typeProperty.getValue() == Type.INDEX) {
+ || (typeProperty.getValue() == Type.INDEX)) {
return typeProperty.getValue().getDisplayName();
} else {
return FieldsUtil.getNameWithType(FieldFactory.parseField(qualifierProperty.getValue()));
@@ -165,23 +165,25 @@ public ObjectProperty sortTypeProperty() {
return sortTypeProperty;
}
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if ((o == null) || (getClass() != o.getClass())) {
return false;
}
MainTableColumnModel that = (MainTableColumnModel) o;
- if (typeProperty != that.typeProperty) {
+ if (typeProperty.getValue() != that.typeProperty.getValue()) {
return false;
}
- return Objects.equals(qualifierProperty, that.qualifierProperty);
+ return Objects.equals(qualifierProperty.getValue(), that.qualifierProperty.getValue());
}
+ @Override
public int hashCode() {
return Objects.hash(typeProperty.getValue(), qualifierProperty.getValue());
}
@@ -199,9 +201,9 @@ public static MainTableColumnModel parse(String rawColumnName) {
Type type = Type.fromString(splittedName[0]);
String qualifier = "";
- if (type == Type.NORMALFIELD
- || type == Type.SPECIALFIELD
- || type == Type.EXTRAFILE) {
+ if ((type == Type.NORMALFIELD)
+ || (type == Type.SPECIALFIELD)
+ || (type == Type.EXTRAFILE)) {
if (splittedName.length == 1) {
qualifier = splittedName[0]; // By default the rawColumnName is parsed as NORMALFIELD
} else {
diff --git a/src/main/java/org/jabref/gui/maintable/OpenExternalFileAction.java b/src/main/java/org/jabref/gui/maintable/OpenExternalFileAction.java
index 84201650ce4..033f359ff67 100644
--- a/src/main/java/org/jabref/gui/maintable/OpenExternalFileAction.java
+++ b/src/main/java/org/jabref/gui/maintable/OpenExternalFileAction.java
@@ -2,8 +2,8 @@
import java.util.List;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
@@ -46,7 +46,7 @@ public void execute() {
databaseContext,
Globals.TASK_EXECUTOR,
dialogService,
- preferencesService.getXMPPreferences(),
+ preferencesService.getXmpPreferences(),
preferencesService.getFilePreferences(),
ExternalFileTypes.getInstance());
linkedFileViewModel.open();
diff --git a/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java b/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java
index d1fd013f79e..8b147729d86 100644
--- a/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java
+++ b/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java
@@ -1,7 +1,7 @@
package org.jabref.gui.maintable;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
@@ -37,7 +37,7 @@ public void execute() {
databaseContext,
Globals.TASK_EXECUTOR,
dialogService,
- preferencesService.getXMPPreferences(),
+ preferencesService.getXmpPreferences(),
preferencesService.getFilePreferences(),
ExternalFileTypes.getInstance()
);
diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java
index 86726216200..a8bfe7ba478 100644
--- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java
+++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java
@@ -4,9 +4,10 @@
import javafx.scene.control.Menu;
import javafx.scene.control.SeparatorMenuItem;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
+import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.SendAsEMailAction;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
@@ -25,18 +26,23 @@
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
import org.jabref.logic.preview.PreviewLayout;
import org.jabref.model.entry.field.SpecialField;
-import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreferencesService;
import org.jabref.preferences.PreviewPreferences;
public class RightClickMenu {
- public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingRepository keyBindingRepository, BasePanel panel, DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) {
+ public static ContextMenu create(BibEntryTableViewModel entry,
+ KeyBindingRepository keyBindingRepository,
+ BasePanel panel,
+ DialogService dialogService,
+ StateManager stateManager,
+ PreferencesService preferencesService,
+ ClipBoardManager clipBoardManager) {
ContextMenu contextMenu = new ContextMenu();
ActionFactory factory = new ActionFactory(keyBindingRepository);
contextMenu.getItems().add(factory.createMenuItem(StandardActions.COPY, new EditAction(StandardActions.COPY, panel.frame(), stateManager)));
- contextMenu.getItems().add(createCopySubMenu(panel, factory, dialogService, stateManager, preferencesService));
+ contextMenu.getItems().add(createCopySubMenu(panel, factory, dialogService, stateManager, preferencesService, clipBoardManager));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, panel.frame(), stateManager)));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.CUT, new EditAction(StandardActions.CUT, panel.frame(), stateManager)));
contextMenu.getItems().add(factory.createMenuItem(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, panel.frame(), stateManager)));
@@ -47,9 +53,7 @@ public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingReposit
contextMenu.getItems().add(new SeparatorMenuItem());
- if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
- // ToDo: SpecialField needs the active BasePanel to mark it as changed.
- // Refactor BasePanel, should mark the BibDatabaseContext or the UndoManager as dirty instead!
+ if (preferencesService.getSpecialFieldsPreferences().isSpecialFieldsEnabled()) {
contextMenu.getItems().add(SpecialFieldMenuItemFactory.createSpecialFieldMenu(SpecialField.RANKING, factory, panel.frame(), dialogService, stateManager));
contextMenu.getItems().add(SpecialFieldMenuItemFactory.getSpecialFieldSingleItem(SpecialField.RELEVANCE, factory, panel.frame(), dialogService, stateManager));
contextMenu.getItems().add(SpecialFieldMenuItemFactory.getSpecialFieldSingleItem(SpecialField.QUALITY, factory, panel.frame(), dialogService, stateManager));
@@ -76,30 +80,35 @@ public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingReposit
return contextMenu;
}
- private static Menu createCopySubMenu(BasePanel panel, ActionFactory factory, DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) {
+ private static Menu createCopySubMenu(BasePanel panel,
+ ActionFactory factory,
+ DialogService dialogService,
+ StateManager stateManager,
+ PreferencesService preferencesService,
+ ClipBoardManager clipBoardManager) {
Menu copySpecialMenu = factory.createMenu(StandardActions.COPY_MORE);
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, clipBoardManager, preferencesService)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, clipBoardManager, preferencesService)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, clipBoardManager, preferencesService)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, clipBoardManager, preferencesService)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, clipBoardManager, preferencesService)));
// the submenu will behave dependent on what style is currently selected (citation/preview)
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
PreviewLayout style = previewPreferences.getCurrentPreviewStyle();
if (style instanceof CitationStylePreviewLayout) {
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, previewPreferences)));
Menu copyCitationMenu = factory.createMenu(StandardActions.COPY_CITATION_MORE);
- copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new CopyCitationAction(CitationStyleOutputFormat.TEXT, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
- copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_RTF, new CopyCitationAction(CitationStyleOutputFormat.RTF, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
- copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_ASCII_DOC, new CopyCitationAction(CitationStyleOutputFormat.ASCII_DOC, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
- copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_XSLFO, new CopyCitationAction(CitationStyleOutputFormat.XSL_FO, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
+ copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new CopyCitationAction(CitationStyleOutputFormat.TEXT, dialogService, stateManager, clipBoardManager, previewPreferences)));
+ copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_RTF, new CopyCitationAction(CitationStyleOutputFormat.RTF, dialogService, stateManager, clipBoardManager, previewPreferences)));
+ copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_ASCII_DOC, new CopyCitationAction(CitationStyleOutputFormat.ASCII_DOC, dialogService, stateManager, clipBoardManager, previewPreferences)));
+ copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_XSLFO, new CopyCitationAction(CitationStyleOutputFormat.XSL_FO, dialogService, stateManager, clipBoardManager, previewPreferences)));
copySpecialMenu.getItems().add(copyCitationMenu);
} else {
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, previewPreferences)));
}
- copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.EXPORT_TO_CLIPBOARD, new ExportToClipboardAction(panel, dialogService, Globals.exportFactory, Globals.clipboardManager, Globals.TASK_EXECUTOR)));
+ copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.EXPORT_TO_CLIPBOARD, new ExportToClipboardAction(panel, dialogService, Globals.exportFactory, clipBoardManager, Globals.TASK_EXECUTOR)));
return copySpecialMenu;
}
}
diff --git a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java
index 2c46132a52c..3ad18d627ab 100644
--- a/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java
+++ b/src/main/java/org/jabref/gui/maintable/columns/FileColumn.java
@@ -10,8 +10,8 @@
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseButton;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
@@ -68,7 +68,7 @@ public FileColumn(MainTableColumnModel model,
entry.getEntry(),
database, Globals.TASK_EXECUTOR,
dialogService,
- preferencesService.getXMPPreferences(),
+ preferencesService.getXmpPreferences(),
preferencesService.getFilePreferences(),
externalFileTypes);
linkedFileViewModel.open();
@@ -132,7 +132,7 @@ private ContextMenu createFileMenu(BibEntryTableViewModel entry, List event -> {
+ if ((event.getButton() == MouseButton.PRIMARY) && (linkedFiles.size() == 1)) {
+ // Open linked identifier directly only if 1 entry is preset
+ try {
+ for (Field field : linkedFiles.keySet()) {
+ JabRefDesktop.openExternalViewer(database, linkedFiles.get(field), field);
+ }
+ } catch (IOException e) {
+ dialogService.showErrorDialogAndWait(Localization.lang("Unable to open link."), e);
+ }
+ }
+ })
.install(this);
}
private Node createIdentifierGraphic(Map values) {
- if (values.isEmpty()) {
- return null;
+ if (values.size() > 1) {
+ return IconTheme.JabRefIcons.LINK_VARIANT.getGraphicNode();
+ } else if (values.size() == 1) {
+ return IconTheme.JabRefIcons.LINK.getGraphicNode();
} else {
- return cellFactory.getTableIcon(StandardField.URL);
+ return null;
}
}
@@ -72,6 +86,10 @@ private String createIdentifierTooltip(Map values) {
private ContextMenu createIdentifierMenu(BibEntryTableViewModel entry, Map values) {
ContextMenu contextMenu = new ContextMenu();
+ if (values.size() <= 1) {
+ return null;
+ }
+
values.keySet().forEach(field -> {
MenuItem menuItem = new MenuItem(field.getDisplayName() + ": " +
ControlHelper.truncateString(values.get(field), -1, "...", ControlHelper.EllipsisPosition.CENTER),
diff --git a/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java b/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java
index c8f3c4a44e5..8504dc6ca84 100644
--- a/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java
+++ b/src/main/java/org/jabref/gui/menus/ChangeEntryTypeMenu.java
@@ -14,8 +14,8 @@
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.Tooltip;
-import org.jabref.Globals;
import org.jabref.gui.EntryTypeView;
+import org.jabref.gui.Globals;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableChangeType;
diff --git a/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java b/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
index 426bbbe516a..7029505ac20 100644
--- a/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
+++ b/src/main/java/org/jabref/gui/menus/FileHistoryMenu.java
@@ -11,16 +11,16 @@
import org.jabref.gui.importer.actions.OpenDatabaseAction;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.io.FileHistory;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
public class FileHistoryMenu extends Menu {
private final FileHistory history;
- private final JabRefPreferences preferences;
+ private final PreferencesService preferences;
private final DialogService dialogService;
private final OpenDatabaseAction openDatabaseAction;
- public FileHistoryMenu(JabRefPreferences preferences, DialogService dialogService, OpenDatabaseAction openDatabaseAction) {
+ public FileHistoryMenu(PreferencesService preferences, DialogService dialogService, OpenDatabaseAction openDatabaseAction) {
setText(Localization.lang("Recent libraries"));
this.preferences = preferences;
diff --git a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java
index e44d3265c34..643f3bde53c 100644
--- a/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java
+++ b/src/main/java/org/jabref/gui/mergeentries/FetchAndMergeEntry.java
@@ -8,9 +8,9 @@
import java.util.Set;
import java.util.TreeSet;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableChangeType;
import org.jabref.gui.undo.UndoableFieldChange;
@@ -18,6 +18,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.importer.EntryBasedFetcher;
import org.jabref.logic.importer.IdBasedFetcher;
+import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.WebFetcher;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.l10n.Localization;
@@ -64,6 +65,8 @@ public void fetchAndMerge(BibEntry entry, List fields) {
if (fetcher.isPresent()) {
BackgroundTask.wrap(() -> fetcher.get().performSearchById(fieldContent.get()))
.onSuccess(fetchedEntry -> {
+ ImportCleanup cleanup = new ImportCleanup(panel.getBibDatabaseContext().getMode());
+ cleanup.doPostCleanup(entry);
String type = field.getDisplayName();
if (fetchedEntry.isPresent()) {
showMergeDialog(entry, fetchedEntry.get(), fetcher.get());
@@ -147,6 +150,8 @@ public void fetchAndMerge(BibEntry entry, EntryBasedFetcher fetcher) {
BackgroundTask.wrap(() -> fetcher.performSearch(entry).stream().findFirst())
.onSuccess(fetchedEntry -> {
if (fetchedEntry.isPresent()) {
+ ImportCleanup cleanup = new ImportCleanup(panel.getBibDatabaseContext().getMode());
+ cleanup.doPostCleanup(fetchedEntry.get());
showMergeDialog(entry, fetchedEntry.get(), fetcher);
} else {
dialogService.notify(Localization.lang("Could not find any bibliographic information."));
diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java
index eca551942e9..10564e53190 100644
--- a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java
+++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java
@@ -32,7 +32,7 @@
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.icon.IconTheme.JabRefIcons;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.gui.util.component.DiffHighlightingTextPane;
diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java
index 965350d4007..ec1ba539807 100644
--- a/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java
+++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntriesAction.java
@@ -4,8 +4,8 @@
import java.util.List;
import java.util.Optional;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeWithFetchedEntryAction.java b/src/main/java/org/jabref/gui/mergeentries/MergeWithFetchedEntryAction.java
index e67c42b0df2..5ebfb67676e 100644
--- a/src/main/java/org/jabref/gui/mergeentries/MergeWithFetchedEntryAction.java
+++ b/src/main/java/org/jabref/gui/mergeentries/MergeWithFetchedEntryAction.java
@@ -1,8 +1,8 @@
package org.jabref.gui.mergeentries;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java
index 55de8d755ff..4a97139f0d0 100644
--- a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java
+++ b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java
@@ -23,6 +23,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.jabref.architecture.AllowedToUseAwt;
import org.jabref.gui.DialogService;
import org.jabref.logic.bibtex.comparator.FieldComparator;
import org.jabref.logic.bibtex.comparator.FieldComparatorStack;
@@ -87,6 +88,7 @@
/**
* Class for manipulating the Bibliography of the currently start document in OpenOffice.
*/
+@AllowedToUseAwt("Requires AWT for italics and bold")
class OOBibBase {
private static final OOPreFormatter POSTFORMATTER = new OOPreFormatter();
@@ -320,7 +322,7 @@ public void insertEntry(List entries, BibDatabase database,
}
String keyString = String.join(",",
- entries.stream().map(entry -> entry.getCiteKeyOptional().orElse("")).collect(Collectors.toList()));
+ entries.stream().map(entry -> entry.getCitationKey().orElse("")).collect(Collectors.toList()));
// Insert bookmark:
String bName = getUniqueReferenceMarkName(keyString,
withText ? inParenthesis ? OOBibBase.AUTHORYEAR_PAR : OOBibBase.AUTHORYEAR_INTEXT : OOBibBase.INVISIBLE_CIT);
@@ -450,7 +452,7 @@ private List refreshCiteMarkersInternal(List databases, OOB
// Rebuild the list of cited keys according to the sort order:
cited.clear();
for (BibEntry entry : entries.keySet()) {
- cited.add(entry.getCiteKeyOptional().orElse(null));
+ cited.add(entry.getCitationKey().orElse(null));
}
names = Arrays.asList(xReferenceMarks.getElementNames());
} else {
@@ -489,7 +491,7 @@ private List refreshCiteMarkersInternal(List databases, OOB
BibDatabase database = linkSourceBase.get(keys[j]);
Optional tmpEntry = Optional.empty();
if (database != null) {
- tmpEntry = database.getEntryByKey(keys[j]);
+ tmpEntry = database.getEntryByCitationKey(keys[j]);
}
if (tmpEntry.isPresent()) {
cEntries[j] = tmpEntry.get();
@@ -507,8 +509,8 @@ private List refreshCiteMarkersInternal(List databases, OOB
StringBuilder sb = new StringBuilder();
normCitMarkers[i] = new String[keys.length];
for (int j = 0; j < keys.length; j++) {
- normCitMarkers[i][j] = cEntries[j].getCiteKeyOptional().orElse(null);
- sb.append(cEntries[j].getCiteKeyOptional().orElse(""));
+ normCitMarkers[i][j] = cEntries[j].getCitationKey().orElse(null);
+ sb.append(cEntries[j].getCitationKey().orElse(""));
if (j < (keys.length - 1)) {
sb.append(',');
}
@@ -565,7 +567,7 @@ private List refreshCiteMarkersInternal(List databases, OOB
}
// Update key list to match the new sorting:
for (int j = 0; j < cEntries.length; j++) {
- bibtexKeys[i][j] = cEntries[j].getCiteKeyOptional().orElse(null);
+ bibtexKeys[i][j] = cEntries[j].getCitationKey().orElse(null);
}
}
@@ -649,12 +651,12 @@ private List refreshCiteMarkersInternal(List databases, OOB
needsChange = true;
BibDatabase database = linkSourceBase.get(currentKey);
if (database != null) {
- tmpEntry = database.getEntryByKey(currentKey);
+ tmpEntry = database.getEntryByCitationKey(currentKey);
}
} else {
BibDatabase database = linkSourceBase.get(currentKey);
if (database != null) {
- tmpEntry = database.getEntryByKey(currentKey);
+ tmpEntry = database.getEntryByCitationKey(currentKey);
}
}
uniquif[k] = "";
@@ -662,7 +664,7 @@ private List refreshCiteMarkersInternal(List databases, OOB
needsChange = true;
BibDatabase database = linkSourceBase.get(currentKey);
if (database != null) {
- tmpEntry = database.getEntryByKey(currentKey);
+ tmpEntry = database.getEntryByCitationKey(currentKey);
}
uniquif[k] = uniq;
}
@@ -828,7 +830,7 @@ private Map findCitedEntries(List databases,
for (String key : keys) {
boolean found = false;
for (BibDatabase database : databases) {
- Optional entry = database.getEntryByKey(key);
+ Optional entry = database.getEntryByCitationKey(key);
if (entry.isPresent()) {
entries.put(entry.get(), database);
linkSourceBase.put(key, database);
@@ -850,10 +852,10 @@ private Point findPosition(XTextViewCursor cursor, XTextRange range) {
}
/**
- * Extract the list of bibtex keys from a reference mark name.
+ * Extract the list of citation keys from a reference mark name.
*
* @param name The reference mark name.
- * @return The list of bibtex keys encoded in the name.
+ * @return The list of citation keys encoded in the name.
*/
public List parseRefMarkName(String name) {
List keys = new ArrayList<>();
@@ -870,13 +872,12 @@ public List parseRefMarkName(String name) {
}
/**
- * Resolve the bibtex key from a citation reference marker name, and look up the index of the key in a list of keys.
+ * Resolve the citation key from a citation reference marker name, and look up the index of the key in a list of keys.
*
* @param citRefName The name of the ReferenceMark representing the citation.
- * @param keys A List of bibtex keys representing the entries in the bibliography.
+ * @param keys A List of citation keys representing the entries in the bibliography.
* @return the indices of the cited keys, -1 if a key is not found. Returns null if the ref name could not be resolved as a citation.
*/
-
private List findCitedEntryIndex(String citRefName, List keys) {
Matcher citeMatcher = CITE_PATTERN.matcher(citRefName);
if (citeMatcher.find()) {
@@ -904,7 +905,7 @@ private Map getSortedEntriesFromSortedRefMarks(List origEntry = Optional.empty();
if (database != null) {
- origEntry = database.getEntryByKey(key);
+ origEntry = database.getEntryByCitationKey(key);
}
if (origEntry.isPresent()) {
if (!newList.containsKey(origEntry.get())) {
@@ -994,7 +995,7 @@ private void insertFullReferenceAtCursor(XTextCursor cursor, Map databases, OOBibStyle style)
List entries = new ArrayList<>();
for (String key : keys) {
for (BibDatabase database : databases) {
- Optional entry = database.getEntryByKey(key);
+ Optional entry = database.getEntryByCitationKey(key);
if (entry.isPresent()) {
entries.add(entry.get());
break;
@@ -1246,7 +1247,7 @@ public void combineCiteMarkers(List databases, OOBibStyle style)
}
}
Collections.sort(entries, new FieldComparator(StandardField.YEAR));
- String keyString = String.join(",", entries.stream().map(entry -> entry.getCiteKeyOptional().orElse(""))
+ String keyString = String.join(",", entries.stream().map(entry -> entry.getCitationKey().orElse(""))
.collect(Collectors.toList()));
// Insert bookmark:
String bName = getUniqueReferenceMarkName(keyString, OOBibBase.AUTHORYEAR_PAR);
@@ -1272,7 +1273,7 @@ public BibDatabase generateDatabase(List databases)
for (String key : cited) {
// Loop through the available databases
for (BibDatabase loopDatabase : databases) {
- Optional entry = loopDatabase.getEntryByKey(key);
+ Optional entry = loopDatabase.getEntryByCitationKey(key);
// If entry found
if (entry.isPresent()) {
BibEntry clonedEntry = (BibEntry) entry.get().clone();
@@ -1281,9 +1282,9 @@ public BibDatabase generateDatabase(List databases)
// Check if the cloned entry has a crossref field
clonedEntry.getField(StandardField.CROSSREF).ifPresent(crossref -> {
// If the crossref entry is not already in the database
- if (!resultDatabase.getEntryByKey(crossref).isPresent()) {
+ if (!resultDatabase.getEntryByCitationKey(crossref).isPresent()) {
// Add it if it is in the current library
- loopDatabase.getEntryByKey(crossref).ifPresent(entriesToInsert::add);
+ loopDatabase.getEntryByCitationKey(crossref).ifPresent(entriesToInsert::add);
}
});
diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
index bff1e366d35..41adef02303 100644
--- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
+++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
@@ -28,9 +28,9 @@
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
@@ -266,7 +266,7 @@ private void initPanel() {
HBox hbox = new HBox();
hbox.getChildren().addAll(connect, manualConnect, selectDocument, update, help);
hbox.getChildren().forEach(btn -> HBox.setHgrow(btn, Priority.ALWAYS));
-
+
FlowPane flow = new FlowPane();
flow.setPadding(new Insets(5, 5, 5, 5));
flow.setVgap(4);
@@ -514,7 +514,7 @@ private boolean checkThatEntriesHaveKeys(List entries) {
// Check if there are empty keys
boolean emptyKeys = false;
for (BibEntry entry : entries) {
- if (!entry.getCiteKeyOptional().isPresent()) {
+ if (!entry.getCitationKey().isPresent()) {
// Found one, no need to look further for now
emptyKeys = true;
break;
@@ -538,7 +538,7 @@ private boolean checkThatEntriesHaveKeys(List entries) {
CitationKeyPatternPreferences prefs = jabRefPreferences.getCitationKeyPatternPreferences();
NamedCompound undoCompound = new NamedCompound(Localization.lang("Cite"));
for (BibEntry entry : entries) {
- if (!entry.getCiteKeyOptional().isPresent()) {
+ if (!entry.getCitationKey().isPresent()) {
// Generate key
new CitationKeyGenerator(panel.getBibDatabaseContext(), prefs)
.generateAndSetKey(entry)
diff --git a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
index 6f8da3c0083..60a5bb84de5 100644
--- a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
+++ b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
@@ -11,8 +11,8 @@
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.util.BaseDialog;
diff --git a/src/main/java/org/jabref/gui/preferences/AbstractPreferenceTabView.java b/src/main/java/org/jabref/gui/preferences/AbstractPreferenceTabView.java
index f68f871ac52..7d9f56fe727 100644
--- a/src/main/java/org/jabref/gui/preferences/AbstractPreferenceTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/AbstractPreferenceTabView.java
@@ -9,7 +9,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.util.TaskExecutor;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
public abstract class AbstractPreferenceTabView extends VBox implements PreferencesTab {
@@ -18,7 +18,7 @@ public abstract class AbstractPreferenceTabView
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/AppearanceTabView.java b/src/main/java/org/jabref/gui/preferences/AppearanceTabView.java
index 21dd8c94bf1..5cc081ab043 100644
--- a/src/main/java/org/jabref/gui/preferences/AppearanceTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/AppearanceTabView.java
@@ -10,7 +10,7 @@
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -26,7 +26,7 @@ public class AppearanceTabView extends AbstractPreferenceTabView
customPathToThemeProperty.setValue(file.toAbsolutePath().toString()));
diff --git a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTab.fxml b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTab.fxml
index c1f334e350a..f992dc19b62 100644
--- a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTab.fxml
@@ -10,7 +10,6 @@
-
diff --git a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabView.java b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabView.java
index 5800ea8e982..5bf4474436c 100644
--- a/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/CitationKeyPatternTabView.java
@@ -7,14 +7,14 @@
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.commonfxcontrols.CitationKeyPatternPanel;
import org.jabref.gui.help.HelpAction;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
@@ -34,11 +34,11 @@ public class CitationKeyPatternTabView extends AbstractPreferenceTabView
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/ExportSortingTabView.java b/src/main/java/org/jabref/gui/preferences/ExportSortingTabView.java
deleted file mode 100644
index 1535b937809..00000000000
--- a/src/main/java/org/jabref/gui/preferences/ExportSortingTabView.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.jabref.gui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javafx.fxml.FXML;
-
-import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
-
-import com.airhacks.afterburner.views.ViewLoader;
-
-public class ExportSortingTabView extends AbstractPreferenceTabView implements PreferencesTab {
-
- @FXML private SaveOrderConfigPanel exportOrderPanel;
-
- public ExportSortingTabView(JabRefPreferences preferences) {
- this.preferences = preferences;
-
- ViewLoader.view(this)
- .root(this)
- .load();
- }
-
- public void initialize() {
- this.viewModel = new ExportSortingTabViewModel(preferences);
-
- exportOrderPanel.saveInOriginalProperty().bindBidirectional(viewModel.saveInOriginalProperty());
- exportOrderPanel.saveInTableOrderProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
- exportOrderPanel.saveInSpecifiedOrderProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
- exportOrderPanel.primarySortFieldsProperty().bind(viewModel.primarySortFieldsProperty());
- exportOrderPanel.secondarySortFieldsProperty().bind(viewModel.secondarySortFieldsProperty());
- exportOrderPanel.tertiarySortFieldsProperty().bind(viewModel.tertiarySortFieldsProperty());
- exportOrderPanel.savePrimaryDescPropertySelected().bindBidirectional(viewModel.savePrimaryDescPropertySelected());
- exportOrderPanel.saveSecondaryDescPropertySelected().bindBidirectional(viewModel.saveSecondaryDescPropertySelected());
- exportOrderPanel.saveTertiaryDescPropertySelected().bindBidirectional(viewModel.saveTertiaryDescPropertySelected());
- exportOrderPanel.savePrimarySortSelectedValueProperty().bindBidirectional(viewModel.savePrimarySortSelectedValueProperty());
- exportOrderPanel.saveSecondarySortSelectedValueProperty().bindBidirectional(viewModel.saveSecondarySortSelectedValueProperty());
- exportOrderPanel.saveTertiarySortSelectedValueProperty().bindBidirectional(viewModel.saveTertiarySortSelectedValueProperty());
- }
-
- @Override
- public String getTabName() {
- return Localization.lang("Export sorting");
- }
-
- @Override
- public boolean validateSettings() {
- return true;
- }
-
- @Override
- public List getRestartWarnings() {
- return new ArrayList<>();
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/ExportSortingTabViewModel.java b/src/main/java/org/jabref/gui/preferences/ExportSortingTabViewModel.java
deleted file mode 100644
index bd34863774c..00000000000
--- a/src/main/java/org/jabref/gui/preferences/ExportSortingTabViewModel.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.jabref.gui.preferences;
-
-import java.util.List;
-import java.util.Set;
-
-import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.ListProperty;
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleListProperty;
-import javafx.beans.property.SimpleObjectProperty;
-import javafx.collections.FXCollections;
-
-import org.jabref.model.entry.field.Field;
-import org.jabref.model.entry.field.FieldFactory;
-import org.jabref.model.metadata.SaveOrderConfig;
-import org.jabref.preferences.PreferencesService;
-
-public class ExportSortingTabViewModel implements PreferenceTabViewModel {
- // SaveOrderConfigPanel
- private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty();
- private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty();
- private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty();
- // ToDo: The single criterions should really be a map or a list.
- private final ListProperty primarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
- private final ListProperty secondarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
- private final ListProperty tertiarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
- private final BooleanProperty savePrimaryDescPropertySelected = new SimpleBooleanProperty();
- private final BooleanProperty saveSecondaryDescPropertySelected = new SimpleBooleanProperty();
- private final BooleanProperty saveTertiaryDescPropertySelected = new SimpleBooleanProperty();
- private final ObjectProperty savePrimarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
- private final ObjectProperty saveSecondarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
- private final ObjectProperty saveTertiarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
-
- private final PreferencesService preferences;
-
- ExportSortingTabViewModel(PreferencesService preferences) {
- this.preferences = preferences;
- }
-
- @Override
- public void setValues() {
- SaveOrderConfig initialExportOrder = preferences.loadExportSaveOrder();
-
- if (initialExportOrder.saveInOriginalOrder()) {
- saveInOriginalProperty.setValue(true);
- } else if (initialExportOrder.saveInSpecifiedOrder()) {
- saveInSpecifiedOrderProperty.setValue(true);
- } else {
- saveInTableOrderProperty.setValue(true);
- }
-
- Set fieldNames = FieldFactory.getCommonFields();
- primarySortFieldsProperty.addAll(fieldNames);
- secondarySortFieldsProperty.addAll(fieldNames);
- tertiarySortFieldsProperty.addAll(fieldNames);
-
- savePrimarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(0).field);
- saveSecondarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(1).field);
- saveTertiarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(2).field);
-
- savePrimaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(0).descending);
- saveSecondaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(1).descending);
- saveTertiaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(2).descending);
- }
-
- @Override
- public void storeSettings() {
- SaveOrderConfig newSaveOrderConfig = new SaveOrderConfig(
- saveInOriginalProperty.getValue(),
- saveInSpecifiedOrderProperty.getValue(),
- new SaveOrderConfig.SortCriterion(
- savePrimarySortSelectedValueProperty.get(),
- savePrimaryDescPropertySelected.getValue()),
- new SaveOrderConfig.SortCriterion(
- saveSecondarySortSelectedValueProperty.get(),
- saveSecondaryDescPropertySelected.getValue()),
- new SaveOrderConfig.SortCriterion(
- saveTertiarySortSelectedValueProperty.get(),
- saveTertiaryDescPropertySelected.getValue()));
- preferences.storeExportSaveOrder(newSaveOrderConfig);
- }
-
- @Override
- public boolean validateSettings() {
- return false;
- }
-
- @Override
- public List getRestartWarnings() {
- return null;
- }
-
- // SaveOrderConfigPanel
-
- public BooleanProperty saveInOriginalProperty() {
- return saveInOriginalProperty;
- }
-
- public BooleanProperty saveInTableOrderProperty() {
- return saveInTableOrderProperty;
- }
-
- public BooleanProperty saveInSpecifiedOrderProperty() {
- return saveInSpecifiedOrderProperty;
- }
-
- public ListProperty primarySortFieldsProperty() {
- return primarySortFieldsProperty;
- }
-
- public ListProperty secondarySortFieldsProperty() {
- return secondarySortFieldsProperty;
- }
-
- public ListProperty tertiarySortFieldsProperty() {
- return tertiarySortFieldsProperty;
- }
-
- public ObjectProperty savePrimarySortSelectedValueProperty() {
- return savePrimarySortSelectedValueProperty;
- }
-
- public ObjectProperty saveSecondarySortSelectedValueProperty() {
- return saveSecondarySortSelectedValueProperty;
- }
-
- public ObjectProperty saveTertiarySortSelectedValueProperty() {
- return saveTertiarySortSelectedValueProperty;
- }
-
- public BooleanProperty savePrimaryDescPropertySelected() {
- return savePrimaryDescPropertySelected;
- }
-
- public BooleanProperty saveSecondaryDescPropertySelected() {
- return saveSecondaryDescPropertySelected;
- }
-
- public BooleanProperty saveTertiaryDescPropertySelected() {
- return saveTertiaryDescPropertySelected;
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/ExternalTabView.java b/src/main/java/org/jabref/gui/preferences/ExternalTabView.java
index a1df1709c0d..5dc54e8baa1 100644
--- a/src/main/java/org/jabref/gui/preferences/ExternalTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/ExternalTabView.java
@@ -12,7 +12,7 @@
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -37,7 +37,7 @@ public class ExternalTabView extends AbstractPreferenceTabView
-
-
+
+
+
-
-
@@ -37,30 +35,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/FileTabView.java b/src/main/java/org/jabref/gui/preferences/FileTabView.java
index 173ef8fe426..35263c518ac 100644
--- a/src/main/java/org/jabref/gui/preferences/FileTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/FileTabView.java
@@ -1,6 +1,8 @@
package org.jabref.gui.preferences;
-import javafx.application.Platform;
+import java.util.ArrayList;
+import java.util.List;
+
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
@@ -8,19 +10,18 @@
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
+import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
import org.jabref.gui.help.HelpAction;
-import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.NewLineSeparator;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
-import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
public class FileTabView extends AbstractPreferenceTabView implements PreferencesTab {
@@ -32,22 +33,12 @@ public class FileTabView extends AbstractPreferenceTabView imp
@FXML private ComboBox newLineSeparator;
@FXML private CheckBox alwaysReformatBib;
- @FXML private TextField mainFileDir;
- @FXML private CheckBox useBibLocationAsPrimary;
- @FXML private Button autolinkRegexHelp;
- @FXML private RadioButton autolinkFileStartsBibtex;
- @FXML private RadioButton autolinkFileExactBibtex;
- @FXML private RadioButton autolinkUseRegex;
- @FXML private TextField autolinkRegexKey;
- @FXML private CheckBox searchFilesOnOpen;
- @FXML private CheckBox openBrowseOnCreate;
+ @FXML private SaveOrderConfigPanel exportOrderPanel;
@FXML private CheckBox autosaveLocalLibraries;
@FXML private Button autosaveLocalLibrariesHelp;
- private ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
-
- public FileTabView(JabRefPreferences preferences) {
+ public FileTabView(PreferencesService preferences) {
this.preferences = preferences;
ViewLoader.view(this)
@@ -55,13 +46,8 @@ public FileTabView(JabRefPreferences preferences) {
.load();
}
- @Override
- public String getTabName() {
- return Localization.lang("File");
- }
-
public void initialize() {
- this.viewModel = new FileTabViewModel(dialogService, preferences);
+ this.viewModel = new FileTabViewModel(preferences);
openLastStartup.selectedProperty().bindBidirectional(viewModel.openLastStartupProperty());
noWrapFiles.textProperty().bindBidirectional(viewModel.noWrapFilesProperty());
@@ -76,27 +62,37 @@ public void initialize() {
newLineSeparator.valueProperty().bindBidirectional(viewModel.selectedNewLineSeparatorProperty());
alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
- mainFileDir.textProperty().bindBidirectional(viewModel.mainFileDirProperty());
- useBibLocationAsPrimary.selectedProperty().bindBidirectional(viewModel.useBibLocationAsPrimaryProperty());
- autolinkFileStartsBibtex.selectedProperty().bindBidirectional(viewModel.autolinkFileStartsBibtexProperty());
- autolinkFileExactBibtex.selectedProperty().bindBidirectional(viewModel.autolinkFileExactBibtexProperty());
- autolinkUseRegex.selectedProperty().bindBidirectional(viewModel.autolinkUseRegexProperty());
- autolinkRegexKey.textProperty().bindBidirectional(viewModel.autolinkRegexKeyProperty());
- autolinkRegexKey.disableProperty().bind(autolinkUseRegex.selectedProperty().not());
- searchFilesOnOpen.selectedProperty().bindBidirectional(viewModel.searchFilesOnOpenProperty());
- openBrowseOnCreate.selectedProperty().bindBidirectional(viewModel.openBrowseOnCreateProperty());
+ exportOrderPanel.saveInOriginalProperty().bindBidirectional(viewModel.saveInOriginalProperty());
+ exportOrderPanel.saveInTableOrderProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
+ exportOrderPanel.saveInSpecifiedOrderProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
+ exportOrderPanel.primarySortFieldsProperty().bind(viewModel.primarySortFieldsProperty());
+ exportOrderPanel.secondarySortFieldsProperty().bind(viewModel.secondarySortFieldsProperty());
+ exportOrderPanel.tertiarySortFieldsProperty().bind(viewModel.tertiarySortFieldsProperty());
+ exportOrderPanel.savePrimaryDescPropertySelected().bindBidirectional(viewModel.savePrimaryDescPropertySelected());
+ exportOrderPanel.saveSecondaryDescPropertySelected().bindBidirectional(viewModel.saveSecondaryDescPropertySelected());
+ exportOrderPanel.saveTertiaryDescPropertySelected().bindBidirectional(viewModel.saveTertiaryDescPropertySelected());
+ exportOrderPanel.savePrimarySortSelectedValueProperty().bindBidirectional(viewModel.savePrimarySortSelectedValueProperty());
+ exportOrderPanel.saveSecondarySortSelectedValueProperty().bindBidirectional(viewModel.saveSecondarySortSelectedValueProperty());
+ exportOrderPanel.saveTertiarySortSelectedValueProperty().bindBidirectional(viewModel.saveTertiarySortSelectedValueProperty());
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
- actionFactory.configureIconButton(StandardActions.HELP_REGEX_SEARCH, new HelpAction(HelpFile.REGEX_SEARCH), autolinkRegexHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE), autosaveLocalLibrariesHelp);
+ }
- validationVisualizer.setDecoration(new IconValidationDecorator());
- Platform.runLater(() -> validationVisualizer.initVisualization(viewModel.mainFileDirValidationStatus(), mainFileDir));
+ @Override
+ public String getTabName() {
+ return Localization.lang("File");
}
- public void mainFileDirBrowse() {
- viewModel.mainFileDirBrowse();
+ @Override
+ public boolean validateSettings() {
+ return true;
+ }
+
+ @Override
+ public List getRestartWarnings() {
+ return new ArrayList<>();
}
}
diff --git a/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java b/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java
index ad26e3d1966..bacfa4cb29c 100644
--- a/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/FileTabViewModel.java
@@ -1,9 +1,7 @@
package org.jabref.gui.preferences;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
@@ -15,16 +13,12 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
-import org.jabref.gui.DialogService;
-import org.jabref.gui.util.DirectoryDialogConfiguration;
-import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.model.entry.field.Field;
+import org.jabref.model.entry.field.FieldFactory;
+import org.jabref.model.metadata.SaveOrderConfig;
+import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.NewLineSeparator;
-
-import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
-import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
-import de.saxsys.mvvmfx.utils.validation.ValidationStatus;
-import de.saxsys.mvvmfx.utils.validation.Validator;
+import org.jabref.preferences.PreferencesService;
public class FileTabViewModel implements PreferenceTabViewModel {
@@ -37,119 +31,108 @@ public class FileTabViewModel implements PreferenceTabViewModel {
private final ObjectProperty selectedNewLineSeparatorProperty = new SimpleObjectProperty<>();
private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
- private final StringProperty mainFileDirProperty = new SimpleStringProperty("");
- private final BooleanProperty useBibLocationAsPrimaryProperty = new SimpleBooleanProperty();
- private final BooleanProperty autolinkFileStartsBibtexProperty = new SimpleBooleanProperty();
- private final BooleanProperty autolinkFileExactBibtexProperty = new SimpleBooleanProperty();
- private final BooleanProperty autolinkUseRegexProperty = new SimpleBooleanProperty();
- private final StringProperty autolinkRegexKeyProperty = new SimpleStringProperty("");
- private final BooleanProperty searchFilesOnOpenProperty = new SimpleBooleanProperty();
- private final BooleanProperty openBrowseOnCreateProperty = new SimpleBooleanProperty();
+ // SaveOrderConfigPanel
+ private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty();
+ private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty();
+ private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty();
+ // ToDo: The single criterions should really be a map or a list.
+ private final ListProperty primarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final ListProperty secondarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final ListProperty tertiarySortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
+ private final BooleanProperty savePrimaryDescPropertySelected = new SimpleBooleanProperty();
+ private final BooleanProperty saveSecondaryDescPropertySelected = new SimpleBooleanProperty();
+ private final BooleanProperty saveTertiaryDescPropertySelected = new SimpleBooleanProperty();
+ private final ObjectProperty savePrimarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
+ private final ObjectProperty saveSecondarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
+ private final ObjectProperty saveTertiarySortSelectedValueProperty = new SimpleObjectProperty<>(null);
private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();
- private final Validator mainFileDirValidator;
-
- private final DialogService dialogService;
- private final JabRefPreferences preferences;
+ private final PreferencesService preferences;
+ private final SaveOrderConfig initialExportOrder;
+ private final ImportExportPreferences initialImportExportPreferences;
- public FileTabViewModel(DialogService dialogService, JabRefPreferences preferences) {
- this.dialogService = dialogService;
+ FileTabViewModel(PreferencesService preferences) {
this.preferences = preferences;
-
- mainFileDirValidator = new FunctionBasedValidator<>(
- mainFileDirProperty,
- input -> {
- Path path = Path.of(mainFileDirProperty.getValue());
- return (Files.exists(path) && Files.isDirectory(path));
- },
- ValidationMessage.error(String.format("%s > %s > %s %n %n %s",
- Localization.lang("File"),
- Localization.lang("External file links"),
- Localization.lang("Main file directory"),
- Localization.lang("Directory not found")
- )
- )
- );
+ this.initialExportOrder = preferences.loadExportSaveOrder();
+ this.initialImportExportPreferences = preferences.getImportExportPreferences();
}
@Override
public void setValues() {
- openLastStartupProperty.setValue(preferences.getBoolean(JabRefPreferences.OPEN_LAST_EDITED));
- noWrapFilesProperty.setValue(preferences.get(JabRefPreferences.NON_WRAPPABLE_FIELDS));
- resolveStringsAllProperty.setValue(preferences.getBoolean(JabRefPreferences.RESOLVE_STRINGS_ALL_FIELDS)); // Flipped around
- resolveStringsBibTexProperty.setValue(!resolveStringsAllProperty.getValue());
- resolveStringsExceptProperty.setValue(preferences.get(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR));
+ openLastStartupProperty.setValue(preferences.shouldOpenLastFilesOnStartup());
+
+ noWrapFilesProperty.setValue(initialImportExportPreferences.getNonWrappableFields());
+ resolveStringsAllProperty.setValue(initialImportExportPreferences.shouldResolveStringsForAllStrings()); // Flipped around
+ resolveStringsBibTexProperty.setValue(initialImportExportPreferences.shouldResolveStringsForStandardBibtexFields());
+ resolveStringsExceptProperty.setValue(initialImportExportPreferences.getNonResolvableFields());
newLineSeparatorListProperty.setValue(FXCollections.observableArrayList(NewLineSeparator.values()));
- selectedNewLineSeparatorProperty.setValue(preferences.getNewLineSeparator());
- alwaysReformatBibProperty.setValue(preferences.getBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT));
-
- mainFileDirProperty.setValue(preferences.getAsOptional(JabRefPreferences.MAIN_FILE_DIRECTORY).orElse(""));
- useBibLocationAsPrimaryProperty.setValue(preferences.getBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR));
- if (preferences.getBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY)) { // Flipped around
- autolinkUseRegexProperty.setValue(true);
- } else if (preferences.getBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY)) {
- autolinkFileExactBibtexProperty.setValue(true);
+ selectedNewLineSeparatorProperty.setValue(initialImportExportPreferences.getNewLineSeparator());
+
+ alwaysReformatBibProperty.setValue(initialImportExportPreferences.shouldAlwaysReformatOnSave());
+
+ if (initialExportOrder.saveInOriginalOrder()) {
+ saveInOriginalProperty.setValue(true);
+ } else if (initialExportOrder.saveInSpecifiedOrder()) {
+ saveInSpecifiedOrderProperty.setValue(true);
} else {
- autolinkFileStartsBibtexProperty.setValue(true);
+ saveInTableOrderProperty.setValue(true);
}
- autolinkRegexKeyProperty.setValue(preferences.get(JabRefPreferences.AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY));
- searchFilesOnOpenProperty.setValue(preferences.getBoolean(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH));
- openBrowseOnCreateProperty.setValue(preferences.getBoolean(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE));
- autosaveLocalLibraries.setValue(preferences.getBoolean(JabRefPreferences.LOCAL_AUTO_SAVE));
- }
+ Set fieldNames = FieldFactory.getCommonFields();
+ primarySortFieldsProperty.addAll(fieldNames);
+ secondarySortFieldsProperty.addAll(fieldNames);
+ tertiarySortFieldsProperty.addAll(fieldNames);
- @Override
- public void storeSettings() {
- preferences.putBoolean(JabRefPreferences.OPEN_LAST_EDITED, openLastStartupProperty.getValue());
- if (!noWrapFilesProperty.getValue().trim().equals(preferences.get(JabRefPreferences.NON_WRAPPABLE_FIELDS))) {
- preferences.put(JabRefPreferences.NON_WRAPPABLE_FIELDS, noWrapFilesProperty.getValue());
- }
- preferences.putBoolean(JabRefPreferences.RESOLVE_STRINGS_ALL_FIELDS, resolveStringsAllProperty.getValue());
- preferences.put(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR, resolveStringsExceptProperty.getValue().trim());
- resolveStringsExceptProperty.setValue(preferences.get(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR));
- if (autolinkUseRegexProperty.getValue()) {
- preferences.put(JabRefPreferences.AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY, autolinkRegexKeyProperty.getValue());
- }
- preferences.setNewLineSeparator(selectedNewLineSeparatorProperty.getValue());
- preferences.putBoolean(JabRefPreferences.REFORMAT_FILE_ON_SAVE_AND_EXPORT, alwaysReformatBibProperty.getValue());
+ savePrimarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(0).field);
+ saveSecondarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(1).field);
+ saveTertiarySortSelectedValueProperty.setValue(initialExportOrder.getSortCriteria().get(2).field);
- preferences.put(JabRefPreferences.MAIN_FILE_DIRECTORY, mainFileDirProperty.getValue());
- preferences.putBoolean(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, useBibLocationAsPrimaryProperty.getValue());
- preferences.putBoolean(JabRefPreferences.AUTOLINK_USE_REG_EXP_SEARCH_KEY, autolinkUseRegexProperty.getValue());
- preferences.putBoolean(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, autolinkFileExactBibtexProperty.getValue());
- preferences.putBoolean(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH, searchFilesOnOpenProperty.getValue());
- preferences.putBoolean(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE, openBrowseOnCreateProperty.getValue());
+ savePrimaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(0).descending);
+ saveSecondaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(1).descending);
+ saveTertiaryDescPropertySelected.setValue(initialExportOrder.getSortCriteria().get(2).descending);
- preferences.putBoolean(JabRefPreferences.LOCAL_AUTO_SAVE, autosaveLocalLibraries.getValue());
+ autosaveLocalLibraries.setValue(preferences.getShouldAutosave());
}
- ValidationStatus mainFileDirValidationStatus() {
- return mainFileDirValidator.getValidationStatus();
+ @Override
+ public void storeSettings() {
+ preferences.storeOpenLastFilesOnStartup(openLastStartupProperty.getValue());
+
+ ImportExportPreferences newImportExportPreferences = new ImportExportPreferences(
+ noWrapFilesProperty.getValue().trim(),
+ resolveStringsBibTexProperty.getValue(),
+ resolveStringsAllProperty.getValue(),
+ resolveStringsExceptProperty.getValue().trim(),
+ selectedNewLineSeparatorProperty.getValue(),
+ alwaysReformatBibProperty.getValue());
+ preferences.storeImportExportPreferences(newImportExportPreferences);
+
+ SaveOrderConfig newSaveOrderConfig = new SaveOrderConfig(
+ saveInOriginalProperty.getValue(),
+ saveInSpecifiedOrderProperty.getValue(),
+ new SaveOrderConfig.SortCriterion(
+ savePrimarySortSelectedValueProperty.get(),
+ savePrimaryDescPropertySelected.getValue()),
+ new SaveOrderConfig.SortCriterion(
+ saveSecondarySortSelectedValueProperty.get(),
+ saveSecondaryDescPropertySelected.getValue()),
+ new SaveOrderConfig.SortCriterion(
+ saveTertiarySortSelectedValueProperty.get(),
+ saveTertiaryDescPropertySelected.getValue()));
+ preferences.storeExportSaveOrder(newSaveOrderConfig);
+
+ preferences.storeShouldAutosave(autosaveLocalLibraries.getValue());
}
@Override
public boolean validateSettings() {
- ValidationStatus validationStatus = mainFileDirValidationStatus();
- if (!validationStatus.isValid()) {
- validationStatus.getHighestMessage().ifPresent(message ->
- dialogService.showErrorDialogAndWait(message.getMessage()));
- return false;
- }
- return true;
+ return false;
}
@Override
public List getRestartWarnings() {
- return new ArrayList<>();
- }
-
- public void mainFileDirBrowse() {
- DirectoryDialogConfiguration dirDialogConfiguration =
- new DirectoryDialogConfiguration.Builder().withInitialDirectory(Path.of(mainFileDirProperty.getValue())).build();
- dialogService.showDirectorySelectionDialog(dirDialogConfiguration)
- .ifPresent(f -> mainFileDirProperty.setValue(f.toString()));
+ return null;
}
// General
@@ -186,44 +169,58 @@ public BooleanProperty alwaysReformatBibProperty() {
return alwaysReformatBibProperty;
}
- // External file links
+ // Autosave
+ public BooleanProperty autosaveLocalLibrariesProperty() {
+ return autosaveLocalLibraries;
+ }
+
+ // SaveOrderConfigPanel
- public StringProperty mainFileDirProperty() {
- return mainFileDirProperty;
+ public BooleanProperty saveInOriginalProperty() {
+ return saveInOriginalProperty;
}
- public BooleanProperty useBibLocationAsPrimaryProperty() {
- return useBibLocationAsPrimaryProperty;
+ public BooleanProperty saveInTableOrderProperty() {
+ return saveInTableOrderProperty;
}
- public BooleanProperty autolinkFileStartsBibtexProperty() {
- return autolinkFileStartsBibtexProperty;
+ public BooleanProperty saveInSpecifiedOrderProperty() {
+ return saveInSpecifiedOrderProperty;
}
- public BooleanProperty autolinkFileExactBibtexProperty() {
- return autolinkFileExactBibtexProperty;
+ public ListProperty primarySortFieldsProperty() {
+ return primarySortFieldsProperty;
}
- public BooleanProperty autolinkUseRegexProperty() {
- return autolinkUseRegexProperty;
+ public ListProperty secondarySortFieldsProperty() {
+ return secondarySortFieldsProperty;
}
- public StringProperty autolinkRegexKeyProperty() {
- return autolinkRegexKeyProperty;
+ public ListProperty tertiarySortFieldsProperty() {
+ return tertiarySortFieldsProperty;
}
- public BooleanProperty searchFilesOnOpenProperty() {
- return searchFilesOnOpenProperty;
+ public ObjectProperty savePrimarySortSelectedValueProperty() {
+ return savePrimarySortSelectedValueProperty;
}
- public BooleanProperty openBrowseOnCreateProperty() {
- return openBrowseOnCreateProperty;
+ public ObjectProperty saveSecondarySortSelectedValueProperty() {
+ return saveSecondarySortSelectedValueProperty;
}
- // Autosave
+ public ObjectProperty saveTertiarySortSelectedValueProperty() {
+ return saveTertiarySortSelectedValueProperty;
+ }
- public BooleanProperty autosaveLocalLibrariesProperty() {
- return autosaveLocalLibraries;
+ public BooleanProperty savePrimaryDescPropertySelected() {
+ return savePrimaryDescPropertySelected;
}
-}
+ public BooleanProperty saveSecondaryDescPropertySelected() {
+ return saveSecondaryDescPropertySelected;
+ }
+
+ public BooleanProperty saveTertiaryDescPropertySelected() {
+ return saveTertiaryDescPropertySelected;
+ }
+}
diff --git a/src/main/java/org/jabref/gui/preferences/GeneralTabView.java b/src/main/java/org/jabref/gui/preferences/GeneralTabView.java
index 3d0fdf2cffa..b861f86e20f 100644
--- a/src/main/java/org/jabref/gui/preferences/GeneralTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/GeneralTabView.java
@@ -10,7 +10,7 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
@@ -20,7 +20,7 @@
import org.jabref.logic.l10n.Language;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseMode;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -51,7 +51,7 @@ public class GeneralTabView extends AbstractPreferenceTabView
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/GroupsTabView.java b/src/main/java/org/jabref/gui/preferences/GroupsTabView.java
index e25ccd47438..023e0de06d2 100644
--- a/src/main/java/org/jabref/gui/preferences/GroupsTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/GroupsTabView.java
@@ -6,21 +6,19 @@
import javafx.scene.control.TextField;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
public class GroupsTabView extends AbstractPreferenceTabView implements PreferencesTab {
- @FXML private CheckBox grayNonHits;
@FXML private RadioButton groupViewModeIntersection;
@FXML private RadioButton groupViewModeUnion;
@FXML private CheckBox autoAssignGroup;
@FXML private CheckBox displayGroupCount;
- @FXML private TextField defaultGroupingField;
@FXML private TextField keywordSeparator;
- public GroupsTabView(JabRefPreferences preferences) {
+ public GroupsTabView(PreferencesService preferences) {
this.preferences = preferences;
ViewLoader.view(this)
@@ -36,12 +34,10 @@ public String getTabName() {
public void initialize() {
this.viewModel = new GroupsTabViewModel(dialogService, preferences);
- grayNonHits.selectedProperty().bindBidirectional(viewModel.grayNonHitsProperty());
groupViewModeIntersection.selectedProperty().bindBidirectional(viewModel.groupViewModeIntersectionProperty());
groupViewModeUnion.selectedProperty().bindBidirectional(viewModel.groupViewModeUnionProperty());
autoAssignGroup.selectedProperty().bindBidirectional(viewModel.autoAssignGroupProperty());
displayGroupCount.selectedProperty().bindBidirectional(viewModel.displayGroupCount());
- defaultGroupingField.textProperty().bindBidirectional(viewModel.defaultGroupingFieldProperty());
keywordSeparator.textProperty().bindBidirectional(viewModel.keywordSeparatorProperty());
}
}
diff --git a/src/main/java/org/jabref/gui/preferences/GroupsTabViewModel.java b/src/main/java/org/jabref/gui/preferences/GroupsTabViewModel.java
index 67abce42a7b..c2cc3fcfd02 100644
--- a/src/main/java/org/jabref/gui/preferences/GroupsTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/GroupsTabViewModel.java
@@ -10,59 +10,57 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.groups.GroupViewMode;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.gui.groups.GroupsPreferences;
+import org.jabref.preferences.PreferencesService;
public class GroupsTabViewModel implements PreferenceTabViewModel {
- private final BooleanProperty grayNonHitsProperty = new SimpleBooleanProperty();
private final BooleanProperty groupViewModeIntersectionProperty = new SimpleBooleanProperty();
private final BooleanProperty groupViewModeUnionProperty = new SimpleBooleanProperty();
private final BooleanProperty autoAssignGroupProperty = new SimpleBooleanProperty();
private final BooleanProperty displayGroupCountProperty = new SimpleBooleanProperty();
- private final StringProperty defaultGroupingFieldProperty = new SimpleStringProperty("");
private final StringProperty keywordSeparatorProperty = new SimpleStringProperty("");
private final DialogService dialogService;
- private final JabRefPreferences preferences;
+ private final PreferencesService preferences;
+ private final GroupsPreferences initialGroupsPreferences;
- public GroupsTabViewModel(DialogService dialogService, JabRefPreferences preferences) {
+ public GroupsTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
+ this.initialGroupsPreferences = preferences.getGroupsPreferences();
}
@Override
public void setValues() {
- grayNonHitsProperty.setValue(preferences.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
- switch (preferences.getGroupViewMode()) {
- case INTERSECTION:
+ switch (initialGroupsPreferences.getGroupViewMode()) {
+ case INTERSECTION -> {
groupViewModeIntersectionProperty.setValue(true);
groupViewModeUnionProperty.setValue(false);
- break;
- case UNION:
+ }
+ case UNION -> {
groupViewModeIntersectionProperty.setValue(false);
groupViewModeUnionProperty.setValue(true);
- break;
+ }
}
- autoAssignGroupProperty.setValue(preferences.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
- displayGroupCountProperty.setValue(preferences.getBoolean(JabRefPreferences.DISPLAY_GROUP_COUNT));
-
- defaultGroupingFieldProperty.setValue(preferences.get(JabRefPreferences.GROUPS_DEFAULT_FIELD));
- keywordSeparatorProperty.setValue(preferences.get(JabRefPreferences.KEYWORD_SEPARATOR));
+ autoAssignGroupProperty.setValue(initialGroupsPreferences.shouldAutoAssignGroup());
+ displayGroupCountProperty.setValue(initialGroupsPreferences.shouldDisplayGroupCount());
+ keywordSeparatorProperty.setValue(initialGroupsPreferences.getKeywordDelimiter().toString());
}
@Override
public void storeSettings() {
- preferences.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayNonHitsProperty.getValue());
+ GroupViewMode groupViewMode = GroupViewMode.UNION;
if (groupViewModeIntersectionProperty.getValue()) {
- preferences.setGroupViewMode(GroupViewMode.INTERSECTION);
- } else if (groupViewModeUnionProperty.getValue()) {
- preferences.setGroupViewMode(GroupViewMode.UNION);
+ groupViewMode = GroupViewMode.INTERSECTION;
}
- preferences.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroupProperty.getValue());
- preferences.putBoolean(JabRefPreferences.DISPLAY_GROUP_COUNT, displayGroupCountProperty.getValue());
- preferences.put(JabRefPreferences.GROUPS_DEFAULT_FIELD, defaultGroupingFieldProperty.getValue().trim());
- preferences.put(JabRefPreferences.KEYWORD_SEPARATOR, keywordSeparatorProperty.getValue());
+ GroupsPreferences newGroupsPreferences = new GroupsPreferences(
+ groupViewMode,
+ autoAssignGroupProperty.getValue(),
+ displayGroupCountProperty.getValue(),
+ keywordSeparatorProperty.getValue().charAt(0));
+ preferences.storeGroupsPreferences(newGroupsPreferences);
}
@Override
@@ -75,10 +73,6 @@ public List getRestartWarnings() {
return new ArrayList<>();
}
- public BooleanProperty grayNonHitsProperty() {
- return grayNonHitsProperty;
- }
-
public BooleanProperty groupViewModeIntersectionProperty() {
return groupViewModeIntersectionProperty;
}
@@ -95,10 +89,6 @@ public BooleanProperty displayGroupCount() {
return displayGroupCountProperty;
}
- public StringProperty defaultGroupingFieldProperty() {
- return defaultGroupingFieldProperty;
- }
-
public StringProperty keywordSeparatorProperty() {
return keywordSeparatorProperty;
}
diff --git a/src/main/java/org/jabref/gui/preferences/ImportTab.fxml b/src/main/java/org/jabref/gui/preferences/ImportTab.fxml
deleted file mode 100644
index 3515eb968a9..00000000000
--- a/src/main/java/org/jabref/gui/preferences/ImportTab.fxml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/jabref/gui/preferences/ImportTabView.java b/src/main/java/org/jabref/gui/preferences/ImportTabView.java
deleted file mode 100644
index 7edb62d62d1..00000000000
--- a/src/main/java/org/jabref/gui/preferences/ImportTabView.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.jabref.gui.preferences;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.ComboBox;
-import javafx.scene.control.TextField;
-
-import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
-
-import com.airhacks.afterburner.views.ViewLoader;
-
-public class ImportTabView extends AbstractPreferenceTabView implements PreferencesTab {
-
- @FXML private ComboBox fileNamePattern;
- @FXML private TextField fileDirectoryPattern;
-
- public ImportTabView(JabRefPreferences preferences) {
- this.preferences = preferences;
-
- ViewLoader.view(this)
- .root(this)
- .load();
- }
-
- public void initialize() {
- this.viewModel = new ImportTabViewModel(preferences);
-
- fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
- fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
- fileDirectoryPattern.textProperty().bindBidirectional(viewModel.fileDirPatternProperty());
- }
-
- @Override
- public String getTabName() {
- return Localization.lang("Import");
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/ImportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/ImportTabViewModel.java
deleted file mode 100644
index 68aec5e2fba..00000000000
--- a/src/main/java/org/jabref/gui/preferences/ImportTabViewModel.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.jabref.gui.preferences;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javafx.beans.property.ListProperty;
-import javafx.beans.property.SimpleListProperty;
-import javafx.beans.property.SimpleStringProperty;
-import javafx.beans.property.StringProperty;
-import javafx.collections.FXCollections;
-
-import org.jabref.preferences.JabRefPreferences;
-
-public class ImportTabViewModel implements PreferenceTabViewModel {
-
- public static final String[] DEFAULT_FILENAME_PATTERNS = new String[] {"[bibtexkey]", "[bibtexkey] - [title]"};
-
- private final ListProperty defaultFileNamePatternsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(DEFAULT_FILENAME_PATTERNS));
- private final StringProperty fileNamePatternProperty = new SimpleStringProperty();
- private final StringProperty fileDirPatternProperty = new SimpleStringProperty();
-
- private final JabRefPreferences preferences;
-
- public ImportTabViewModel(JabRefPreferences preferences) {
- this.preferences = preferences;
- }
-
- @Override
- public void setValues() {
- fileNamePatternProperty.setValue(preferences.get(JabRefPreferences.IMPORT_FILENAMEPATTERN));
- fileDirPatternProperty.setValue(preferences.get(JabRefPreferences.IMPORT_FILEDIRPATTERN));
- }
-
- @Override
- public void storeSettings() {
- preferences.put(JabRefPreferences.IMPORT_FILENAMEPATTERN, fileNamePatternProperty.getValue());
- preferences.put(JabRefPreferences.IMPORT_FILEDIRPATTERN, fileDirPatternProperty.getValue());
- }
-
- @Override
- public boolean validateSettings() {
- return true;
- }
-
- @Override
- public List getRestartWarnings() {
- return new ArrayList<>();
- }
-
- public ListProperty defaultFileNamePatternsProperty() {
- return defaultFileNamePatternsProperty;
- }
-
- public StringProperty fileNamePatternProperty() {
- return fileNamePatternProperty;
- }
-
- public StringProperty fileDirPatternProperty() {
- return fileDirPatternProperty;
- }
-}
diff --git a/src/main/java/org/jabref/gui/preferences/LinkedFilesTab.fxml b/src/main/java/org/jabref/gui/preferences/LinkedFilesTab.fxml
new file mode 100644
index 00000000000..b4c151e971d
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/LinkedFilesTab.fxml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/preferences/LinkedFilesTabView.java b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabView.java
new file mode 100644
index 00000000000..a8b1fa4340b
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabView.java
@@ -0,0 +1,79 @@
+package org.jabref.gui.preferences;
+
+import javafx.application.Platform;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.RadioButton;
+import javafx.scene.control.TextField;
+
+import org.jabref.gui.Globals;
+import org.jabref.gui.actions.ActionFactory;
+import org.jabref.gui.actions.StandardActions;
+import org.jabref.gui.help.HelpAction;
+import org.jabref.gui.util.IconValidationDecorator;
+import org.jabref.logic.help.HelpFile;
+import org.jabref.logic.l10n.Localization;
+import org.jabref.preferences.PreferencesService;
+
+import com.airhacks.afterburner.views.ViewLoader;
+import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
+
+public class LinkedFilesTabView extends AbstractPreferenceTabView implements PreferencesTab {
+
+ @FXML private TextField mainFileDirectory;
+ @FXML private CheckBox useBibLocationAsPrimary;
+ @FXML private Button autolinkRegexHelp;
+ @FXML private RadioButton autolinkFileStartsBibtex;
+ @FXML private RadioButton autolinkFileExactBibtex;
+ @FXML private RadioButton autolinkUseRegex;
+ @FXML private TextField autolinkRegexKey;
+ @FXML private CheckBox searchFilesOnOpen;
+ @FXML private CheckBox openBrowseOnCreate;
+
+ @FXML private ComboBox fileNamePattern;
+ @FXML private TextField fileDirectoryPattern;
+
+ private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
+
+ public LinkedFilesTabView(PreferencesService preferences) {
+ this.preferences = preferences;
+
+ ViewLoader.view(this)
+ .root(this)
+ .load();
+ }
+
+ @Override
+ public String getTabName() {
+ return Localization.lang("Linked files");
+ }
+
+ public void initialize() {
+ this.viewModel = new LinkedFilesTabViewModel(dialogService, preferences);
+
+ mainFileDirectory.textProperty().bindBidirectional(viewModel.mainFileDirectoryProperty());
+ useBibLocationAsPrimary.selectedProperty().bindBidirectional(viewModel.useBibLocationAsPrimaryProperty());
+ autolinkFileStartsBibtex.selectedProperty().bindBidirectional(viewModel.autolinkFileStartsBibtexProperty());
+ autolinkFileExactBibtex.selectedProperty().bindBidirectional(viewModel.autolinkFileExactBibtexProperty());
+ autolinkUseRegex.selectedProperty().bindBidirectional(viewModel.autolinkUseRegexProperty());
+ autolinkRegexKey.textProperty().bindBidirectional(viewModel.autolinkRegexKeyProperty());
+ autolinkRegexKey.disableProperty().bind(autolinkUseRegex.selectedProperty().not());
+ searchFilesOnOpen.selectedProperty().bindBidirectional(viewModel.searchFilesOnOpenProperty());
+ openBrowseOnCreate.selectedProperty().bindBidirectional(viewModel.openBrowseOnCreateProperty());
+ fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
+ fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
+ fileDirectoryPattern.textProperty().bindBidirectional(viewModel.fileDirectoryPatternProperty());
+
+ ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
+ actionFactory.configureIconButton(StandardActions.HELP_REGEX_SEARCH, new HelpAction(HelpFile.REGEX_SEARCH), autolinkRegexHelp);
+
+ validationVisualizer.setDecoration(new IconValidationDecorator());
+ Platform.runLater(() -> validationVisualizer.initVisualization(viewModel.mainFileDirValidationStatus(), mainFileDirectory));
+ }
+
+ public void mainFileDirBrowse() {
+ viewModel.mainFileDirBrowse();
+ }
+}
diff --git a/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java
new file mode 100644
index 00000000000..66539b9f197
--- /dev/null
+++ b/src/main/java/org/jabref/gui/preferences/LinkedFilesTabViewModel.java
@@ -0,0 +1,192 @@
+package org.jabref.gui.preferences;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+import javafx.beans.property.BooleanProperty;
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.beans.property.StringProperty;
+import javafx.collections.FXCollections;
+
+import org.jabref.gui.DialogService;
+import org.jabref.gui.util.DirectoryDialogConfiguration;
+import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.util.io.AutoLinkPreferences;
+import org.jabref.preferences.FilePreferences;
+import org.jabref.preferences.PreferencesService;
+
+import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
+import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
+import de.saxsys.mvvmfx.utils.validation.ValidationStatus;
+import de.saxsys.mvvmfx.utils.validation.Validator;
+
+public class LinkedFilesTabViewModel implements PreferenceTabViewModel {
+
+ private final StringProperty mainFileDirectoryProperty = new SimpleStringProperty("");
+ private final BooleanProperty useBibLocationAsPrimaryProperty = new SimpleBooleanProperty();
+ private final BooleanProperty autolinkFileStartsBibtexProperty = new SimpleBooleanProperty();
+ private final BooleanProperty autolinkFileExactBibtexProperty = new SimpleBooleanProperty();
+ private final BooleanProperty autolinkUseRegexProperty = new SimpleBooleanProperty();
+ private final StringProperty autolinkRegexKeyProperty = new SimpleStringProperty("");
+ private final BooleanProperty searchFilesOnOpenProperty = new SimpleBooleanProperty();
+ private final BooleanProperty openBrowseOnCreateProperty = new SimpleBooleanProperty();
+ private final ListProperty defaultFileNamePatternsProperty =
+ new SimpleListProperty<>(FXCollections.observableArrayList(FilePreferences.DEFAULT_FILENAME_PATTERNS));
+ private final StringProperty fileNamePatternProperty = new SimpleStringProperty();
+ private final StringProperty fileDirectoryPatternProperty = new SimpleStringProperty();
+
+ private final Validator mainFileDirValidator;
+
+ private final DialogService dialogService;
+ private final PreferencesService preferences;
+ private final FilePreferences initialFilePreferences;
+ private final AutoLinkPreferences initialAutoLinkPreferences;
+
+ public LinkedFilesTabViewModel(DialogService dialogService, PreferencesService preferences) {
+ this.dialogService = dialogService;
+ this.preferences = preferences;
+ this.initialFilePreferences = preferences.getFilePreferences();
+ this.initialAutoLinkPreferences = preferences.getAutoLinkPreferences();
+
+ mainFileDirValidator = new FunctionBasedValidator<>(
+ mainFileDirectoryProperty,
+ input -> {
+ Path path = Path.of(mainFileDirectoryProperty.getValue());
+ return (Files.exists(path) && Files.isDirectory(path));
+ },
+ ValidationMessage.error(String.format("%s > %s > %s %n %n %s",
+ Localization.lang("File"),
+ Localization.lang("External file links"),
+ Localization.lang("Main file directory"),
+ Localization.lang("Directory not found")
+ )
+ )
+ );
+ }
+
+ @Override
+ public void setValues() {
+ // External files preferences / Attached files preferences / File preferences
+ mainFileDirectoryProperty.setValue(initialFilePreferences.getFileDirectory().orElse(Path.of("")).toString());
+ useBibLocationAsPrimaryProperty.setValue(initialFilePreferences.isBibLocationAsPrimary());
+ searchFilesOnOpenProperty.setValue(initialFilePreferences.shouldSearchFilesOnOpen());
+ openBrowseOnCreateProperty.setValue(initialFilePreferences.shouldOpenBrowseOnCreate());
+ fileNamePatternProperty.setValue(initialFilePreferences.getFileNamePattern());
+ fileDirectoryPatternProperty.setValue(initialFilePreferences.getFileDirectoryPattern());
+
+ // Autolink preferences
+ switch (initialAutoLinkPreferences.getCitationKeyDependency()) {
+ case START -> autolinkFileStartsBibtexProperty.setValue(true);
+ case EXACT -> autolinkFileExactBibtexProperty.setValue(true);
+ case REGEX -> autolinkUseRegexProperty.setValue(true);
+ }
+
+ autolinkRegexKeyProperty.setValue(initialAutoLinkPreferences.getRegularExpression());
+ }
+
+ @Override
+ public void storeSettings() {
+ // External files preferences / Attached files preferences / File preferences
+ preferences.storeFilePreferences(new FilePreferences(
+ initialFilePreferences.getUser(),
+ mainFileDirectoryProperty.getValue(),
+ useBibLocationAsPrimaryProperty.getValue(),
+ fileNamePatternProperty.getValue(),
+ fileDirectoryPatternProperty.getValue(),
+ initialFilePreferences.shouldDownloadLinkedFiles(), // set in ImportEntriesViewModel
+ searchFilesOnOpenProperty.getValue(),
+ openBrowseOnCreateProperty.getValue()));
+
+ // Autolink preferences
+ AutoLinkPreferences.CitationKeyDependency citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.START;
+ if (autolinkFileExactBibtexProperty.getValue()) {
+ citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.EXACT;
+ } else if (autolinkUseRegexProperty.getValue()) {
+ citationKeyDependency = AutoLinkPreferences.CitationKeyDependency.REGEX;
+ }
+
+ preferences.storeAutoLinkPreferences(new AutoLinkPreferences(
+ citationKeyDependency,
+ autolinkRegexKeyProperty.getValue(),
+ preferences.getKeywordDelimiter()));
+ }
+
+ ValidationStatus mainFileDirValidationStatus() {
+ return mainFileDirValidator.getValidationStatus();
+ }
+
+ @Override
+ public boolean validateSettings() {
+ ValidationStatus validationStatus = mainFileDirValidationStatus();
+ if (!validationStatus.isValid()) {
+ validationStatus.getHighestMessage().ifPresent(message ->
+ dialogService.showErrorDialogAndWait(message.getMessage()));
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public List getRestartWarnings() {
+ return new ArrayList<>();
+ }
+
+ public void mainFileDirBrowse() {
+ DirectoryDialogConfiguration dirDialogConfiguration =
+ new DirectoryDialogConfiguration.Builder().withInitialDirectory(Path.of(mainFileDirectoryProperty.getValue())).build();
+ dialogService.showDirectorySelectionDialog(dirDialogConfiguration)
+ .ifPresent(f -> mainFileDirectoryProperty.setValue(f.toString()));
+ }
+
+ // External file links
+
+ public StringProperty mainFileDirectoryProperty() {
+ return mainFileDirectoryProperty;
+ }
+
+ public BooleanProperty useBibLocationAsPrimaryProperty() {
+ return useBibLocationAsPrimaryProperty;
+ }
+
+ public BooleanProperty autolinkFileStartsBibtexProperty() {
+ return autolinkFileStartsBibtexProperty;
+ }
+
+ public BooleanProperty autolinkFileExactBibtexProperty() {
+ return autolinkFileExactBibtexProperty;
+ }
+
+ public BooleanProperty autolinkUseRegexProperty() {
+ return autolinkUseRegexProperty;
+ }
+
+ public StringProperty autolinkRegexKeyProperty() {
+ return autolinkRegexKeyProperty;
+ }
+
+ public BooleanProperty searchFilesOnOpenProperty() {
+ return searchFilesOnOpenProperty;
+ }
+
+ public BooleanProperty openBrowseOnCreateProperty() {
+ return openBrowseOnCreateProperty;
+ }
+
+ public ListProperty defaultFileNamePatternsProperty() {
+ return defaultFileNamePatternsProperty;
+ }
+
+ public StringProperty fileNamePatternProperty() {
+ return fileNamePatternProperty;
+ }
+
+ public StringProperty fileDirectoryPatternProperty() {
+ return fileDirectoryPatternProperty;
+ }
+}
+
diff --git a/src/main/java/org/jabref/gui/preferences/NameFormatterTabView.java b/src/main/java/org/jabref/gui/preferences/NameFormatterTabView.java
index 1313d4fbef0..d2499990894 100644
--- a/src/main/java/org/jabref/gui/preferences/NameFormatterTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/NameFormatterTabView.java
@@ -9,7 +9,7 @@
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
@@ -17,7 +17,7 @@
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
@@ -31,7 +31,7 @@ public class NameFormatterTabView extends AbstractPreferenceTabView names = preferences.getStringList(JabRefPreferences.NAME_FORMATER_KEY);
- List formats = preferences.getStringList(JabRefPreferences.NAME_FORMATTER_VALUE);
+ List names = initialNameFormatterPreferences.getNameFormatterKey();
+ List formats = initialNameFormatterPreferences.getNameFormatterValue();
for (int i = 0; i < names.size(); i++) {
if (i < formats.size()) {
@@ -53,8 +56,10 @@ public void storeSettings() {
formats.add(formatterListItem.getFormat());
}
- preferences.putStringList(JabRefPreferences.NAME_FORMATER_KEY, names);
- preferences.putStringList(JabRefPreferences.NAME_FORMATTER_VALUE, formats);
+ NameFormatterPreferences newNameFormatterPreferences = new NameFormatterPreferences(
+ names,
+ formats);
+ preferences.storeNameFormatterPreferences(newNameFormatterPreferences);
}
public void addFormatter() {
diff --git a/src/main/java/org/jabref/gui/preferences/NetworkTab.fxml b/src/main/java/org/jabref/gui/preferences/NetworkTab.fxml
index 77c3f00a629..148f7a50873 100644
--- a/src/main/java/org/jabref/gui/preferences/NetworkTab.fxml
+++ b/src/main/java/org/jabref/gui/preferences/NetworkTab.fxml
@@ -53,5 +53,7 @@
GridPane.rowIndex="5"/>
+
diff --git a/src/main/java/org/jabref/gui/preferences/NetworkTabView.java b/src/main/java/org/jabref/gui/preferences/NetworkTabView.java
index 245d5f3ed5b..e484bb357bd 100644
--- a/src/main/java/org/jabref/gui/preferences/NetworkTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/NetworkTabView.java
@@ -9,7 +9,7 @@
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
@@ -17,7 +17,7 @@
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -40,13 +40,14 @@ public class NetworkTabView extends AbstractPreferenceTabView restartWarning = new ArrayList<>();
public NetworkTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
- this.remotePreferences = preferences.getRemotePreferences();
- this.proxyPreferences = preferences.getProxyPreferences();
+ this.initialRemotePreferences = preferences.getRemotePreferences();
+ this.initialProxyPreferences = preferences.getProxyPreferences();
remotePortValidator = new FunctionBasedValidator<>(
remotePortProperty,
@@ -104,15 +107,19 @@ public NetworkTabViewModel(DialogService dialogService, PreferencesService prefe
}
public void setValues() {
- remoteServerProperty.setValue(remotePreferences.useRemoteServer());
- remotePortProperty.setValue(String.valueOf(remotePreferences.getPort()));
+ remoteServerProperty.setValue(initialRemotePreferences.useRemoteServer());
+ remotePortProperty.setValue(String.valueOf(initialRemotePreferences.getPort()));
- proxyUseProperty.setValue(proxyPreferences.isUseProxy());
- proxyHostnameProperty.setValue(proxyPreferences.getHostname());
- proxyPortProperty.setValue(proxyPreferences.getPort());
- proxyUseAuthenticationProperty.setValue(proxyPreferences.isUseAuthentication());
- proxyUsernameProperty.setValue(proxyPreferences.getUsername());
- proxyPasswordProperty.setValue(proxyPreferences.getPassword());
+ setProxyValues();
+ }
+
+ private void setProxyValues() {
+ proxyUseProperty.setValue(initialProxyPreferences.isUseProxy());
+ proxyHostnameProperty.setValue(initialProxyPreferences.getHostname());
+ proxyPortProperty.setValue(initialProxyPreferences.getPort());
+ proxyUseAuthenticationProperty.setValue(initialProxyPreferences.isUseAuthentication());
+ proxyUsernameProperty.setValue(initialProxyPreferences.getUsername());
+ proxyPasswordProperty.setValue(initialProxyPreferences.getPassword());
}
public void storeSettings() {
@@ -122,12 +129,12 @@ public void storeSettings() {
private void storeRemoteSettings() {
RemotePreferences newRemotePreferences = new RemotePreferences(
- remotePreferences.getPort(),
+ initialRemotePreferences.getPort(),
remoteServerProperty.getValue()
);
getPortAsInt(remotePortProperty.getValue()).ifPresent(newPort -> {
- if (remotePreferences.isDifferentPort(newPort)) {
+ if (initialRemotePreferences.isDifferentPort(newPort)) {
newRemotePreferences.setPort(newPort);
if (newRemotePreferences.useRemoteServer()) {
@@ -137,7 +144,7 @@ private void storeRemoteSettings() {
});
if (newRemotePreferences.useRemoteServer()) {
- Globals.REMOTE_LISTENER.openAndStart(new JabRefMessageHandler(), remotePreferences.getPort());
+ Globals.REMOTE_LISTENER.openAndStart(new JabRefMessageHandler(), initialRemotePreferences.getPort());
} else {
Globals.REMOTE_LISTENER.stop();
}
@@ -155,7 +162,7 @@ private void storeProxySettings() {
proxyPasswordProperty.getValue()
);
- if (!newProxyPreferences.equals(proxyPreferences)) {
+ if (!newProxyPreferences.equals(initialProxyPreferences)) {
ProxyRegisterer.register(newProxyPreferences);
}
preferences.storeProxyPreferences(newProxyPreferences);
@@ -215,6 +222,39 @@ public boolean validateSettings() {
return true;
}
+ /**
+ * Check the connection by using the given url. Used for validating the http proxy.
+ * The checking result will be appear when request finished.
+ * The checking result could be either success or fail, if fail, the cause will be displayed.
+ */
+ public void checkConnection() {
+ final String connectionSuccessText = Localization.lang("Connection successful!");
+ final String connectionFailedText = Localization.lang("Connection failed!");
+ final String dialogTitle = Localization.lang("Check Proxy Setting");
+
+ final String testUrl = "http://jabref.org";
+
+ // Workaround for testing, since the URLDownload uses stored proxy settings, see
+ // preferences.storeProxyPreferences(...) below.
+ storeProxySettings();
+
+ URLDownload urlDownload;
+ try {
+ urlDownload = new URLDownload(testUrl);
+ if (urlDownload.canBeReached()) {
+ dialogService.showInformationDialogAndWait(dialogTitle, connectionSuccessText);
+ } else {
+ dialogService.showErrorDialogAndWait(dialogTitle, connectionFailedText);
+ }
+ } catch (MalformedURLException e) {
+ // Why would that happen? Because one of developers inserted a failing url in testUrl...
+ } catch (UnirestException e) {
+ dialogService.showErrorDialogAndWait(dialogTitle, connectionFailedText);
+ }
+
+ preferences.storeProxyPreferences(initialProxyPreferences);
+ }
+
@Override
public List getRestartWarnings() {
return restartWarning;
diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
index 34fbcfc9822..0d02d553374 100644
--- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java
@@ -8,13 +8,13 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
-import org.jabref.Globals;
-import org.jabref.JabRefException;
import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.push.PushToApplicationsManager;
import org.jabref.gui.util.FileDialogConfiguration;
+import org.jabref.logic.JabRefException;
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.exporter.SavePreferences;
import org.jabref.logic.exporter.TemplateExporter;
@@ -52,8 +52,7 @@ public PreferencesDialogViewModel(DialogService dialogService, JabRefFrame frame
new GroupsTabView(preferences),
new EntryEditorTabView(preferences),
new CitationKeyPatternTabView(preferences),
- new ImportTabView(preferences),
- new ExportSortingTabView(preferences),
+ new LinkedFilesTabView(preferences),
new NameFormatterTabView(preferences),
new XmpPrivacyTabView(preferences),
new NetworkTabView(preferences),
@@ -69,7 +68,7 @@ public void importPreferences() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.XML)
.withDefaultExtension(StandardFileType.XML)
- .withInitialDirectory(preferences.setLastPreferencesExportPath()).build();
+ .withInitialDirectory(preferences.getLastPreferencesExportPath()).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> {
try {
@@ -89,7 +88,7 @@ public void exportPreferences() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.XML)
.withDefaultExtension(StandardFileType.XML)
- .withInitialDirectory(preferences.setLastPreferencesExportPath())
+ .withInitialDirectory(preferences.getLastPreferencesExportPath())
.build();
dialogService.showFileSaveDialog(fileDialogConfiguration)
@@ -97,7 +96,7 @@ public void exportPreferences() {
try {
storeAllSettings();
preferences.exportPreferences(exportFile);
- preferences.setLastPreferencesExportPath(exportFile);
+ preferences.storeLastPreferencesExportPath(exportFile);
} catch (JabRefException ex) {
LOGGER.warn(ex.getMessage(), ex);
dialogService.showErrorDialogAndWait(Localization.lang("Export preferences"), ex);
@@ -143,8 +142,8 @@ private void updateAfterPreferenceChanges() {
List customExporters = preferences.getCustomExportFormats(Globals.journalAbbreviationRepository);
LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(Globals.journalAbbreviationRepository);
- SavePreferences savePreferences = preferences.loadForExportFromPreferences();
- XmpPreferences xmpPreferences = preferences.getXMPPreferences();
+ SavePreferences savePreferences = preferences.getSavePreferencesForExport();
+ XmpPreferences xmpPreferences = preferences.getXmpPreferences();
Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences);
ExternalApplicationsPreferences externalApplicationsPreferences = preferences.getExternalApplicationsPreferences();
@@ -156,10 +155,7 @@ private void updateAfterPreferenceChanges() {
/**
* Checks if all tabs are valid
- * ToDo: After conversion of all tabs use mvvmfx-validator
- * ToDo: should be observable for binding of OK-button in View
*/
-
public boolean validSettings() {
for (PreferencesTab tab : preferenceTabs) {
if (!tab.validateSettings()) {
diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java
index a1bc618b641..8ddafe09a47 100644
--- a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java
@@ -21,7 +21,7 @@
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.SimpleCommand;
@@ -33,7 +33,7 @@
import org.jabref.logic.preview.PreviewLayout;
import org.jabref.logic.util.TestEntry;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
@@ -63,6 +63,14 @@ public class PreviewTabView extends AbstractPreferenceTabView editArea.copy();
+ case CUT -> editArea.cut();
+ case PASTE -> editArea.paste();
+ case SELECT_ALL -> editArea.selectAll();
}
editArea.requestFocus();
}
}
}
- public PreviewTabView(JabRefPreferences preferences) {
- this.preferences = preferences;
-
- ViewLoader.view(this)
- .root(this)
- .load();
- }
-
@Override
public String getTabName() {
return Localization.lang("Entry preview");
diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java b/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java
index e478914451e..78956920079 100644
--- a/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java
@@ -23,10 +23,10 @@
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
-import org.jabref.JabRefGUI;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.DragAndDropDataFormats;
+import org.jabref.gui.JabRefGUI;
import org.jabref.gui.StateManager;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.CustomLocalDragboard;
@@ -37,7 +37,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.TextBasedPreviewLayout;
import org.jabref.logic.preview.PreviewLayout;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import org.jabref.preferences.PreviewPreferences;
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
@@ -73,8 +73,8 @@ public class PreviewTabViewModel implements PreferenceTabViewModel {
private final StringProperty sourceTextProperty = new SimpleStringProperty("");
private final DialogService dialogService;
- private final JabRefPreferences preferences;
- private final PreviewPreferences previewPreferences;
+ private final PreferencesService preferences;
+ private final PreviewPreferences initialPreviewPreferences;
private final TaskExecutor taskExecutor;
private final Validator chosenListValidator;
@@ -83,12 +83,12 @@ public class PreviewTabViewModel implements PreferenceTabViewModel {
private ListProperty dragSourceList = null;
private ObjectProperty> dragSourceSelectionModel = null;
- public PreviewTabViewModel(DialogService dialogService, JabRefPreferences preferences, TaskExecutor taskExecutor, StateManager stateManager) {
+ public PreviewTabViewModel(DialogService dialogService, PreferencesService preferences, TaskExecutor taskExecutor, StateManager stateManager) {
this.dialogService = dialogService;
this.preferences = preferences;
this.taskExecutor = taskExecutor;
this.localDragboard = stateManager.getLocalDragboard();
- previewPreferences = preferences.getPreviewPreferences();
+ initialPreviewPreferences = preferences.getPreviewPreferences();
sourceTextProperty.addListener((observable, oldValue, newValue) -> {
if (getCurrentLayout() instanceof TextBasedPreviewLayout) {
@@ -113,13 +113,13 @@ public BooleanProperty showAsExtraTabProperty() {
}
public void setValues() {
- showAsExtraTab.set(previewPreferences.showPreviewAsExtraTab());
+ showAsExtraTab.set(initialPreviewPreferences.showPreviewAsExtraTab());
chosenListProperty().getValue().clear();
- chosenListProperty.getValue().addAll(previewPreferences.getPreviewCycle());
+ chosenListProperty.getValue().addAll(initialPreviewPreferences.getPreviewCycle());
availableListProperty.clear();
if (chosenListProperty.stream().noneMatch(layout -> layout instanceof TextBasedPreviewLayout)) {
- availableListProperty.getValue().add(previewPreferences.getTextBasedPreviewLayout());
+ availableListProperty.getValue().add(initialPreviewPreferences.getTextBasedPreviewLayout());
}
BackgroundTask.wrap(CitationStyle::discoverCitationStyles)
@@ -182,7 +182,7 @@ private PreviewLayout getCurrentLayout() {
PreviewLayout layout = findLayoutByName("Preview");
if (layout == null) {
- layout = previewPreferences.getTextBasedPreviewLayout();
+ layout = initialPreviewPreferences.getTextBasedPreviewLayout();
}
return layout;
diff --git a/src/main/java/org/jabref/gui/preferences/TableTabView.java b/src/main/java/org/jabref/gui/preferences/TableTabView.java
index cb92b5311f5..309ae7da5dd 100644
--- a/src/main/java/org/jabref/gui/preferences/TableTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/TableTabView.java
@@ -21,7 +21,7 @@
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -49,9 +49,7 @@ public class TableTabView extends AbstractPreferenceTabView i
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
- private final JabRefPreferences preferences;
-
- public TableTabView(JabRefPreferences preferences) {
+ public TableTabView(PreferencesService preferences) {
this.preferences = preferences;
ViewLoader.view(this)
diff --git a/src/main/java/org/jabref/gui/preferences/TableTabViewModel.java b/src/main/java/org/jabref/gui/preferences/TableTabViewModel.java
index 2cd6e8256b2..a2f464b4b2b 100644
--- a/src/main/java/org/jabref/gui/preferences/TableTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/TableTabViewModel.java
@@ -120,9 +120,9 @@ public void setValues() {
initialSpecialFieldsPreferences = preferences.getSpecialFieldsPreferences();
MainTableNameFormatPreferences initialNameFormatPreferences = preferences.getMainTableNameFormatPreferences();
- specialFieldsEnabledProperty.setValue(initialSpecialFieldsPreferences.getSpecialFieldsEnabled());
- specialFieldsSyncKeywordsProperty.setValue(initialSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords());
- specialFieldsSerializeProperty.setValue(initialSpecialFieldsPreferences.getSerializeSpecialFields());
+ specialFieldsEnabledProperty.setValue(initialSpecialFieldsPreferences.isSpecialFieldsEnabled());
+ specialFieldsSyncKeywordsProperty.setValue(initialSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords());
+ specialFieldsSerializeProperty.setValue(initialSpecialFieldsPreferences.shouldSerializeSpecialFields());
extraFileColumnsEnabledProperty.setValue(initialMainTablePreferences.getExtraFileColumnsEnabled());
autoResizeColumnsProperty.setValue(initialMainTablePreferences.getResizeColumnsToFit());
@@ -155,30 +155,16 @@ public void setValues() {
}
switch (initialNameFormatPreferences.getDisplayStyle()) {
- case NATBIB:
- namesNatbibProperty.setValue(true);
- break;
- case AS_IS:
- nameAsIsProperty.setValue(true);
- break;
- case FIRSTNAME_LASTNAME:
- nameFirstLastProperty.setValue(true);
- break;
- case LASTNAME_FIRSTNAME:
- nameLastFirstProperty.setValue(true);
- break;
+ case NATBIB -> namesNatbibProperty.setValue(true);
+ case AS_IS -> nameAsIsProperty.setValue(true);
+ case FIRSTNAME_LASTNAME -> nameFirstLastProperty.setValue(true);
+ case LASTNAME_FIRSTNAME -> nameLastFirstProperty.setValue(true);
}
switch (initialNameFormatPreferences.getAbbreviationStyle()) {
- case FULL:
- abbreviationEnabledProperty.setValue(true);
- break;
- case LASTNAME_ONLY:
- abbreviationLastNameOnlyProperty.setValue(true);
- break;
- case NONE:
- abbreviationDisabledProperty.setValue(true);
- break;
+ case FULL -> abbreviationEnabledProperty.setValue(true);
+ case LASTNAME_ONLY -> abbreviationLastNameOnlyProperty.setValue(true);
+ case NONE -> abbreviationDisabledProperty.setValue(true);
}
}
@@ -268,11 +254,11 @@ public void storeSettings() {
specialFieldsSyncKeywordsProperty.getValue(),
specialFieldsSerializeProperty.getValue());
- if (initialSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords() != newSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords()) {
+ if (initialSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords() != newSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords()) {
restartWarnings.add(Localization.lang("Synchronize special fields to keywords"));
}
- if (initialSpecialFieldsPreferences.getSerializeSpecialFields() != newSpecialFieldsPreferences.getSerializeSpecialFields()) {
+ if (initialSpecialFieldsPreferences.shouldSerializeSpecialFields() != newSpecialFieldsPreferences.shouldSerializeSpecialFields()) {
restartWarnings.add(Localization.lang("Serialize special fields"));
}
diff --git a/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabView.java b/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabView.java
index 77baff41b69..07b0ee2474a 100644
--- a/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabView.java
+++ b/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabView.java
@@ -18,7 +18,7 @@
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.field.Field;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import com.airhacks.afterburner.views.ViewLoader;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
@@ -32,9 +32,9 @@ public class XmpPrivacyTabView extends AbstractPreferenceTabView addFieldName;
@FXML private Button addField;
- private ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
+ private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
- public XmpPrivacyTabView(JabRefPreferences preferences) {
+ public XmpPrivacyTabView(PreferencesService preferences) {
this.preferences = preferences;
ViewLoader.view(this)
diff --git a/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabViewModel.java b/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabViewModel.java
index fc9bdd24f66..a54f8aa8053 100644
--- a/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabViewModel.java
+++ b/src/main/java/org/jabref/gui/preferences/XmpPrivacyTabViewModel.java
@@ -1,8 +1,8 @@
package org.jabref.gui.preferences;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
-import java.util.stream.Collectors;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
@@ -14,9 +14,10 @@
import org.jabref.gui.DialogService;
import org.jabref.logic.l10n.Localization;
+import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
-import org.jabref.preferences.JabRefPreferences;
+import org.jabref.preferences.PreferencesService;
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
@@ -31,13 +32,15 @@ public class XmpPrivacyTabViewModel implements PreferenceTabViewModel {
private final ObjectProperty addFieldProperty = new SimpleObjectProperty<>();
private final DialogService dialogService;
- private final JabRefPreferences preferences;
+ private final PreferencesService preferences;
+ private final XmpPreferences initialXmpPreferences;
- private Validator xmpFilterListValidator;
+ private final Validator xmpFilterListValidator;
- XmpPrivacyTabViewModel(DialogService dialogService, JabRefPreferences preferences) {
+ XmpPrivacyTabViewModel(DialogService dialogService, PreferencesService preferences) {
this.dialogService = dialogService;
this.preferences = preferences;
+ this.initialXmpPreferences = preferences.getXmpPreferences();
xmpFilterListValidator = new FunctionBasedValidator<>(
xmpFilterListProperty,
@@ -50,12 +53,10 @@ public class XmpPrivacyTabViewModel implements PreferenceTabViewModel {
@Override
public void setValues() {
- xmpFilterEnabledProperty.setValue(preferences.getBoolean(JabRefPreferences.USE_XMP_PRIVACY_FILTER));
+ xmpFilterEnabledProperty.setValue(initialXmpPreferences.shouldUseXmpPrivacyFilter());
xmpFilterListProperty.clear();
- List xmpFilters = preferences.getStringList(JabRefPreferences.XMP_PRIVACY_FILTERS)
- .stream().map(FieldFactory::parseField).collect(Collectors.toList());
- xmpFilterListProperty.addAll(xmpFilters);
+ xmpFilterListProperty.addAll(initialXmpPreferences.getXmpPrivacyFilter());
availableFieldsProperty.clear();
availableFieldsProperty.addAll(FieldFactory.getCommonFields());
@@ -63,10 +64,11 @@ public void setValues() {
@Override
public void storeSettings() {
- preferences.putBoolean(JabRefPreferences.USE_XMP_PRIVACY_FILTER, xmpFilterEnabledProperty.getValue());
- preferences.putStringList(JabRefPreferences.XMP_PRIVACY_FILTERS, xmpFilterListProperty.getValue().stream()
- .map(Field::getName)
- .collect(Collectors.toList()));
+ XmpPreferences newXmpPreferences = new XmpPreferences(
+ xmpFilterEnabledProperty.getValue(),
+ new HashSet<>(xmpFilterListProperty.getValue()),
+ preferences.getKeywordDelimiter());
+ preferences.storeXmpPreferences(newXmpPreferences);
}
public void addField() {
diff --git a/src/main/java/org/jabref/gui/preview/CopyCitationAction.java b/src/main/java/org/jabref/gui/preview/CopyCitationAction.java
index 2ccbae9798e..03d6a353536 100644
--- a/src/main/java/org/jabref/gui/preview/CopyCitationAction.java
+++ b/src/main/java/org/jabref/gui/preview/CopyCitationAction.java
@@ -8,9 +8,9 @@
import javafx.scene.input.ClipboardContent;
-import org.jabref.Globals;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
diff --git a/src/main/java/org/jabref/gui/preview/PreviewPanel.java b/src/main/java/org/jabref/gui/preview/PreviewPanel.java
index e0d5841857c..83a80ae422c 100644
--- a/src/main/java/org/jabref/gui/preview/PreviewPanel.java
+++ b/src/main/java/org/jabref/gui/preview/PreviewPanel.java
@@ -16,8 +16,8 @@
import javafx.scene.input.TransferMode;
import javafx.scene.layout.VBox;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.externalfiles.ExternalFilesEntryLinker;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.icon.IconTheme;
diff --git a/src/main/java/org/jabref/gui/preview/PreviewViewer.java b/src/main/java/org/jabref/gui/preview/PreviewViewer.java
index 79993768b29..7e2fae665cf 100644
--- a/src/main/java/org/jabref/gui/preview/PreviewViewer.java
+++ b/src/main/java/org/jabref/gui/preview/PreviewViewer.java
@@ -15,9 +15,9 @@
import javafx.scene.input.ClipboardContent;
import javafx.scene.web.WebView;
-import org.jabref.Globals;
import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.util.BackgroundTask;
@@ -81,10 +81,10 @@ public class PreviewViewer extends ScrollPane implements InvalidationListener {
private Optional entry = Optional.empty();
private Optional searchHighlightPattern = Optional.empty();
- private BibDatabaseContext database;
+ private final BibDatabaseContext database;
private boolean registered;
- private ChangeListener> listener = (queryObservable, queryOldValue, queryNewValue) -> {
+ private final ChangeListener> listener = (queryObservable, queryOldValue, queryNewValue) -> {
searchHighlightPattern = queryNewValue.flatMap(SearchQuery::getJavaScriptPatternForWords);
highlightSearchPattern();
};
@@ -206,7 +206,7 @@ public void print() {
BackgroundTask
.wrap(() -> {
- job.getJobSettings().setJobName(entry.flatMap(BibEntry::getCiteKeyOptional).orElse("NO ENTRY"));
+ job.getJobSettings().setJobName(entry.flatMap(BibEntry::getCitationKey).orElse("NO ENTRY"));
previewView.getEngine().print(job);
job.endJob();
})
diff --git a/src/main/java/org/jabref/gui/protectedterms/NewProtectedTermsFileDialog.java b/src/main/java/org/jabref/gui/protectedterms/NewProtectedTermsFileDialog.java
index d97e6ccc9fb..2cfbcf1d7eb 100644
--- a/src/main/java/org/jabref/gui/protectedterms/NewProtectedTermsFileDialog.java
+++ b/src/main/java/org/jabref/gui/protectedterms/NewProtectedTermsFileDialog.java
@@ -7,8 +7,8 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
index a8fe0b7c52c..a746231b40b 100644
--- a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
+++ b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
@@ -3,8 +3,8 @@
import java.io.IOException;
import java.util.List;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.OS;
import org.jabref.model.database.BibDatabaseContext;
diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
index 405e631cdae..01c0af0ff82 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java
@@ -4,8 +4,8 @@
import java.util.Objects;
import java.util.Optional;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.Action;
import org.jabref.gui.actions.SimpleCommand;
@@ -73,7 +73,7 @@ private static String getKeyString(List entries) {
Optional citeKey;
boolean first = true;
for (BibEntry bes : entries) {
- citeKey = bes.getCiteKeyOptional();
+ citeKey = bes.getCitationKey();
if (citeKey.isEmpty() || citeKey.get().isEmpty()) {
// Should never occur, because we made sure that all entries have keys
continue;
@@ -93,7 +93,7 @@ public void execute() {
// If required, check that all entries have citation keys defined:
if (application.requiresCitationKeys()) {
for (BibEntry entry : stateManager.getSelectedEntries()) {
- if (StringUtil.isBlank(entry.getCiteKeyOptional())) {
+ if (StringUtil.isBlank(entry.getCitationKey())) {
dialogService.showErrorDialogAndWait(
application.getApplicationName(),
Localization.lang("This operation requires all selected entries to have citation keys defined."));
diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationSettings.java b/src/main/java/org/jabref/gui/push/PushToApplicationSettings.java
index f0a627269ca..42b75acb24d 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplicationSettings.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplicationSettings.java
@@ -8,8 +8,8 @@
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationsManager.java b/src/main/java/org/jabref/gui/push/PushToApplicationsManager.java
index 474f0f36a1a..a275a731f0e 100644
--- a/src/main/java/org/jabref/gui/push/PushToApplicationsManager.java
+++ b/src/main/java/org/jabref/gui/push/PushToApplicationsManager.java
@@ -6,8 +6,8 @@
import javafx.scene.control.ButtonBase;
import javafx.scene.control.MenuItem;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.preferences.PreferencesService;
diff --git a/src/main/java/org/jabref/gui/push/PushToEmacs.java b/src/main/java/org/jabref/gui/push/PushToEmacs.java
index 42527f17c5c..56a6ed848de 100644
--- a/src/main/java/org/jabref/gui/push/PushToEmacs.java
+++ b/src/main/java/org/jabref/gui/push/PushToEmacs.java
@@ -4,9 +4,9 @@
import java.io.InputStream;
import java.util.List;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/PushToEmacsSettings.java b/src/main/java/org/jabref/gui/push/PushToEmacsSettings.java
index 5e3364f1939..88770406a30 100644
--- a/src/main/java/org/jabref/gui/push/PushToEmacsSettings.java
+++ b/src/main/java/org/jabref/gui/push/PushToEmacsSettings.java
@@ -3,8 +3,8 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
diff --git a/src/main/java/org/jabref/gui/push/PushToLyx.java b/src/main/java/org/jabref/gui/push/PushToLyx.java
index 41147023e1e..fe7731d5832 100644
--- a/src/main/java/org/jabref/gui/push/PushToLyx.java
+++ b/src/main/java/org/jabref/gui/push/PushToLyx.java
@@ -6,9 +6,9 @@
import java.io.IOException;
import java.util.List;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/PushToLyxSettings.java b/src/main/java/org/jabref/gui/push/PushToLyxSettings.java
index 70ae6e2132e..d631c0c8500 100644
--- a/src/main/java/org/jabref/gui/push/PushToLyxSettings.java
+++ b/src/main/java/org/jabref/gui/push/PushToLyxSettings.java
@@ -1,7 +1,7 @@
package org.jabref.gui.push;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
diff --git a/src/main/java/org/jabref/gui/push/PushToVim.java b/src/main/java/org/jabref/gui/push/PushToVim.java
index 075945a1e0d..5682fb151dd 100644
--- a/src/main/java/org/jabref/gui/push/PushToVim.java
+++ b/src/main/java/org/jabref/gui/push/PushToVim.java
@@ -4,9 +4,9 @@
import java.io.InputStream;
import java.util.List;
-import org.jabref.Globals;
-import org.jabref.JabRefExecutorService;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
+import org.jabref.gui.JabRefExecutorService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.logic.l10n.Localization;
diff --git a/src/main/java/org/jabref/gui/push/PushToVimSettings.java b/src/main/java/org/jabref/gui/push/PushToVimSettings.java
index fa08f9de83a..a29e8a1154a 100644
--- a/src/main/java/org/jabref/gui/push/PushToVimSettings.java
+++ b/src/main/java/org/jabref/gui/push/PushToVimSettings.java
@@ -3,8 +3,8 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.JabRefPreferences;
diff --git a/src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java b/src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java
index ec233a9a5f7..10a190a0694 100644
--- a/src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java
+++ b/src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java
@@ -4,8 +4,8 @@
import javafx.application.Platform;
-import org.jabref.JabRefGUI;
import org.jabref.cli.ArgumentProcessor;
+import org.jabref.gui.JabRefGUI;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.remote.server.MessageHandler;
diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
index 5eb52ad10f6..6e674d584b4 100644
--- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
+++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
@@ -31,8 +31,8 @@
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
-import org.jabref.Globals;
import org.jabref.gui.ClipBoardManager;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.autocompleter.AppendPersonNamesStrategy;
diff --git a/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java b/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java
index 72bf0e9c129..c3c75e18e2a 100644
--- a/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java
+++ b/src/main/java/org/jabref/gui/shared/PullChangesFromSharedAction.java
@@ -3,7 +3,7 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
-import org.jabref.model.database.shared.DatabaseSynchronizer;
+import org.jabref.logic.shared.DatabaseSynchronizer;
public class PullChangesFromSharedAction extends SimpleCommand {
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
index fefdbbd68f6..df2562ddd5d 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
@@ -18,7 +18,7 @@
import org.jabref.gui.util.ControlHelper;
import org.jabref.gui.util.IconValidationDecorator;
import org.jabref.logic.l10n.Localization;
-import org.jabref.model.database.shared.DBMSType;
+import org.jabref.logic.shared.DBMSType;
import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
index 28ab38de947..845732f020a 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
@@ -19,10 +19,10 @@
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
-import org.jabref.Globals;
import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.exporter.SaveDatabaseAction;
import org.jabref.gui.help.HelpAction;
@@ -32,14 +32,14 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.shared.DBMSConnectionProperties;
import org.jabref.logic.shared.DBMSConnectionPropertiesBuilder;
+import org.jabref.logic.shared.DBMSType;
+import org.jabref.logic.shared.DatabaseLocation;
+import org.jabref.logic.shared.DatabaseNotSupportedException;
import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException;
import org.jabref.logic.shared.prefs.SharedDatabasePreferences;
import org.jabref.logic.shared.security.Password;
import org.jabref.logic.util.StandardFileType;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.database.shared.DBMSType;
-import org.jabref.model.database.shared.DatabaseLocation;
-import org.jabref.model.database.shared.DatabaseNotSupportedException;
import org.jabref.preferences.JabRefPreferences;
import com.tobiasdiez.easybind.EasyBind;
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java
index 41047ab80ec..d80128d9af5 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java
@@ -9,9 +9,9 @@
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
-import org.jabref.Globals;
import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.exporter.SaveDatabaseAction;
@@ -22,6 +22,8 @@
import org.jabref.logic.shared.DBMSConnection;
import org.jabref.logic.shared.DBMSConnectionProperties;
import org.jabref.logic.shared.DBMSSynchronizer;
+import org.jabref.logic.shared.DatabaseNotSupportedException;
+import org.jabref.logic.shared.DatabaseSynchronizer;
import org.jabref.logic.shared.event.ConnectionLostEvent;
import org.jabref.logic.shared.event.SharedEntriesNotPresentEvent;
import org.jabref.logic.shared.event.UpdateRefusedEvent;
@@ -29,8 +31,6 @@
import org.jabref.logic.shared.exception.NotASharedDatabaseException;
import org.jabref.logic.shared.prefs.SharedDatabasePreferences;
import org.jabref.model.database.BibDatabaseContext;
-import org.jabref.model.database.shared.DatabaseNotSupportedException;
-import org.jabref.model.database.shared.DatabaseSynchronizer;
import org.jabref.model.entry.BibEntry;
import com.google.common.eventbus.Subscribe;
diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java
index f7de35a35ae..40f6567342e 100644
--- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java
+++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldAction.java
@@ -3,8 +3,8 @@
import java.util.List;
import java.util.Objects;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
@@ -34,14 +34,13 @@ public class SpecialFieldAction extends SimpleCommand {
/**
* @param nullFieldIfValueIsTheSame - false also causes that doneTextPattern has two place holders %0 for the value and %1 for the sum of entries
*/
- public SpecialFieldAction(
- JabRefFrame frame,
- SpecialField specialField,
- String value,
- boolean nullFieldIfValueIsTheSame,
- String undoText,
- DialogService dialogService,
- StateManager stateManager) {
+ public SpecialFieldAction(JabRefFrame frame,
+ SpecialField specialField,
+ String value,
+ boolean nullFieldIfValueIsTheSame,
+ String undoText,
+ DialogService dialogService,
+ StateManager stateManager) {
this.frame = frame;
this.specialField = specialField;
this.value = value;
@@ -61,9 +60,16 @@ public void execute() {
return;
}
NamedCompound ce = new NamedCompound(undoText);
- for (BibEntry be : bes) {
+ for (BibEntry bibEntry : bes) {
// if (value==null) and then call nullField has been omitted as updatefield also handles value==null
- List changes = SpecialFieldsUtils.updateField(specialField, value, be, nullFieldIfValueIsTheSame, Globals.prefs.isKeywordSyncEnabled(), Globals.prefs.getKeywordDelimiter());
+ List changes = SpecialFieldsUtils.updateField(
+ specialField,
+ value,
+ bibEntry,
+ nullFieldIfValueIsTheSame,
+ Globals.prefs.getSpecialFieldsPreferences().isKeywordSyncEnabled(),
+ Globals.prefs.getKeywordDelimiter());
+
for (FieldChange change : changes) {
ce.addEdit(new UndoableFieldChange(change));
}
@@ -80,10 +86,9 @@ public void execute() {
outText = getTextDone(specialField, value, Integer.toString(bes.size()));
}
dialogService.notify(outText);
- } else {
- // if user does not change anything with his action, we do not do anything either
- // even no output message
}
+
+ // if user does not change anything with his action, we do not do anything either, even no output message
} catch (Throwable ex) {
LOGGER.error("Problem setting special fields", ex);
}
diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java
index 72c51d825bb..a32fe926312 100644
--- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java
+++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldMenuItemFactory.java
@@ -7,8 +7,8 @@
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionFactory;
diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java
index 2565adcfa42..e2d3ffda9a6 100644
--- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java
+++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java
@@ -31,81 +31,44 @@ public String getMenuString() {
}
public String getToolTipText() {
-
- switch (value) {
- case PRINTED:
- return Localization.lang("Toggle print status");
- case CLEAR_PRIORITY:
- return Localization.lang("No priority information");
- case PRIORITY_HIGH:
- return Localization.lang("Priority high");
- case PRIORITY_MEDIUM:
- return Localization.lang("Priority medium");
- case PRIORITY_LOW:
- return Localization.lang("Priority low");
- case QUALITY_ASSURED:
- return Localization.lang("Toggle quality assured");
- case CLEAR_RANK:
- return Localization.lang("No rank information");
- case RANK_1:
- return Localization.lang("One star");
- case RANK_2:
- return Localization.lang("Two stars");
- case RANK_3:
- return Localization.lang("Three stars");
- case RANK_4:
- return Localization.lang("Four stars");
- case RANK_5:
- return Localization.lang("Five stars");
- case CLEAR_READ_STATUS:
- return Localization.lang("No read status information");
- case READ:
- return Localization.lang("Read status read");
- case SKIMMED:
- return Localization.lang("Read status skimmed");
- case RELEVANT:
- return Localization.lang("Toggle relevance");
- default:
- throw new IllegalArgumentException("There is no tooltip localization for special field value " + value);
- }
+ return switch (value) {
+ case PRINTED -> Localization.lang("Toggle print status");
+ case CLEAR_PRIORITY -> Localization.lang("No priority information");
+ case PRIORITY_HIGH -> Localization.lang("Priority high");
+ case PRIORITY_MEDIUM -> Localization.lang("Priority medium");
+ case PRIORITY_LOW -> Localization.lang("Priority low");
+ case QUALITY_ASSURED -> Localization.lang("Toggle quality assured");
+ case CLEAR_RANK -> Localization.lang("No rank information");
+ case RANK_1 -> Localization.lang("One star");
+ case RANK_2 -> Localization.lang("Two stars");
+ case RANK_3 -> Localization.lang("Three stars");
+ case RANK_4 -> Localization.lang("Four stars");
+ case RANK_5 -> Localization.lang("Five stars");
+ case CLEAR_READ_STATUS -> Localization.lang("No read status information");
+ case READ -> Localization.lang("Read status read");
+ case SKIMMED -> Localization.lang("Read status skimmed");
+ case RELEVANT -> Localization.lang("Toggle relevance");
+ };
}
public Action getAction() {
- switch (value) {
- case PRINTED:
- return StandardActions.TOGGLE_PRINTED;
- case CLEAR_PRIORITY:
- return StandardActions.CLEAR_PRIORITY;
- case PRIORITY_HIGH:
- return StandardActions.PRIORITY_HIGH;
- case PRIORITY_MEDIUM:
- return StandardActions.PRIORITY_MEDIUM;
- case PRIORITY_LOW:
- return StandardActions.PRIORITY_LOW;
- case QUALITY_ASSURED:
- return StandardActions.QUALITY_ASSURED;
- case CLEAR_RANK:
- return StandardActions.CLEAR_RANK;
- case RANK_1:
- return StandardActions.RANK_1;
- case RANK_2:
- return StandardActions.RANK_2;
- case RANK_3:
- return StandardActions.RANK_3;
- case RANK_4:
- return StandardActions.RANK_4;
- case RANK_5:
- return StandardActions.RANK_5;
- case CLEAR_READ_STATUS:
- return StandardActions.CLEAR_READ_STATUS;
- case READ:
- return StandardActions.READ;
- case SKIMMED:
- return StandardActions.SKIMMED;
- case RELEVANT:
- return StandardActions.RELEVANT;
- default:
- throw new IllegalArgumentException("There is no action name for special field value " + value);
- }
+ return switch (value) {
+ case PRINTED -> StandardActions.TOGGLE_PRINTED;
+ case CLEAR_PRIORITY -> StandardActions.CLEAR_PRIORITY;
+ case PRIORITY_HIGH -> StandardActions.PRIORITY_HIGH;
+ case PRIORITY_MEDIUM -> StandardActions.PRIORITY_MEDIUM;
+ case PRIORITY_LOW -> StandardActions.PRIORITY_LOW;
+ case QUALITY_ASSURED -> StandardActions.QUALITY_ASSURED;
+ case CLEAR_RANK -> StandardActions.CLEAR_RANK;
+ case RANK_1 -> StandardActions.RANK_1;
+ case RANK_2 -> StandardActions.RANK_2;
+ case RANK_3 -> StandardActions.RANK_3;
+ case RANK_4 -> StandardActions.RANK_4;
+ case RANK_5 -> StandardActions.RANK_5;
+ case CLEAR_READ_STATUS -> StandardActions.CLEAR_READ_STATUS;
+ case READ -> StandardActions.READ;
+ case SKIMMED -> StandardActions.SKIMMED;
+ case RELEVANT -> StandardActions.RELEVANT;
+ };
}
}
diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java
index 3ead9368a00..4a9f6cd4a45 100644
--- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java
+++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldViewModel.java
@@ -6,8 +6,8 @@
import javax.swing.undo.UndoManager;
-import org.jabref.Globals;
import org.jabref.gui.DialogService;
+import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.Action;
@@ -53,22 +53,14 @@ public String getLocalization() {
}
public Action getAction() {
- switch (field) {
- case PRINTED:
- return StandardActions.PRINTED;
- case PRIORITY:
- return StandardActions.PRIORITY;
- case QUALITY:
- return StandardActions.QUALITY;
- case RANKING:
- return StandardActions.RANKING;
- case READ_STATUS:
- return StandardActions.READ_STATUS;
- case RELEVANCE:
- return StandardActions.RELEVANCE;
- default:
- throw new IllegalArgumentException("There is no icon mapping for special field " + field);
- }
+ return switch (field) {
+ case PRINTED -> StandardActions.PRINTED;
+ case PRIORITY -> StandardActions.PRIORITY;
+ case QUALITY -> StandardActions.QUALITY;
+ case RANKING -> StandardActions.RANKING;
+ case READ_STATUS -> StandardActions.READ_STATUS;
+ case RELEVANCE -> StandardActions.RELEVANCE;
+ };
}
public JabRefIcon getEmptyIcon() {
@@ -81,8 +73,15 @@ public List getValues() {
.collect(Collectors.toList());
}
- public void setSpecialFieldValue(BibEntry be, SpecialFieldValue value) {
- List changes = SpecialFieldsUtils.updateField(getField(), value.getFieldValue().orElse(null), be, getField().isSingleValueField(), Globals.prefs.isKeywordSyncEnabled(), Globals.prefs.getKeywordDelimiter());
+ public void setSpecialFieldValue(BibEntry bibEntry, SpecialFieldValue value) {
+ List changes = SpecialFieldsUtils.updateField(
+ getField(),
+ value.getFieldValue().orElse(null),
+ bibEntry,
+ getField().isSingleValueField(),
+ Globals.prefs.getSpecialFieldsPreferences().isKeywordSyncEnabled(),
+ Globals.prefs.getKeywordDelimiter());
+
for (FieldChange change : changes) {
undoManager.addEdit(new UndoableFieldChange(change));
}
diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldsPreferences.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldsPreferences.java
index 54ca0f5f8f2..1480ad68dbf 100644
--- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldsPreferences.java
+++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldsPreferences.java
@@ -14,15 +14,19 @@ public SpecialFieldsPreferences(boolean specialFieldsEnabled, boolean autoSyncSp
this.serializeSpecialFields = serializeSpecialFields;
}
- public boolean getSpecialFieldsEnabled() {
+ public boolean isSpecialFieldsEnabled() {
return specialFieldsEnabled;
}
- public boolean getAutoSyncSpecialFieldsToKeyWords() {
+ public boolean shouldAutoSyncSpecialFieldsToKeyWords() {
return autoSyncSpecialFieldsToKeyWords;
}
- public boolean getSerializeSpecialFields() {
+ public boolean shouldSerializeSpecialFields() {
return serializeSpecialFields;
}
+
+ public boolean isKeywordSyncEnabled() {
+ return specialFieldsEnabled && autoSyncSpecialFieldsToKeyWords;
+ }
}
diff --git a/src/main/java/org/jabref/gui/texparser/ParseLatexResultViewModel.java b/src/main/java/org/jabref/gui/texparser/ParseLatexResultViewModel.java
index c5d6eb5c02a..dd9b2464d01 100644
--- a/src/main/java/org/jabref/gui/texparser/ParseLatexResultViewModel.java
+++ b/src/main/java/org/jabref/gui/texparser/ParseLatexResultViewModel.java
@@ -34,7 +34,7 @@ public ParseLatexResultViewModel(LatexBibEntriesResolverResult resolverResult, B
this.referenceList = FXCollections.observableArrayList();
this.citationList = FXCollections.observableArrayList();
- Set newEntryKeys = resolverResult.getNewEntries().stream().map(entry -> entry.getCiteKeyOptional().orElse("")).collect(Collectors.toSet());
+ Set newEntryKeys = resolverResult.getNewEntries().stream().map(entry -> entry.getCitationKey().orElse("")).collect(Collectors.toSet());
for (Map.Entry> entry : resolverResult.getCitations().asMap().entrySet()) {
String key = entry.getKey();
referenceList.add(new ReferenceViewModel(key, newEntryKeys.contains(key), entry.getValue()));
diff --git a/src/main/java/org/jabref/gui/undo/UndoableChangeType.java b/src/main/java/org/jabref/gui/undo/UndoableChangeType.java
index 23f7cf18faf..05d29f902e8 100644
--- a/src/main/java/org/jabref/gui/undo/UndoableChangeType.java
+++ b/src/main/java/org/jabref/gui/undo/UndoableChangeType.java
@@ -28,7 +28,7 @@ public UndoableChangeType(BibEntry entry, EntryType oldType, EntryType newType)
@Override
public String getPresentationName() {
return Localization.lang("change type of entry %0 from %1 to %2",
- StringUtil.boldHTML(entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))),
+ StringUtil.boldHTML(entry.getCitationKey().orElse(Localization.lang("undefined"))),
StringUtil.boldHTML(oldType.getDisplayName(), Localization.lang("undefined")),
StringUtil.boldHTML(newType.getDisplayName()));
}
diff --git a/src/main/java/org/jabref/gui/undo/UndoableFieldChange.java b/src/main/java/org/jabref/gui/undo/UndoableFieldChange.java
index bff2eac7a3b..efb96c70020 100644
--- a/src/main/java/org/jabref/gui/undo/UndoableFieldChange.java
+++ b/src/main/java/org/jabref/gui/undo/UndoableFieldChange.java
@@ -36,7 +36,7 @@ public UndoableFieldChange(FieldChange change) {
@Override
public String getPresentationName() {
return Localization.lang("change field %0 of entry %1 from %2 to %3", StringUtil.boldHTML(field.getDisplayName()),
- StringUtil.boldHTML(entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))),
+ StringUtil.boldHTML(entry.getCitationKey().orElse(Localization.lang("undefined"))),
StringUtil.boldHTML(oldValue, Localization.lang("undefined")),
StringUtil.boldHTML(newValue, Localization.lang("undefined")));
}
diff --git a/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java b/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java
index 9fc4a6a3b7d..3af516b94c1 100644
--- a/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java
+++ b/src/main/java/org/jabref/gui/undo/UndoableInsertEntries.java
@@ -44,7 +44,7 @@ public String getPresentationName() {
return Localization.lang("paste entries");
} else if (entries.size() == 1) {
return Localization.lang("paste entry %0",
- StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ StringUtil.boldHTML(entries.get(0).getCitationKey().orElse(Localization.lang("undefined"))));
} else {
return null;
}
@@ -53,7 +53,7 @@ public String getPresentationName() {
return Localization.lang("insert entries");
} else if (entries.size() == 1) {
return Localization.lang("insert entry %0",
- StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ StringUtil.boldHTML(entries.get(0).getCitationKey().orElse(Localization.lang("undefined"))));
} else {
return null;
}
diff --git a/src/main/java/org/jabref/gui/undo/UndoableKeyChange.java b/src/main/java/org/jabref/gui/undo/UndoableKeyChange.java
index 9355c9335ab..8b37869d6a8 100644
--- a/src/main/java/org/jabref/gui/undo/UndoableKeyChange.java
+++ b/src/main/java/org/jabref/gui/undo/UndoableKeyChange.java
@@ -36,12 +36,12 @@ public String getPresentationName() {
@Override
public void undo() {
super.undo();
- entry.setCiteKey(oldValue);
+ entry.setCitationKey(oldValue);
}
@Override
public void redo() {
super.redo();
- entry.setCiteKey(newValue);
+ entry.setCitationKey(newValue);
}
}
diff --git a/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java b/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java
index e04f23fa882..65b6ae48331 100644
--- a/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java
+++ b/src/main/java/org/jabref/gui/undo/UndoableRemoveEntries.java
@@ -47,7 +47,7 @@ public String getPresentationName() {
return Localization.lang("cut entries");
} else if (entries.size() == 1) {
return Localization.lang("cut entry %0",
- StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ StringUtil.boldHTML(entries.get(0).getCitationKey().orElse(Localization.lang("undefined"))));
} else {
return null;
}
@@ -56,7 +56,7 @@ public String getPresentationName() {
return Localization.lang("remove entries");
} else if (entries.size() == 1) {
return Localization.lang("remove entry %0",
- StringUtil.boldHTML(entries.get(0).getCiteKeyOptional().orElse(Localization.lang("undefined"))));
+ StringUtil.boldHTML(entries.get(0).getCitationKey().orElse(Localization.lang("undefined"))));
} else {
return null;
}
diff --git a/src/main/java/org/jabref/gui/util/BaseDialog.java b/src/main/java/org/jabref/gui/util/BaseDialog.java
index 1995d34ce7d..ee1aec850a9 100644
--- a/src/main/java/org/jabref/gui/util/BaseDialog.java
+++ b/src/main/java/org/jabref/gui/util/BaseDialog.java
@@ -2,6 +2,7 @@
import java.util.Optional;
+import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
@@ -9,11 +10,13 @@
import javafx.scene.input.KeyCode;
import javafx.stage.Stage;
-import org.jabref.Globals;
+import org.jabref.gui.Globals;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.gui.keyboard.KeyBindingRepository;
+import com.tobiasdiez.easybind.EasyBind;
+
public class BaseDialog extends Dialog implements org.jabref.gui.Dialog {
protected BaseDialog() {
@@ -36,7 +39,10 @@ protected BaseDialog() {
setDialogIcon(IconTheme.getJabRefImageFX());
setResizable(true);
- Globals.prefs.getTheme().installCss(getDialogPane().getScene());
+
+ EasyBind.wrapNullable(dialogPaneProperty())
+ .mapObservable(Node::sceneProperty)
+ .subscribeToValues(scene -> Globals.prefs.getTheme().installCss(scene));
}
private Optional