Skip to content

Commit

Permalink
Nice UI defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Aug 28, 2023
1 parent 297b366 commit 587b40a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.libraryproperties.saving;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;

Expand All @@ -18,13 +19,22 @@
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.entry.field.StandardField;
import org.jabref.model.metadata.MetaData;
import org.jabref.model.metadata.SaveOrder;
import org.jabref.preferences.CleanupPreferences;
import org.jabref.preferences.PreferencesService;

public class SavingPropertiesViewModel implements PropertiesTabViewModel {

private static final SaveOrder UI_DEFAULT_SAVE_ORDER = new SaveOrder(SaveOrder.OrderType.ORIGINAL, List.of(
new SaveOrder.SortCriterion(StandardField.AUTHOR),
new SaveOrder.SortCriterion(StandardField.YEAR),
new SaveOrder.SortCriterion(StandardField.TITLE),
// Pro users generate their citation keys well. They can just delete the above three proposals and get a well-sorted library.
new SaveOrder.SortCriterion(InternalField.KEY_FIELD)
));

private final BooleanProperty protectDisableProperty = new SimpleBooleanProperty();
private final BooleanProperty libraryProtectedProperty = new SimpleBooleanProperty();

Expand All @@ -48,7 +58,7 @@ public SavingPropertiesViewModel(BibDatabaseContext databaseContext, Preferences
this.databaseContext = databaseContext;
this.preferencesService = preferencesService;
this.initialMetaData = databaseContext.getMetaData();
this.saveOrder = initialMetaData.getSaveOrder().orElse(SaveOrder.getDefaultSaveOrder());
this.saveOrder = initialMetaData.getSaveOrder().orElse(UI_DEFAULT_SAVE_ORDER);
}

@Override
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/jabref/model/metadata/SaveOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ public static class SortCriterion {
public final boolean descending;

/**
*
* Given field sorted ascending
*/
public SortCriterion(Field field) {
this(field, false);
}

/**
* @param field The field
* @param descending Must be a boolean value as string, e.g. "true", "false"
*/
Expand Down

0 comments on commit 587b40a

Please sign in to comment.