From 96cf3f585cad7cf6b6a0facc4157df4af90ff6c1 Mon Sep 17 00:00:00 2001 From: Grzegorz Date: Tue, 31 Mar 2020 15:08:13 +0200 Subject: [PATCH] Tooltip on crossref field. Improve display of groups. Following #6140 --- .../gui/fieldeditors/FieldNameLabel.java | 3 +++ .../gui/fieldeditors/LinkedEntriesEditor.fxml | 8 +++--- .../gui/fieldeditors/LinkedEntriesEditor.java | 27 +++++++++++-------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java b/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java index 91b48f527210..463fc08ef548 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java @@ -146,6 +146,9 @@ public String getDescription(Field field) { return Localization.lang("Year of publication."); case KEYWORDS: return Localization.lang("Separated list of keywords."); + case CROSSREF: + return Localization.lang("Linking entries together (child parent relation).") + "\n" + + Localization.lang("Enter the key of the other entry."); } } else if (field instanceof InternalField) { InternalField internalField = (InternalField) field; diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml index d473486a2224..8835deef9d2c 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.fxml @@ -1,8 +1,10 @@ - - + + + - + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index f510063ee90d..b9c22b72f337 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -1,13 +1,16 @@ package org.jabref.gui.fieldeditors; +import com.jfoenix.controls.JFXChip; +import com.jfoenix.controls.JFXChipView; +import com.jfoenix.controls.JFXDefaultChip; import javafx.beans.binding.Bindings; import javafx.fxml.FXML; import javafx.scene.Parent; +import javafx.scene.control.TextField; import javafx.scene.layout.HBox; import org.jabref.gui.autocompleter.AutoCompleteSuggestionProvider; -import org.jabref.gui.autocompleter.AutoCompletionTextInputBinding; -import org.jabref.gui.util.component.TagBar; + import org.jabref.logic.integrity.FieldCheckers; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; @@ -21,7 +24,7 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX { @FXML private final LinkedEntriesEditorViewModel viewModel; @FXML - private TagBar linkedEntriesBar; + private JFXChipView chipView; public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); @@ -30,16 +33,18 @@ public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, Auto .root(this) .load(); - linkedEntriesBar.setFieldProperties(field.getProperties()); - linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); - linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink)); + //I have no idea how to make suggestions work + chipView.getSuggestions().addAll(viewModel.linkedEntriesProperty()); + chipView.setConverter(viewModel.getStringConverter()); - AutoCompletionTextInputBinding.autoComplete(linkedEntriesBar.getInputTextField(), viewModel::complete, viewModel.getStringConverter()); - Bindings.bindContentBidirectional(linkedEntriesBar.tagsProperty(), viewModel.linkedEntriesProperty()); - } + chipView.setChipFactory( + (view, item) -> { + JFXChip chip = new JFXDefaultChip<>(view, item); + chip.setOnMouseClicked(event -> viewModel.jumpToEntry(item) ); + return chip; + }); - public LinkedEntriesEditorViewModel getViewModel() { - return viewModel; + Bindings.bindContentBidirectional(chipView.getChips(), viewModel.linkedEntriesProperty()); } @Override