-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag-Based Selection for Entry fields in Preferences #12592
base: main
Are you sure you want to change the base?
Changes from all commits
f9744d8
439988c
c8b9cf8
af00b52
076e6f5
366e163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,25 +1,30 @@ | ||||||
package org.jabref.gui.preferences.entry; | ||||||
|
||||||
import javafx.beans.property.BooleanProperty; | ||||||
import javafx.beans.property.ListProperty; | ||||||
import javafx.beans.property.SimpleBooleanProperty; | ||||||
import javafx.beans.property.SimpleListProperty; | ||||||
import javafx.beans.property.SimpleStringProperty; | ||||||
import javafx.beans.property.StringProperty; | ||||||
import javafx.collections.FXCollections; | ||||||
import javafx.util.StringConverter; | ||||||
|
||||||
import org.jabref.gui.preferences.PreferenceTabViewModel; | ||||||
import org.jabref.logic.bibtex.FieldPreferences; | ||||||
import org.jabref.logic.preferences.CliPreferences; | ||||||
import org.jabref.logic.preferences.OwnerPreferences; | ||||||
import org.jabref.logic.preferences.TimestampPreferences; | ||||||
import org.jabref.model.entry.BibEntryPreferences; | ||||||
import org.jabref.model.entry.field.Field; | ||||||
import org.jabref.model.entry.field.FieldFactory; | ||||||
|
||||||
public class EntryTabViewModel implements PreferenceTabViewModel { | ||||||
|
||||||
private final StringProperty keywordSeparatorProperty = new SimpleStringProperty(""); | ||||||
|
||||||
private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty(); | ||||||
private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty(""); | ||||||
private final StringProperty nonWrappableFieldsProperty = new SimpleStringProperty(""); | ||||||
private final ListProperty<Field> resolveStringsForFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); | ||||||
private final ListProperty<Field> nonWrappableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList()); | ||||||
|
||||||
private final BooleanProperty markOwnerProperty = new SimpleBooleanProperty(); | ||||||
private final StringProperty markOwnerNameProperty = new SimpleStringProperty(""); | ||||||
|
@@ -42,10 +47,9 @@ public EntryTabViewModel(CliPreferences preferences) { | |||||
@Override | ||||||
public void setValues() { | ||||||
keywordSeparatorProperty.setValue(bibEntryPreferences.getKeywordSeparator().toString()); | ||||||
|
||||||
resolveStringsProperty.setValue(fieldPreferences.shouldResolveStrings()); | ||||||
resolveStringsForFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getResolvableFields())); | ||||||
nonWrappableFieldsProperty.setValue(FieldFactory.serializeFieldsList(fieldPreferences.getNonWrappableFields())); | ||||||
resolveStringsForFieldsProperty.setValue(FXCollections.observableArrayList(fieldPreferences.getResolvableFields())); | ||||||
nonWrappableFieldsProperty.setValue(FXCollections.observableArrayList(fieldPreferences.getNonWrappableFields())); | ||||||
|
||||||
markOwnerProperty.setValue(ownerPreferences.isUseOwner()); | ||||||
markOwnerNameProperty.setValue(ownerPreferences.getDefaultOwner()); | ||||||
|
@@ -58,17 +62,16 @@ public void setValues() { | |||||
@Override | ||||||
public void storeSettings() { | ||||||
bibEntryPreferences.keywordSeparatorProperty().setValue(keywordSeparatorProperty.getValue().charAt(0)); | ||||||
|
||||||
fieldPreferences.setResolveStrings(resolveStringsProperty.getValue()); | ||||||
fieldPreferences.setResolvableFields(FieldFactory.parseFieldList(resolveStringsForFieldsProperty.getValue().trim())); | ||||||
fieldPreferences.setNonWrappableFields(FieldFactory.parseFieldList(nonWrappableFieldsProperty.getValue().trim())); | ||||||
|
||||||
ownerPreferences.setUseOwner(markOwnerProperty.getValue()); | ||||||
ownerPreferences.setDefaultOwner(markOwnerNameProperty.getValue()); | ||||||
ownerPreferences.setOverwriteOwner(markOwnerOverwriteProperty.getValue()); | ||||||
|
||||||
timestampPreferences.setAddCreationDate(addCreationDateProperty.getValue()); | ||||||
timestampPreferences.setAddModificationDate(addModificationDateProperty.getValue()); | ||||||
fieldPreferences.getResolvableFields().clear(); | ||||||
fieldPreferences.getResolvableFields().addAll(resolveStringsForFieldsProperty.getValue()); | ||||||
fieldPreferences.getNonWrappableFields().clear(); | ||||||
fieldPreferences.getNonWrappableFields().addAll(nonWrappableFieldsProperty.getValue()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
public StringProperty keywordSeparatorProperty() { | ||||||
|
@@ -79,11 +82,11 @@ public BooleanProperty resolveStringsProperty() { | |||||
return resolveStringsProperty; | ||||||
} | ||||||
|
||||||
public StringProperty resolveStringsForFieldsProperty() { | ||||||
public ListProperty<Field> resolveStringsForFieldsProperty() { | ||||||
return resolveStringsForFieldsProperty; | ||||||
} | ||||||
|
||||||
public StringProperty nonWrappableFieldsProperty() { | ||||||
public ListProperty<Field> nonWrappableFieldsProperty() { | ||||||
return nonWrappableFieldsProperty; | ||||||
} | ||||||
|
||||||
|
@@ -110,4 +113,18 @@ public BooleanProperty addCreationDateProperty() { | |||||
public BooleanProperty addModificationDateProperty() { | ||||||
return addModificationDateProperty; | ||||||
} | ||||||
|
||||||
public StringConverter<Field> getFieldStringConverter() { | ||||||
return new StringConverter<>() { | ||||||
@Override | ||||||
public String toString(Field field) { | ||||||
return field.getDisplayName(); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public Field fromString(String string) { | ||||||
return FieldFactory.parseField(string); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I was updating it according to the autocompletion module, and that uses parseFieldList. |
||||||
} | ||||||
}; | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values are in list format, so can not trim them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use map to trim them individually then.