diff --git a/CHANGELOG.md b/CHANGELOG.md index 6442bbd0f0f..aa9b038abaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) - We fixed an issue where the command line arguments `importBibtex` and `importToOpen` did not import into the currently open library, but opened a new one. [#5537](https://github.com/JabRef/jabref/issues/5537) - 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) - We fixed an issue where the merge dialog showed the wrong text colour in "Dark" mode [#5516](https://github.com/JabRef/jabref/issues/5516) - We fixed visibility issues with the scrollbar and group selection highlight in "Dark" mode, and enabled "Dark" mode for the OpenOffice preview in the style selection window. [#5522](https://github.com/JabRef/jabref/issues/5522) - We fixed an issue where the author field was not correctly parsed during bibtex key-generation. [#5551](https://github.com/JabRef/jabref/issues/5551) diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index d44cb882aad..77c02ef2e2d 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -84,7 +84,9 @@ 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)) { + } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); + } 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); diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index 1f3b2b143a6..f510063ee90 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -18,16 +18,19 @@ 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) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); ViewLoader.view(this) - .root(this) - .load(); + .root(this) + .load(); + 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 9cb34945cd2..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; @@ -27,9 +29,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 java.util.Set properties; public TagBar() { tags = new SimpleListProperty<>(FXCollections.observableArrayList()); @@ -37,8 +42,8 @@ public TagBar() { // Load FXML ViewLoader.view(this) - .root(this) - .load(); + .root(this) + .load(); getStylesheets().add(0, TagBar.class.getResource("TagBar.css").toExternalForm()); } @@ -66,6 +71,9 @@ private void onTagsChanged(ListChangeListener.Change change) { tagList.getChildren().addAll(change.getFrom(), change.getAddedSubList().stream().map(this::createTag).collect(Collectors.toList())); } } + if (this.properties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { + inputTextField.setDisable(!tags.isEmpty()); + } } private Tag createTag(T item) { @@ -83,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)) { + if ((newTag != null) && !tags.contains(newTag) && (tags.isEmpty() || this.properties.contains(FieldProperty.MULTIPLE_ENTRY_LINK))) { tags.add(newTag); inputTextField.clear(); } @@ -97,4 +105,8 @@ public void setStringConverter(StringConverter stringConverter) { public void setOnTagClicked(BiConsumer onTagClicked) { this.onTagClicked = onTagClicked; } + + public void setFieldProperties(Set properties) { + this.properties = properties; + } }