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..3d5d6ff73f1 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java +++ b/src/main/java/org/jabref/gui/libraryproperties/saving/SavingPropertiesViewModel.java @@ -1,8 +1,6 @@ package org.jabref.gui.libraryproperties.saving; import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; import java.util.Optional; import javafx.beans.property.BooleanProperty; @@ -18,7 +16,6 @@ import org.jabref.model.database.BibDatabaseContext; 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.MetaData; import org.jabref.model.metadata.SaveOrder; import org.jabref.preferences.CleanupPreferences; @@ -65,11 +62,9 @@ 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); + sortableFieldsProperty.addAll(FieldFactory.getAllFieldsSortedWithoutInternalExceptSome()); sortCriteriaProperty.clear(); sortCriteriaProperty.addAll(exportSaveOrder.getSortCriteria().stream() .map(SortCriterionViewModel::new) 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..0546284f10e 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,6 @@ package org.jabref.gui.preferences.export; import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; import javafx.beans.property.BooleanProperty; import javafx.beans.property.ListProperty; @@ -44,9 +42,7 @@ public void setValues() { .map(SortCriterionViewModel::new) .toList()); - List fieldNames = new ArrayList<>(FieldFactory.getCommonFields()); - fieldNames.sort(Comparator.comparing(Field::getDisplayName)); - sortableFieldsProperty.addAll(fieldNames); + sortableFieldsProperty.addAll(FieldFactory.getAllFieldsSortedWithoutInternalExceptSome()); } @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..05f3aeb1eb5 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,24 @@ public static Set getCommonFields() { return publicAndInternalFields; } + /** + * Returns a sorted Set of Fields (by {@link Field#getDisplayName} with all fields without internal ones, except {@link InternalField#TYPE_HEADER} and {@link InternalField#KEY_FIELD} as they are useful for sorting + */ + public static Set getAllFieldsSortedWithoutInternalExceptSome() { + Set fields = new TreeSet<>(Comparator.comparing(Field::getDisplayName)); + + fields.addAll(EnumSet.allOf(StandardField.class)); + fields.addAll(EnumSet.allOf(SpecialField.class)); + fields.addAll(EnumSet.allOf(IEEEField.class)); + fields.addAll(EnumSet.allOf(BiblatexApaField.class)); + fields.addAll(EnumSet.allOf(BiblatexSoftwareField.class)); + fields.removeIf(field -> field instanceof UserSpecificCommentField); + fields.add(InternalField.KEY_FIELD); + fields.add(InternalField.TYPE_HEADER); + + return fields; + } + /** * Returns a List with all standard fields and the citation key field */