Skip to content

Commit

Permalink
fix: make more fields, fomatters, ids and languages sorted by alphabe…
Browse files Browse the repository at this point in the history
…tical order (#7717)
  • Loading branch information
dateri authored May 10, 2021
1 parent 2bbb35a commit ab74598
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FieldFormatterCleanupsPanelViewModel {
private final ObjectProperty<SelectionModel<FieldFormatterCleanup>> selectedCleanupProperty = new SimpleObjectProperty<>(new NoSelectionModel<>());
private final ListProperty<Field> availableFieldsProperty = new SimpleListProperty<>(new SortedList<>(FXCollections.observableArrayList(FieldFactory.getCommonFields()), Comparator.comparing(Field::getDisplayName)));
private final ObjectProperty<Field> selectedFieldProperty = new SimpleObjectProperty<>();
private final ListProperty<Formatter> availableFormattersProperty = new SimpleListProperty<>(FXCollections.observableArrayList(Cleanups.getBuiltInFormatters()));
private final ListProperty<Formatter> availableFormattersProperty = new SimpleListProperty<>(new SortedList<>(FXCollections.observableArrayList(Cleanups.getBuiltInFormatters()), Comparator.comparing(Formatter::getName)));
private final ObjectProperty<Formatter> selectedFormatterProperty = new SimpleObjectProperty<>();

public FieldFormatterCleanupsPanelViewModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.nio.charset.Charset;
import java.nio.file.Path;
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;
Expand Down Expand Up @@ -106,9 +108,10 @@ void setValues() {
saveInTableOrderProperty.setValue(true);
}

Set<Field> fieldNames = FieldFactory.getCommonFields();
List<Field> fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
// allow entrytype field as sort criterion
fieldNames.add(InternalField.TYPE_HEADER);
fieldNames.sort(Comparator.comparing(Field::getDisplayName));
primarySortFieldsProperty.addAll(fieldNames);
secondarySortFieldsProperty.addAll(fieldNames);
tertiarySortFieldsProperty.addAll(fieldNames);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jabref.gui.preferences.file;

import java.util.Set;
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 @@ -79,7 +81,8 @@ public void setValues() {
saveInTableOrderProperty.setValue(true);
}

Set<Field> fieldNames = FieldFactory.getCommonFields();
List<Field> fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
fieldNames.sort(Comparator.comparing(Field::getDisplayName));
primarySortFieldsProperty.addAll(fieldNames);
secondarySortFieldsProperty.addAll(fieldNames);
tertiarySortFieldsProperty.addAll(fieldNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import javafx.beans.property.BooleanProperty;
Expand All @@ -13,6 +14,7 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.transformation.SortedList;

import org.jabref.gui.DialogService;
import org.jabref.gui.preferences.PreferenceTabViewModel;
Expand Down Expand Up @@ -66,7 +68,7 @@ public GeneralTabViewModel(DialogService dialogService, PreferencesService prefe
}

public void setValues() {
languagesListProperty.setValue(FXCollections.observableArrayList(Language.values()));
languagesListProperty.setValue(new SortedList<>(FXCollections.observableArrayList(Language.values()), Comparator.comparing(Language::getDisplayName)));
selectedLanguageProperty.setValue(preferencesService.getLanguage());

encodingsListProperty.setValue(FXCollections.observableArrayList(Encodings.getCharsets()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.preferences.xmp;

import java.util.Comparator;
import java.util.HashSet;

import javafx.beans.property.BooleanProperty;
Expand Down Expand Up @@ -59,6 +60,7 @@ public void setValues() {

availableFieldsProperty.clear();
availableFieldsProperty.addAll(FieldFactory.getCommonFields());
availableFieldsProperty.sort((Comparator.comparing(Field::getDisplayName)));
}

@Override
Expand Down

0 comments on commit ab74598

Please sign in to comment.