diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f35b7daa8..84c71fc3902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - The formatter `remove_unicode_ligatures` is now called `replace_unicode_ligatures`. [#9890](https://github.com/JabRef/jabref/pull/9890) - We improved the error message when no terminal was found [#9607](https://github.com/JabRef/jabref/issues/9607) - In the context of the "systematic literature functionality", we changed the name "database" to "catalog" to use a separate term for online catalogs in comparison to SQL databases. [#9951](https://github.com/JabRef/jabref/pull/9951) +- We now show more fields (including Special Fields) in the dropdown selection for "Save sort order" in the library properties and for "Export sort order" in the preferences. [#10010](https://github.com/JabRef/jabref/issues/10010) ### Fixed diff --git a/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java index 3216e60e2ed..15955183f52 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java +++ b/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java @@ -1,9 +1,8 @@ package org.jabref.gui.libraryproperties.saving; import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; import java.util.Optional; +import java.util.Set; import javafx.beans.property.BooleanProperty; import javafx.beans.property.ListProperty; @@ -65,11 +64,15 @@ public void setValues() { case TABLE -> saveInTableOrderProperty.setValue(true); } - List fieldNames = new ArrayList<>(FieldFactory.getCommonFields()); - fieldNames.add(InternalField.TYPE_HEADER); // allow entrytype field as sort criterion - fieldNames.sort(Comparator.comparing(Field::getDisplayName)); sortableFieldsProperty.clear(); - sortableFieldsProperty.addAll(fieldNames); + + Set fields = FieldFactory.getAllFieldsWithOutInternal(); + fields.add(InternalField.INTERNAL_ALL_FIELD); + fields.add(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD); + fields.add(InternalField.KEY_FIELD); + fields.add(InternalField.TYPE_HEADER); + + sortableFieldsProperty.addAll(FieldFactory.getStandardFieldsWithCitationKey()); sortCriteriaProperty.clear(); sortCriteriaProperty.addAll(exportSaveOrder.getSortCriteria().stream() .map(SortCriterionViewModel::new) diff --git a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java index 3e63facf759..08cd62c0ec4 100644 --- a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java @@ -76,10 +76,11 @@ public CustomEntryTypesTabViewModel(BibDatabaseMode mode, ValidationMessage.error(Localization.lang("Entry type cannot be empty. Please enter a name."))); fieldValidator = new FunctionBasedValidator<>( newFieldToAdd, - input -> input != null && StringUtil.isNotBlank(input.getDisplayName()), + input -> (input != null) && StringUtil.isNotBlank(input.getDisplayName()), ValidationMessage.error(Localization.lang("Field cannot be empty. Please enter a name."))); } + @Override public void setValues() { if (!this.entryTypesWithFields.isEmpty()) { this.entryTypesWithFields.clear(); @@ -97,6 +98,7 @@ public void setValues() { } } + @Override public void storeSettings() { Set multilineFields = new HashSet<>(); for (EntryTypeViewModel typeViewModel : entryTypesWithFields) { diff --git a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java index 8b2ef12e7ef..f8b278b9708 100644 --- a/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/export/ExportTabViewModel.java @@ -1,8 +1,7 @@ package org.jabref.gui.preferences.export; import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; +import java.util.Set; import javafx.beans.property.BooleanProperty; import javafx.beans.property.ListProperty; @@ -14,6 +13,7 @@ import org.jabref.gui.preferences.PreferenceTabViewModel; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; +import org.jabref.model.entry.field.InternalField; import org.jabref.model.metadata.SaveOrder; import org.jabref.preferences.ExportPreferences; @@ -44,9 +44,12 @@ public void setValues() { .map(SortCriterionViewModel::new) .toList()); - List fieldNames = new ArrayList<>(FieldFactory.getCommonFields()); - fieldNames.sort(Comparator.comparing(Field::getDisplayName)); - sortableFieldsProperty.addAll(fieldNames); + Set fields = FieldFactory.getAllFieldsWithOutInternal(); + fields.add(InternalField.INTERNAL_ALL_FIELD); + fields.add(InternalField.INTERNAL_ALL_TEXT_FIELDS_FIELD); + fields.add(InternalField.KEY_FIELD); + fields.add(InternalField.TYPE_HEADER); + sortableFieldsProperty.addAll(FieldFactory.getStandardFieldsWithCitationKey()); } @Override diff --git a/src/main/java/org/jabref/model/entry/field/FieldFactory.java b/src/main/java/org/jabref/model/entry/field/FieldFactory.java index 0316114b2aa..cac6bb3b2c7 100644 --- a/src/main/java/org/jabref/model/entry/field/FieldFactory.java +++ b/src/main/java/org/jabref/model/entry/field/FieldFactory.java @@ -3,11 +3,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.EnumSet; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -133,7 +135,7 @@ public static Set getJournalNameFields() { } /** - * Returns a List with all standard fields and including some common internal fields + * Returns a Set with all standard fields and including some common internal fields */ public static Set getCommonFields() { EnumSet allFields = EnumSet.allOf(StandardField.class); @@ -147,6 +149,17 @@ public static Set getCommonFields() { return publicAndInternalFields; } + /** + * Returns a sorted Set of Fields (by {@link Field#getDisplayName} with all fields without internal ones + */ + public static Set getAllFieldsWithOutInternal() { + Set fields = new TreeSet<>(Comparator.comparing(Field::getDisplayName)); + fields.addAll(getAllFields()); + fields.removeAll(EnumSet.allOf(InternalField.class)); + + return fields; + } + /** * Returns a List with all standard fields and the citation key field */