Skip to content

Commit

Permalink
Make wrap fields also visible in entry editor
Browse files Browse the repository at this point in the history
Fixes #4373
  • Loading branch information
Siedlerchr committed Apr 19, 2020
1 parent 1c3834f commit 0b39116
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
9 changes: 4 additions & 5 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import javax.swing.undo.UndoManager;

import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.autocompleter.AutoCompleteSuggestionProvider;
import org.jabref.gui.autocompleter.ContentSelectorSuggestionProvider;
Expand Down Expand Up @@ -52,10 +51,10 @@ public static FieldEditorFX getForField(final Field field,
preferences.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY),
preferences.getBoolean(JabRefPreferences.ALLOW_INTEGER_EDITION_BIBTEX));

final boolean isSingleLine = FieldFactory.isSingleLineField(field);
boolean isMultiLine = FieldFactory.isMultiLineField(field, preferences.getFieldContentParserPreferences().getNonWrappableFields());

if (preferences.getTimestampPreferences().getTimestampField().equals(field)) {
return new DateEditor(field, DateTimeFormatter.ofPattern(Globals.prefs.getTimestampPreferences().getTimestampFormat()), suggestionProvider, fieldCheckers);
return new DateEditor(field, DateTimeFormatter.ofPattern(preferences.getTimestampPreferences().getTimestampFormat()), suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.DATE)) {
return new DateEditor(field, DateTimeFormatter.ofPattern("[uuuu][-MM][-dd]"), suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.EXTERNAL)) {
Expand Down Expand Up @@ -89,14 +88,14 @@ public static FieldEditorFX getForField(final Field field,
} else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) {
return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) {
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine);
return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isMultiLine);
} else if (StandardField.KEYWORDS.equals(field)) {
return new KeywordsEditor(field, suggestionProvider, fieldCheckers, preferences);
} else if (field == InternalField.KEY_FIELD) {
return new BibtexKeyEditor(field, preferences, suggestionProvider, fieldCheckers, databaseContext, undoManager, dialogService);
} else {
// default
return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isSingleLine);
return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isMultiLine);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ public PersonsEditor(final Field field,
final AutoCompleteSuggestionProvider<?> suggestionProvider,
final JabRefPreferences preferences,
final FieldCheckers fieldCheckers,
final boolean isSingleLine) {
final boolean isMultiLine) {
this.viewModel = new PersonsEditorViewModel(field, suggestionProvider, preferences.getAutoCompletePreferences(), fieldCheckers);

textInput = isSingleLine
? new EditorTextField()
: new EditorTextArea();
textInput = isMultiLine ? new EditorTextArea() : new EditorTextField();

decoratedStringProperty = new UiThreadStringProperty(viewModel.textProperty());
textInput.textProperty().bindBidirectional(decoratedStringProperty);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ public SimpleEditor(final Field field,
final AutoCompleteSuggestionProvider<?> suggestionProvider,
final FieldCheckers fieldCheckers,
final JabRefPreferences preferences,
final boolean isSingleLine) {
final boolean isMultiLine) {
this.viewModel = new SimpleEditorViewModel(field, suggestionProvider, fieldCheckers);

textInput = isSingleLine
? new EditorTextField()
: new EditorTextArea();
textInput = isMultiLine ? new EditorTextArea() : new EditorTextField();
HBox.setHgrow(textInput, Priority.ALWAYS);

textInput.textProperty().bindBidirectional(viewModel.textProperty());
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/jabref/model/entry/field/FieldFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,10 @@ public static List<Field> getDefaultGeneralFields() {
return defaultGeneralFields;
}

// TODO: Move somewhere more appropriate and make user-configurable
public static boolean isSingleLineField(final Field field) {
if (field.equals(StandardField.ABSTRACT) || field.equals(StandardField.COMMENT)) {
return false;
}

public static boolean isMultiLineField(final Field field, List<Field> nonWrappableFields) {
// Treat unknown fields as multi-line fields
return !(field instanceof UnknownField);
// FieldContentFormatter provides us with the addtional field abstract, comment and review
return (field instanceof UnknownField) || nonWrappableFields.contains(field) || field.equals(StandardField.ABSTRACT) || field.equals(StandardField.COMMENT) || field.equals(StandardField.REVIEW);
}
}
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ private JabRefPreferences() {
defaults.put(DEFAULT_BIBTEX_KEY_PATTERN, "[auth][year]");
defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, StandardField.URL.getName());
defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE);
defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file;isbn;issn");
defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file;isbn;issn;");
defaults.put(WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE);
defaults.put(USE_TIME_STAMP, Boolean.FALSE);
defaults.put(OVERWRITE_TIME_STAMP, Boolean.FALSE);
Expand Down Expand Up @@ -1538,12 +1538,14 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() {
getBoolean(USE_IEEE_ABRV), getDefaultEncoding());
}

@Override
public CleanupPreferences getCleanupPreferences(JournalAbbreviationLoader journalAbbreviationLoader) {
return new CleanupPreferences(
getLayoutFormatterPreferences(journalAbbreviationLoader),
getFilePreferences());
}

@Override
public CleanupPreset getCleanupPreset() {
Set<CleanupPreset.CleanupStep> activeJobs = EnumSet.noneOf(CleanupPreset.CleanupStep.class);

Expand All @@ -1558,6 +1560,7 @@ public CleanupPreset getCleanupPreset() {
return new CleanupPreset(activeJobs, formatterCleanups);
}

@Override
public void setCleanupPreset(CleanupPreset cleanupPreset) {
for (CleanupPreset.CleanupStep action : EnumSet.allOf(CleanupPreset.CleanupStep.class)) {
putBoolean(JabRefPreferences.CLEANUP + action.name(), cleanupPreset.isActive(action));
Expand Down

0 comments on commit 0b39116

Please sign in to comment.