From 51bf073773615399f493eb1a41bb603c5b827f4f Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 25 Aug 2019 13:14:54 +0200 Subject: [PATCH] Treat unknown fields as multi-line fields Fixes #5021. Unknown fields are now treated as multi-line fields. In the future, we should provide an UI interface to specify or change properties of fields. --- .../jabref/gui/fieldeditors/FieldEditors.java | 8 +++----- .../gui/fieldeditors/MultilineEditor.java | 18 ------------------ .../jabref/model/entry/field/FieldFactory.java | 8 +++++++- .../model/entry/field/FieldProperty.java | 1 - .../model/entry/field/StandardField.java | 4 ++-- 5 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/fieldeditors/MultilineEditor.java diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index f1f588faca0..d44cb882aad 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -90,14 +90,12 @@ public static FieldEditorFX getForField(final Field field, return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine); } else if (StandardField.KEYWORDS.equals(field)) { return new KeywordsEditor(field, suggestionProvider, fieldCheckers, preferences); - } else if (fieldProperties.contains(FieldProperty.MULTILINE_TEXT)) { - return new MultilineEditor(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); } - - // default - return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isSingleLine); } @SuppressWarnings("unchecked") diff --git a/src/main/java/org/jabref/gui/fieldeditors/MultilineEditor.java b/src/main/java/org/jabref/gui/fieldeditors/MultilineEditor.java deleted file mode 100644 index ac1323c9737..00000000000 --- a/src/main/java/org/jabref/gui/fieldeditors/MultilineEditor.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.jabref.gui.fieldeditors; - -import org.jabref.gui.autocompleter.AutoCompleteSuggestionProvider; -import org.jabref.logic.integrity.FieldCheckers; -import org.jabref.model.entry.field.Field; -import org.jabref.preferences.JabRefPreferences; - -public class MultilineEditor extends SimpleEditor implements FieldEditorFX { - - public MultilineEditor(Field field, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers, JabRefPreferences preferences) { - super(field, suggestionProvider, fieldCheckers, preferences); - } - - @Override - public double getWeight() { - return 4; - } -} diff --git a/src/main/java/org/jabref/model/entry/field/FieldFactory.java b/src/main/java/org/jabref/model/entry/field/FieldFactory.java index 0f348e6120e..4a9da29f966 100644 --- a/src/main/java/org/jabref/model/entry/field/FieldFactory.java +++ b/src/main/java/org/jabref/model/entry/field/FieldFactory.java @@ -139,7 +139,13 @@ public static List getDefaultGeneralFields() { return defaultGeneralFields; } + // TODO: Move somewhere more appropriate and make user-configurable public static boolean isSingleLineField(final Field field) { - return !field.getProperties().contains(FieldProperty.MULTILINE_TEXT); + if (field.equals(StandardField.ABSTRACT) || field.equals(StandardField.COMMENT)) { + return false; + } + + // Treat unknown fields as multi-line fields + return !(field instanceof UnknownField); } } diff --git a/src/main/java/org/jabref/model/entry/field/FieldProperty.java b/src/main/java/org/jabref/model/entry/field/FieldProperty.java index c774c6880ee..df6603868bf 100644 --- a/src/main/java/org/jabref/model/entry/field/FieldProperty.java +++ b/src/main/java/org/jabref/model/entry/field/FieldProperty.java @@ -13,7 +13,6 @@ public enum FieldProperty { JOURNAL_NAME, LANGUAGE, MONTH, - MULTILINE_TEXT, MULTIPLE_ENTRY_LINK, NUMERIC, PAGES, diff --git a/src/main/java/org/jabref/model/entry/field/StandardField.java b/src/main/java/org/jabref/model/entry/field/StandardField.java index 6acf86dfbce..2b3c7ebf534 100644 --- a/src/main/java/org/jabref/model/entry/field/StandardField.java +++ b/src/main/java/org/jabref/model/entry/field/StandardField.java @@ -11,7 +11,7 @@ */ public enum StandardField implements Field { - ABSTRACT("abstract", FieldProperty.MULTILINE_TEXT), + ABSTRACT("abstract"), ADDENDUM("addendum"), ADDRESS("address"), AFTERWORD("afterword", FieldProperty.PERSON_NAMES), @@ -28,7 +28,7 @@ public enum StandardField implements Field { BOOKTITLEADDON("booktitleaddon"), CHAPTER("chapter"), COMMENTATOR("commentator", FieldProperty.PERSON_NAMES), - COMMENT("comment", FieldProperty.MULTILINE_TEXT), + COMMENT("comment"), CROSSREF("crossref", FieldProperty.SINGLE_ENTRY_LINK), DATE("date", FieldProperty.DATE), DAY("day"),