Skip to content

Commit

Permalink
Resolve issue JabRef#6140
Browse files Browse the repository at this point in the history
Tooltip on crossref field.
Improve display of groups.
  • Loading branch information
dextep committed Mar 31, 2020
1 parent a44305b commit 9f32323
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/FieldNameLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.util.component.TagBar?>
<?import javafx.scene.layout.*?>
<?import com.jfoenix.controls.JFXChipView?>

<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.LinkedEntriesEditor">
<TagBar fx:id="linkedEntriesBar" maxWidth="Infinity" HBox.hgrow="ALWAYS"/>
<JFXChipView fx:id="chipView" HBox.hgrow="ALWAYS" maxWidth="Infinity"/>
</fx:root>

27 changes: 16 additions & 11 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +24,7 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX {
@FXML
private final LinkedEntriesEditorViewModel viewModel;
@FXML
private TagBar<ParsedEntryLink> linkedEntriesBar;
private JFXChipView<ParsedEntryLink> chipView;

public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider<?> suggestionProvider, FieldCheckers fieldCheckers) {
this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers);
Expand All @@ -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<ParsedEntryLink> 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
Expand Down

0 comments on commit 9f32323

Please sign in to comment.