From caa88a2664928116a53c0a48c36d8c6f434bf690 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 26 Nov 2019 22:35:41 +0100 Subject: [PATCH 1/6] Issue solved - but it's not clean and not tested add an attribute in tagbar to allow or not multiple entries --- .../java/org/jabref/gui/fieldeditors/FieldEditors.java | 6 ++++-- .../org/jabref/gui/fieldeditors/LinkedEntriesEditor.java | 3 ++- src/main/java/org/jabref/gui/util/component/TagBar.java | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index d44cb882aad..2481fa5e619 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -84,8 +84,10 @@ public static FieldEditorFX getForField(final Field field, } else { return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers)); } - } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK) || fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { - return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); + } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,false); + } else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,true); } else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) { return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine); } else if (StandardField.KEYWORDS.equals(field)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index 1f3b2b143a6..961958914a5 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -21,13 +21,14 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX { @FXML private final LinkedEntriesEditorViewModel viewModel; @FXML private TagBar linkedEntriesBar; - public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { + public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers, Boolean isMultiple) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); ViewLoader.view(this) .root(this) .load(); + linkedEntriesBar.allowsMultipleEntries(isMultiple); linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink)); diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index 9cb34945cd2..a55d66c7400 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -30,6 +30,7 @@ public class TagBar extends HBox { @FXML private TextField inputTextField; @FXML private HBox tagList; private BiConsumer onTagClicked; + private Boolean allowsMultiple; public TagBar() { tags = new SimpleListProperty<>(FXCollections.observableArrayList()); @@ -62,8 +63,10 @@ private void onTagsChanged(ListChangeListener.Change change) { while (change.next()) { if (change.wasRemoved()) { tagList.getChildren().subList(change.getFrom(), change.getFrom() + change.getRemovedSize()).clear(); + if(!allowsMultiple) { inputTextField.setDisable(false);} } else if (change.wasAdded()) { tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList())); + if(!allowsMultiple) { inputTextField.setDisable(true);} } } } @@ -81,7 +84,7 @@ private Tag createTag(T item) { @FXML private void addTextAsNewTag(ActionEvent event) { String inputText = inputTextField.getText(); - if (StringUtil.isNotBlank(inputText)) { + if (StringUtil.isNotBlank(inputText)&&(tags.isEmpty()||this.allowsMultiple)) { T newTag = stringConverter.fromString(inputText); if ((newTag != null) && !tags.contains(newTag)) { tags.add(newTag); @@ -97,4 +100,6 @@ public void setStringConverter(StringConverter stringConverter) { public void setOnTagClicked(BiConsumer onTagClicked) { this.onTagClicked = onTagClicked; } + + public void allowsMultipleEntries(Boolean isMultiple) { this.allowsMultiple=isMultiple; } } From 78fcf34dcd67310d77a022487d6884df69ac0855 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 4 Dec 2019 10:21:48 +0100 Subject: [PATCH 2/6] fixed and cleansed --- src/main/java/org/jabref/gui/util/component/TagBar.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index a55d66c7400..55f96fec3f4 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -30,7 +30,7 @@ public class TagBar extends HBox { @FXML private TextField inputTextField; @FXML private HBox tagList; private BiConsumer onTagClicked; - private Boolean allowsMultiple; + private Boolean allowsMultiple=true; public TagBar() { tags = new SimpleListProperty<>(FXCollections.observableArrayList()); @@ -84,9 +84,9 @@ private Tag createTag(T item) { @FXML private void addTextAsNewTag(ActionEvent event) { String inputText = inputTextField.getText(); - if (StringUtil.isNotBlank(inputText)&&(tags.isEmpty()||this.allowsMultiple)) { + if (StringUtil.isNotBlank(inputText)) { T newTag = stringConverter.fromString(inputText); - if ((newTag != null) && !tags.contains(newTag)) { + if ((newTag != null) && !tags.contains(newTag)&&(tags.isEmpty()||this.allowsMultiple)) { tags.add(newTag); inputTextField.clear(); } From 925f03ab9b4a1e305b30660ff4a3e8aa4663b9d7 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 9 Dec 2019 09:54:30 +0100 Subject: [PATCH 3/6] Fix multiple entries allowed in crossref Fixed issue #5284 where multiple entries were allowed in crossref field, whereas only one should be allowed. https://github.com/JabRef/jabref/issues/5284 --- AUTHORS | 3 +++ CHANGELOG.md | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 799b72a6fdc..e5239076f5b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -104,6 +104,7 @@ Jörg Lenhard Jörg Wegner Jörg Zieren Jørgen Kvalsvik +Julien Benard Jürgen Lange Kai Mindermann Karsten Hiekmann @@ -117,6 +118,7 @@ Leonardo Haddad Ling Wang Linus Dietz Lorenzo Genta +Lucas Beretti Luciana de Melo e Abud Mairieli Wessel Manuel Siebeneicher @@ -200,6 +202,7 @@ Toralf Senger Ulrich Stärk Ulrik Stervbo Uwe Kuehn +Venceslas Roullier Vincent W. Yang Waida Fan Waluyo Adi Siswanto diff --git a/CHANGELOG.md b/CHANGELOG.md index 796c8e28ff5..e0b6d84693a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - The "All entries group" is no longer shown when no library is open. - We fixed an exception which occurred when closing JabRef. [#5348](https://github.com/JabRef/jabref/issues/5348) - We fixed a few problems that prevented JabFox to communicate with JabRef. [#4737](https://github.com/JabRef/jabref/issues/4737) [#4303](https://github.com/JabRef/jabref/issues/4303) -- We fixed an error where the groups containing an entry loose their highlight color when scrolling. [#5022](https://github.com/JabRef/jabref/issues/5022) +- We fixed an error where the groups containing an entry loose their highlight color when scrolling. [#5022](https://github.com/JabRef/jabref/issues/5022) - We fixed an error where an exception was thrown when merging entries. [#5169](https://github.com/JabRef/jabref/issues/5169) - After assigning an entry to a group, the item count is now properly colored to reflect the new membership of the entry. [#3112](https://github.com/JabRef/jabref/issues/3112) - The group panel is now properly updated when switching between libraries (or when closing/opening one). [#3142](https://github.com/JabRef/jabref/issues/3142) @@ -37,7 +37,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where multiple entries were highlighted in the web search result after scrolling. [#5035](https://github.com/JabRef/jabref/issues/5035) - We fixed an issue where the hover indication in the web search pane was not working. [#5277](https://github.com/JabRef/jabref/issues/5277) - We fixed an error mentioning "javafx.controls/com.sun.javafx.scene.control" that was thrown when interacting with the toolbar. -- We fixed an error where a cleared search was restored after switching libraries. [#4846](https://github.com/JabRef/jabref/issues/4846) +- We fixed an error where a cleared search was restored after switching libraries. [#4846](https://github.com/JabRef/jabref/issues/4846) - We fixed an exception which occurred when trying to open a non-existing file from the "Recent files"-menu [#5334](https://github.com/JabRef/jabref/issues/5334) - We fixed an issues where the search highlight in the entry preview did not worked. [#5069](https://github.com/JabRef/jabref/issues/5069) - The context menu for fields in the entry editor is back. [#5254](https://github.com/JabRef/jabref/issues/5254) @@ -46,11 +46,11 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We re-introduced the feature to switch between different preview styles. [#5221](https://github.com/JabRef/jabref/issues/5221) - We fixed various issues (including [#5263](https://github.com/JabRef/jabref/issues/5263)) related to copying entries to the clipboard - We fixed some display errors in the preferences dialog and replaced some of the controls [#5033](https://github.com/JabRef/jabref/pull/5033) [#5047](https://github.com/JabRef/jabref/pull/5047) [#5062](https://github.com/JabRef/jabref/pull/5062) [#5141](https://github.com/JabRef/jabref/pull/5141) [#5185](https://github.com/JabRef/jabref/pull/5185) [#5265](https://github.com/JabRef/jabref/pull/5265) [#5315](https://github.com/JabRef/jabref/pull/5315) [#5360](https://github.com/JabRef/jabref/pull/5360) -- We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447) +- We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447) - After successful import of one or multiple bib entries the main table scrolls to the first imported entry [#5383](https://github.com/JabRef/jabref/issues/5383) - We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) - We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463) - +- We fixed an issue where multiple entries were allowed in the "crossref" field [#5284](https://github.com/JabRef/jabref/issues/5284) ### Removed @@ -151,7 +151,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We optimized the code responsible for connecting to an external database, which should lead to huge improvements in performance. - For automatically created groups, added ability to filter groups by entry type. [#4539](https://github.com/JabRef/jabref/issues/4539) - We added the ability to add field names from the Preferences Dialog [#4546](https://github.com/JabRef/jabref/issues/4546) -- We added the ability to change the column widths directly in the main +- We added the ability to change the column widths directly in the main . [#4546](https://github.com/JabRef/jabref/issues/4546) - We added a description of how recommendations were chosen and better error handling to Related Articles tab - We added the ability to execute default action in dialog by using with Ctrl + Enter combination [#4496](https://github.com/JabRef/jabref/issues/4496) From 19d4394a59404168866b592d5cfef590d417d24c Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 11 Dec 2019 23:37:19 +0100 Subject: [PATCH 4/6] Reformat code Reformat code according to Jabref code style, simplify some conditions. --- .../jabref/gui/fieldeditors/FieldEditors.java | 4 ++-- .../gui/fieldeditors/LinkedEntriesEditor.java | 10 ++++---- .../org/jabref/gui/util/component/TagBar.java | 23 +++++++++++-------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 2481fa5e619..29711b2ffce 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -85,9 +85,9 @@ public static FieldEditorFX getForField(final Field field, return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers)); } } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { - return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,false); + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers, false); } else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { - return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers,true); + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers, true); } else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) { return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine); } else if (StandardField.KEYWORDS.equals(field)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index 961958914a5..c4fa4b48ced 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -18,15 +18,17 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX { - @FXML private final LinkedEntriesEditorViewModel viewModel; - @FXML private TagBar linkedEntriesBar; + @FXML + private final LinkedEntriesEditorViewModel viewModel; + @FXML + private TagBar linkedEntriesBar; public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers, Boolean isMultiple) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); ViewLoader.view(this) - .root(this) - .load(); + .root(this) + .load(); linkedEntriesBar.allowsMultipleEntries(isMultiple); linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index 55f96fec3f4..136e3d38c4a 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -27,10 +27,12 @@ public class TagBar extends HBox { private final ListProperty tags; private StringConverter stringConverter; - @FXML private TextField inputTextField; - @FXML private HBox tagList; + @FXML + private TextField inputTextField; + @FXML + private HBox tagList; private BiConsumer onTagClicked; - private Boolean allowsMultiple=true; + private boolean allowsMultiple = true; public TagBar() { tags = new SimpleListProperty<>(FXCollections.observableArrayList()); @@ -38,8 +40,8 @@ public TagBar() { // Load FXML ViewLoader.view(this) - .root(this) - .load(); + .root(this) + .load(); getStylesheets().add(0, TagBar.class.getResource("TagBar.css").toExternalForm()); } @@ -63,12 +65,13 @@ private void onTagsChanged(ListChangeListener.Change change) { while (change.next()) { if (change.wasRemoved()) { tagList.getChildren().subList(change.getFrom(), change.getFrom() + change.getRemovedSize()).clear(); - if(!allowsMultiple) { inputTextField.setDisable(false);} } else if (change.wasAdded()) { tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList())); - if(!allowsMultiple) { inputTextField.setDisable(true);} } } + if (!allowsMultiple) { + inputTextField.setDisable(!tags.isEmpty()); + } } private Tag createTag(T item) { @@ -86,7 +89,7 @@ private void addTextAsNewTag(ActionEvent event) { String inputText = inputTextField.getText(); if (StringUtil.isNotBlank(inputText)) { T newTag = stringConverter.fromString(inputText); - if ((newTag != null) && !tags.contains(newTag)&&(tags.isEmpty()||this.allowsMultiple)) { + if ((newTag != null) && !tags.contains(newTag) && (tags.isEmpty() || this.allowsMultiple)) { tags.add(newTag); inputTextField.clear(); } @@ -101,5 +104,7 @@ public void setOnTagClicked(BiConsumer onTagClicked) { this.onTagClicked = onTagClicked; } - public void allowsMultipleEntries(Boolean isMultiple) { this.allowsMultiple=isMultiple; } + public void allowsMultipleEntries(Boolean isMultiple) { + this.allowsMultiple = isMultiple; + } } From 5f5f94b92210971ebfa0897f3ea8f9550aebd02f Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 13 Dec 2019 14:43:06 +0100 Subject: [PATCH 5/6] Replaced the boolean with an enum arg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit former "isMultiple" was replaced by a use of FielProperty.Multiple_entry_link. Co-authored-by: Julien Bénard Co-authored-by: Lucas Beretti Co-authored-by: Venceslas Roullier --- src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java | 4 ++-- .../org/jabref/gui/fieldeditors/LinkedEntriesEditor.java | 5 +++-- src/main/java/org/jabref/gui/util/component/TagBar.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 29711b2ffce..77c02ef2e2d 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -85,9 +85,9 @@ public static FieldEditorFX getForField(final Field field, return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers)); } } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { - return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers, false); + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); } else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { - return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers, true); + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); } else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) { return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine); } else if (StandardField.KEYWORDS.equals(field)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index c4fa4b48ced..91a25770bf2 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -15,6 +15,7 @@ import org.jabref.model.entry.field.Field; import com.airhacks.afterburner.views.ViewLoader; +import org.jabref.model.entry.field.FieldProperty; public class LinkedEntriesEditor extends HBox implements FieldEditorFX { @@ -23,14 +24,14 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX { @FXML private TagBar linkedEntriesBar; - public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers, Boolean isMultiple) { + public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); ViewLoader.view(this) .root(this) .load(); - linkedEntriesBar.allowsMultipleEntries(isMultiple); + linkedEntriesBar.allowsMultipleEntries(field.getProperties().contains(FieldProperty.MULTIPLE_ENTRY_LINK)); linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink)); diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index 136e3d38c4a..b037db63699 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -104,7 +104,7 @@ public void setOnTagClicked(BiConsumer onTagClicked) { this.onTagClicked = onTagClicked; } - public void allowsMultipleEntries(Boolean isMultiple) { + public void allowsMultipleEntries(boolean isMultiple) { this.allowsMultiple = isMultiple; } } From fac11aebc2458a5f82948340e171919f9337dc36 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 15 Dec 2019 15:08:54 +0100 Subject: [PATCH 6/6] Replaced the boolean in Tagbar with a property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced the boolean attribute in TagBar with a Set of properties Co-authored-by: Julien Bénard Co-authored-by: Lucas Beretti Co-authored-by: Venceslas Roullier --- AUTHORS | 3 --- .../jabref/gui/fieldeditors/LinkedEntriesEditor.java | 3 +-- .../java/org/jabref/gui/util/component/TagBar.java | 12 +++++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5c213d85316..e8ff220b00e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -158,7 +158,6 @@ Jörg Lenhard Jörg Wegner Jörg Zieren Jørgen Kvalsvik -Julien Benard Jürgen Lange Kai Mindermann Kai Takac @@ -182,7 +181,6 @@ Li Zhilin Ling Wang Linus Dietz Lorenzo Genta -Lucas Beretti Luciana de Melo e Abud Mairieli Wessel Malik Atalla @@ -319,7 +317,6 @@ Ulrik Stervbo UltimaBGD Uwe Kuehn Valentin Pons -Venceslas Roullier Victor Figueira Victor Michelan Vincent W. Yang diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index 91a25770bf2..f510063ee90 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -15,7 +15,6 @@ import org.jabref.model.entry.field.Field; import com.airhacks.afterburner.views.ViewLoader; -import org.jabref.model.entry.field.FieldProperty; public class LinkedEntriesEditor extends HBox implements FieldEditorFX { @@ -31,7 +30,7 @@ public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, Auto .root(this) .load(); - linkedEntriesBar.allowsMultipleEntries(field.getProperties().contains(FieldProperty.MULTIPLE_ENTRY_LINK)); + linkedEntriesBar.setFieldProperties(field.getProperties()); linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink)); diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index b037db63699..13974238a30 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -2,6 +2,7 @@ import java.util.Collection; import java.util.function.BiConsumer; +import java.util.Set; import java.util.stream.Collectors; import javafx.beans.property.ListProperty; @@ -16,6 +17,7 @@ import javafx.scene.layout.HBox; import javafx.util.StringConverter; +import org.jabref.model.entry.field.FieldProperty; import org.jabref.model.strings.StringUtil; import com.airhacks.afterburner.views.ViewLoader; @@ -32,7 +34,7 @@ public class TagBar extends HBox { @FXML private HBox tagList; private BiConsumer onTagClicked; - private boolean allowsMultiple = true; + private java.util.Set properties; public TagBar() { tags = new SimpleListProperty<>(FXCollections.observableArrayList()); @@ -69,7 +71,7 @@ private void onTagsChanged(ListChangeListener.Change change) { tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList())); } } - if (!allowsMultiple) { + if (this.properties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { inputTextField.setDisable(!tags.isEmpty()); } } @@ -89,7 +91,7 @@ private void addTextAsNewTag(ActionEvent event) { String inputText = inputTextField.getText(); if (StringUtil.isNotBlank(inputText)) { T newTag = stringConverter.fromString(inputText); - if ((newTag != null) && !tags.contains(newTag) && (tags.isEmpty() || this.allowsMultiple)) { + if ((newTag != null) && !tags.contains(newTag) && (tags.isEmpty() || this.properties.contains(FieldProperty.MULTIPLE_ENTRY_LINK))) { tags.add(newTag); inputTextField.clear(); } @@ -104,7 +106,7 @@ public void setOnTagClicked(BiConsumer onTagClicked) { this.onTagClicked = onTagClicked; } - public void allowsMultipleEntries(boolean isMultiple) { - this.allowsMultiple = isMultiple; + public void setFieldProperties(Set properties) { + this.properties = properties; } }