Skip to content

Commit

Permalink
Show more fields for save sort order and export sort order
Browse files Browse the repository at this point in the history
Fixes #10010
  • Loading branch information
Siedlerchr committed Jun 16, 2023
1 parent 710e1f2 commit ae4e0e4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -65,11 +62,9 @@ public void setValues() {
case TABLE -> saveInTableOrderProperty.setValue(true);
}

List<Field> 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -44,9 +42,7 @@ public void setValues() {
.map(SortCriterionViewModel::new)
.toList());

List<Field> fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
fieldNames.sort(Comparator.comparing(Field::getDisplayName));
sortableFieldsProperty.addAll(fieldNames);
sortableFieldsProperty.addAll(FieldFactory.getAllFieldsSortedWithoutInternalExceptSome());
}

@Override
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/org/jabref/model/entry/field/FieldFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -133,7 +135,7 @@ public static Set<Field> 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<Field> getCommonFields() {
EnumSet<StandardField> allFields = EnumSet.allOf(StandardField.class);
Expand All @@ -147,6 +149,24 @@ public static Set<Field> 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<Field> getAllFieldsSortedWithoutInternalExceptSome() {
Set<Field> 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
*/
Expand Down

0 comments on commit ae4e0e4

Please sign in to comment.