diff --git a/CHANGELOG.md b/CHANGELOG.md
index 78a2f4163bf..1ae087d571c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where it was no longer possible to connect to LibreOffice. [#5261](https://github.com/JabRef/jabref/issues/5261)
- The "All entries group" is no longer shown when no library is open.
- We fixed an exception which occurred when closing JabRef. [#5348](https://github.com/JabRef/jabref/issues/5348)
+- We fixed an issue where JabRef reports incorrectly about customized entry types. [#5332](https://github.com/JabRef/jabref/issues/5332)
- We fixed a few problems that prevented JabFox to communicate with JabRef. [#4737](https://github.com/JabRef/jabref/issues/4737) [#4303](https://github.com/JabRef/jabref/issues/4303)
- We fixed an error where the groups containing an entry loose their highlight color when scrolling. [#5022](https://github.com/JabRef/jabref/issues/5022)
- We fixed an error where scrollbars were not shown. [#5374](https://github.com/JabRef/jabref/issues/5374)
diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java
index 72051540247..7b4a6a15368 100644
--- a/src/main/java/org/jabref/JabRefMain.java
+++ b/src/main/java/org/jabref/JabRefMain.java
@@ -85,13 +85,13 @@ public void start(Stage mainStage) throws Exception {
Platform.exit();
}
}
-
+
@Override
public void stop() {
Globals.stopBackgroundTasks();
Globals.shutdownThreadPools();
}
-
+
/**
* Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported.
* This test uses the requirements for the Java version as specified in gradle.build
. It is possible to
@@ -166,7 +166,7 @@ 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.entryTypesManager.addCustomizedEntryTypes(preferences.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
+ Globals.entryTypesManager.addCustomOrModifiedTypes(preferences.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
preferences.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader);
diff --git a/src/main/java/org/jabref/cli/ArgumentProcessor.java b/src/main/java/org/jabref/cli/ArgumentProcessor.java
index 252d8f8344e..bfe62a61579 100644
--- a/src/main/java/org/jabref/cli/ArgumentProcessor.java
+++ b/src/main/java/org/jabref/cli/ArgumentProcessor.java
@@ -458,7 +458,7 @@ private void exportFile(List loaded, String[] data) {
private void importPreferences() {
try {
Globals.prefs.importPreferences(cli.getPreferencesImport());
- Globals.entryTypesManager.addCustomizedEntryTypes(Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
+ Globals.entryTypesManager.addCustomOrModifiedTypes(Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBTEX),
Globals.prefs.loadBibEntryTypes(BibDatabaseMode.BIBLATEX));
List customExporters = Globals.prefs.getCustomExportFormats(Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs
diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.fxml b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.fxml
index ad1606546b8..791543daf23 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.fxml
+++ b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.fxml
@@ -9,7 +9,7 @@
xmlns="http://javafx.com/javafx/8.0.171"
fx:controller="org.jabref.gui.importer.ImportCustomEntryTypesDialog">
-
+
diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.java b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.java
index cc1aa40cab6..e61fa7910d0 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialog.java
@@ -45,13 +45,13 @@ public ImportCustomEntryTypesDialog(BibDatabaseMode mode, List cus
});
setTitle(Localization.lang("Custom entry types"));
-
}
@FXML
public void initialize() {
viewModel = new ImportCustomEntryTypesDialogViewModel(mode, customEntryTypes, preferencesService);
+ boxDifferentCustomization.visibleProperty().bind(Bindings.isNotEmpty(viewModel.differentCustomizations()));
boxDifferentCustomization.managedProperty().bind(Bindings.isNotEmpty(viewModel.differentCustomizations()));
unknownEntryTypesCheckList.setItems(viewModel.newTypes());
differentCustomizationCheckList.setItems(viewModel.differentCustomizations());
diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
index 7504ded4cf2..2695361c9d0 100644
--- a/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/importer/ImportCustomEntryTypesDialogViewModel.java
@@ -26,7 +26,7 @@ public ImportCustomEntryTypesDialogViewModel(BibDatabaseMode mode, List currentlyStoredType = Globals.entryTypesManager.enrich(customType.getType(), mode);
- if (!currentlyStoredType.isPresent()) {
+ if (currentlyStoredType.isEmpty()) {
newTypes.add(customType);
} else {
if (!EntryTypeFactory.isEqualNameAndFieldBased(customType, currentlyStoredType.get())) {
@@ -47,11 +47,11 @@ public ObservableList differentCustomizations() {
public void importBibEntryTypes(List checkedUnknownEntryTypes, List checkedDifferentEntryTypes) {
if (!checkedUnknownEntryTypes.isEmpty()) {
- checkedUnknownEntryTypes.forEach(type -> Globals.entryTypesManager.addCustomizedEntryType(type, mode));
+ checkedUnknownEntryTypes.forEach(type -> Globals.entryTypesManager.addCustomOrModifiedType(type, mode));
preferencesService.saveCustomEntryTypes();
}
if (!checkedDifferentEntryTypes.isEmpty()) {
- checkedUnknownEntryTypes.forEach(type -> Globals.entryTypesManager.addCustomizedEntryType(type, mode));
+ checkedUnknownEntryTypes.forEach(type -> Globals.entryTypesManager.addCustomOrModifiedType(type, mode));
preferencesService.saveCustomEntryTypes();
}
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 d65d23d34c3..867e2b8565b 100644
--- a/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java
+++ b/src/main/java/org/jabref/gui/importer/actions/CheckForNewEntryTypesAction.java
@@ -27,7 +27,6 @@ public void performAction(BasePanel panel, ParserResult parserResult) {
ImportCustomEntryTypesDialog importBibEntryTypesDialog = new ImportCustomEntryTypesDialog(mode, getListOfUnknownAndUnequalCustomizations(parserResult));
importBibEntryTypesDialog.showAndWait();
-
}
private List getListOfUnknownAndUnequalCustomizations(ParserResult parserResult) {
@@ -35,7 +34,7 @@ private List getListOfUnknownAndUnequalCustomizations(ParserResult
return parserResult.getEntryTypes()
.stream()
- .filter(type -> Globals.entryTypesManager.isCustomizedType(type, mode))
+ .filter(type -> Globals.entryTypesManager.isDifferentCustomOrModifiedType(type, mode))
.collect(Collectors.toList());
}
diff --git a/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java b/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java
index 350c822510c..57d4b1de9e1 100644
--- a/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java
+++ b/src/main/java/org/jabref/migrations/CustomEntryTypePreferenceMigration.java
@@ -32,7 +32,7 @@ static void upgradeStoredBibEntryTypes(BibDatabaseMode defaultBibDatabaseMode) {
int number = 0;
Optional type;
while ((type = getBibEntryType(number)).isPresent()) {
- Globals.entryTypesManager.addCustomizedEntryType(type.get(), defaultBibDatabaseMode);
+ Globals.entryTypesManager.addCustomOrModifiedType(type.get(), defaultBibDatabaseMode);
storedOldTypes.add(type.get());
number++;
}
diff --git a/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java b/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java
index ab4a5192288..f278b8d5a50 100644
--- a/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java
+++ b/src/main/java/org/jabref/model/entry/BibEntryTypesManager.java
@@ -71,16 +71,16 @@ public static String serialize(BibEntryType entryType) {
/**
* Returns true if the type is a custom type, or if it is a standard type which has customized fields
*/
- public boolean isCustomizedType(BibEntryType type, BibDatabaseMode mode) {
- return mode == BibDatabaseMode.BIBLATEX ? BIBLATEX.isCustomizedType(type) : BIBTEX.isCustomizedType(type);
+ public boolean isCustomOrModifiedType(BibEntryType type, BibDatabaseMode mode) {
+ return mode == BibDatabaseMode.BIBLATEX ? BIBLATEX.isCustomOrModifiedType(type) : BIBTEX.isCustomOrModifiedType(type);
}
/**
* Sets the given custom entry types for BibTeX and biblatex mode
*/
- public void addCustomizedEntryTypes(List customBibtexEntryTypes, List customBiblatexEntryTypes) {
- customBibtexEntryTypes.forEach(type -> addCustomizedEntryType(type, BibDatabaseMode.BIBTEX));
- customBiblatexEntryTypes.forEach(type -> addCustomizedEntryType(type, BibDatabaseMode.BIBLATEX));
+ public void addCustomOrModifiedTypes(List customizedBibtexEntryTypes, List customizedBiblatexEntryTypes) {
+ customizedBibtexEntryTypes.forEach(type -> addCustomOrModifiedType(type, BibDatabaseMode.BIBTEX));
+ customizedBiblatexEntryTypes.forEach(type -> addCustomOrModifiedType(type, BibDatabaseMode.BIBLATEX));
}
/**
@@ -104,11 +104,11 @@ public List getAllCustomTypes(BibDatabaseMode mode) {
}
}
- public void addCustomizedEntryType(BibEntryType entryType, BibDatabaseMode mode) {
+ public void addCustomOrModifiedType(BibEntryType entryType, BibDatabaseMode mode) {
if (BibDatabaseMode.BIBLATEX == mode) {
- BIBLATEX.addCustomizedType(entryType);
+ BIBLATEX.addCustomOrModifiedType(entryType);
} else if (BibDatabaseMode.BIBTEX == mode) {
- BIBTEX.addCustomizedType(entryType);
+ BIBTEX.addCustomOrModifiedType(entryType);
}
}
@@ -127,11 +127,22 @@ public Optional enrich(EntryType type, BibDatabaseMode mode) {
return mode == BibDatabaseMode.BIBLATEX ? BIBLATEX.enrich(type) : BIBTEX.enrich(type);
}
+ public boolean isDifferentCustomOrModifiedType(BibEntryType type, BibDatabaseMode mode) {
+ Optional currentlyStoredType = enrich(type.getType(), mode);
+ if (currentlyStoredType.isEmpty()) {
+ // new customization
+ return true;
+ } else {
+ // different customization
+ return !EntryTypeFactory.isEqualNameAndFieldBased(type, currentlyStoredType.get());
+ }
+ }
+
/**
* This class is used to specify entry types for either BIBTEX and BIBLATEX.
*/
static class InternalEntryTypes {
- private final SortedSet customizedTypes = new TreeSet<>();
+ private final SortedSet customOrModifiedType = new TreeSet<>();
private final SortedSet standardTypes;
public InternalEntryTypes(List standardTypes) {
@@ -143,9 +154,9 @@ public InternalEntryTypes(List standardTypes) {
* or null if it does not exist.
*/
public Optional enrich(EntryType type) {
- Optional enrichedType = customizedTypes.stream()
- .filter(customizedType -> customizedType.getType().equals(type))
- .findFirst();
+ Optional enrichedType = customOrModifiedType.stream()
+ .filter(customizedType -> customizedType.getType().equals(type))
+ .findFirst();
if (enrichedType.isPresent()) {
return enrichedType;
} else {
@@ -155,19 +166,20 @@ public Optional enrich(EntryType type) {
}
}
- private void addCustomizedType(BibEntryType type) {
- customizedTypes.remove(type);
- customizedTypes.add(type);
+ private void addCustomOrModifiedType(BibEntryType type) {
+ customOrModifiedType.remove(type);
+ customOrModifiedType.add(type);
}
public SortedSet getAllTypes() {
- SortedSet allTypes = new TreeSet<>(customizedTypes);
+ SortedSet allTypes = new TreeSet<>(customOrModifiedType);
allTypes.addAll(standardTypes);
return allTypes;
}
- public boolean isCustomizedType(BibEntryType entryType) {
- return customizedTypes.stream().anyMatch(customizedType -> customizedType.getType().equals(entryType.getType()));
+ public boolean isCustomOrModifiedType(BibEntryType entryType) {
+ return customOrModifiedType.stream()
+ .anyMatch(customizedType -> customizedType.getType().equals(entryType.getType()));
}
}
}
diff --git a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
index 610ae01fe2d..876995c42ef 100644
--- a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
+++ b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java
@@ -273,7 +273,7 @@ void writeEntryWithCustomizedTypeAlsoWritesTypeDeclaration() throws Exception {
new OrFields(StandardField.TITLE),
new OrFields(StandardField.AUTHOR),
new OrFields(StandardField.DATE)));
- entryTypesManager.addCustomizedEntryType(customizedBibType, BibDatabaseMode.BIBTEX);
+ entryTypesManager.addCustomOrModifiedType(customizedBibType, BibDatabaseMode.BIBTEX);
BibEntry entry = new BibEntry(customizedType);
database.insertEntry(entry);
diff --git a/src/test/java/org/jabref/model/BibEntryTypeFactoryTest.java b/src/test/java/org/jabref/model/entry/BibEntryTypesManagerTest.java
similarity index 81%
rename from src/test/java/org/jabref/model/BibEntryTypeFactoryTest.java
rename to src/test/java/org/jabref/model/entry/BibEntryTypesManagerTest.java
index 9cfd2533521..6d0af169818 100644
--- a/src/test/java/org/jabref/model/BibEntryTypeFactoryTest.java
+++ b/src/test/java/org/jabref/model/entry/BibEntryTypesManagerTest.java
@@ -1,4 +1,4 @@
-package org.jabref.model;
+package org.jabref.model.entry;
import java.util.Collections;
import java.util.Optional;
@@ -6,8 +6,6 @@
import java.util.stream.Stream;
import org.jabref.model.database.BibDatabaseMode;
-import org.jabref.model.entry.BibEntryType;
-import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.BibField;
import org.jabref.model.entry.field.FieldPriority;
import org.jabref.model.entry.field.StandardField;
@@ -25,8 +23,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-class BibEntryTypeFactoryTest {
+class BibEntryTypesManagerTest {
private static final EntryType UNKNOWN_TYPE = new UnknownEntryType("unknownType");
private static final EntryType CUSTOM_TYPE = new UnknownEntryType("customType");
@@ -51,6 +50,13 @@ void setUp() {
entryTypesManager = new BibEntryTypesManager();
}
+ @ParameterizedTest
+ @MethodSource("mode")
+ void isCustomOrModifiedTypeReturnsTrueForModifiedStandardEntryType(BibDatabaseMode mode) {
+ entryTypesManager.addCustomOrModifiedType(overwrittenStandardType, mode);
+ assertTrue(entryTypesManager.isCustomOrModifiedType(overwrittenStandardType, mode));
+ }
+
@Test
void allTypesBibtexAreCorrect() {
TreeSet defaultTypes = new TreeSet<>(BibtexEntryTypeDefinitions.ALL);
@@ -75,53 +81,53 @@ void unknownTypeIsNotFound(BibDatabaseMode mode) {
@ParameterizedTest
@MethodSource("mode")
void newCustomEntryTypeFound(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(newCustomType, mode);
+ entryTypesManager.addCustomOrModifiedType(newCustomType, mode);
assertEquals(Optional.of(newCustomType), entryTypesManager.enrich(CUSTOM_TYPE, mode));
}
@ParameterizedTest
@MethodSource("mode")
void registeredBibEntryTypeIsContainedInListOfCustomizedEntryTypes(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(newCustomType, mode);
+ entryTypesManager.addCustomOrModifiedType(newCustomType, mode);
assertEquals(Collections.singletonList(newCustomType), entryTypesManager.getAllCustomTypes(mode));
}
@Test
void registerBibEntryTypeDoesNotAffectOtherMode() {
- entryTypesManager.addCustomizedEntryType(newCustomType, BibDatabaseMode.BIBTEX);
+ entryTypesManager.addCustomOrModifiedType(newCustomType, BibDatabaseMode.BIBTEX);
assertFalse(entryTypesManager.getAllTypes(BibDatabaseMode.BIBLATEX).contains(newCustomType));
}
@ParameterizedTest
@MethodSource("mode")
void overwriteBibEntryTypeFields(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(newCustomType, mode);
+ entryTypesManager.addCustomOrModifiedType(newCustomType, mode);
BibEntryType newBibEntryTypeTitle = new BibEntryType(
CUSTOM_TYPE,
Collections.singleton(new BibField(StandardField.TITLE, FieldPriority.IMPORTANT)),
Collections.emptySet());
- entryTypesManager.addCustomizedEntryType(newBibEntryTypeTitle, mode);
+ entryTypesManager.addCustomOrModifiedType(newBibEntryTypeTitle, mode);
assertEquals(Optional.of(newBibEntryTypeTitle), entryTypesManager.enrich(CUSTOM_TYPE, mode));
}
@ParameterizedTest
@MethodSource("mode")
void overwriteStandardTypeRequiredFields(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(overwrittenStandardType, mode);
+ entryTypesManager.addCustomOrModifiedType(overwrittenStandardType, mode);
assertEquals(Optional.of(overwrittenStandardType), entryTypesManager.enrich(overwrittenStandardType.getType(), mode));
}
@ParameterizedTest
@MethodSource("mode")
void registeredCustomizedStandardEntryTypeIsNotContainedInListOfCustomEntryTypes(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(overwrittenStandardType, mode);
+ entryTypesManager.addCustomOrModifiedType(overwrittenStandardType, mode);
assertEquals(Collections.emptyList(), entryTypesManager.getAllCustomTypes(mode));
}
@ParameterizedTest
@MethodSource("mode")
void standardTypeIsStillAccessibleIfOverwritten(BibDatabaseMode mode) {
- entryTypesManager.addCustomizedEntryType(overwrittenStandardType, mode);
+ entryTypesManager.addCustomOrModifiedType(overwrittenStandardType, mode);
assertFalse(entryTypesManager.isCustomType(overwrittenStandardType.getType(), mode));
}
}