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 4f21af2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 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,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.util.component.TagBar?>
<?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"/>

This comment has been minimized.

Copy link
@dextep

dextep Mar 31, 2020

Author Owner

How can i set height, because maxHeight doesn't work? @tobiasdiez

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Mar 31, 2020

Normally, the entry editor take care that all controls have the proper height (you might need to specify prefHeight for this to work). Why do you want to set this manually?

This comment has been minimized.

Copy link
@dextep

dextep Mar 31, 2020

Author Owner

I added prefHeight but it still doesn't look good. Unfortunately the prefHeight did't change anything.
<JFXChipView fx:id="chipView" prefHeight="0.0" HBox.hgrow="ALWAYS" maxWidth="Infinity"/>
image

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Mar 31, 2020

This looks like the editor in the chips view is has some padding. I didn't tried it but adding the following to main.css (or base.css don't remember the name) might work:

.chips-pane > .editor {
    -fx-pref-height: infinity;
    maybe something like the following in addition?
    -fx-padding: 0;
}

This comment has been minimized.

Copy link
@dextep

dextep Apr 1, 2020

Author Owner

Right now i have 2 problems:

  1. I can't align this field to the left:
    image
  2. After adding chip it creates empty space below:
    image

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Apr 1, 2020

The best way to investigate these problems is to use ScenicView https://github.com/JonathanGiles/scenic-view

Please also create a pull-request towards the JabRef repositories so that the other developers also see your questions and can help you. Thanks!

This comment has been minimized.

Copy link
@dextep

dextep Apr 1, 2020

Author Owner

unfortunately I can't find a parameter that could even out this field

</fx:root>
23 changes: 15 additions & 8 deletions src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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.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 +22,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,12 +31,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));
// chipView.getSuggestions().addAll(viewModel.linkedEntriesProperty());

This comment has been minimized.

Copy link
@dextep

dextep Mar 31, 2020

Author Owner

I have no idea how to make suggestions work. @tobiasdiez

This comment has been minimized.

This comment has been minimized.

Copy link
@dextep

dextep Mar 31, 2020

Author Owner

I don't know how can I take all keys to put them to the suggestions.

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Mar 31, 2020

That requires indeed a bit more work than I initially thought:

This comment has been minimized.

Copy link
@dextep

dextep Mar 31, 2020

Author Owner

ok, will try, but next problem i recognize is blocking the entry of new entries while FieldProperty.SINGLE_ENTRY_LINK

This comment has been minimized.

Copy link
@dextep

dextep Apr 1, 2020

Author Owner

Its good idea to get keys from databaseContext param getPossibleSuggestions(BibDatabaseContext databaseContext) ?

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Apr 1, 2020

The suggestion providers are already initialized with the current database (i.e. only contain entries of this library).

This comment has been minimized.

Copy link
@dextep

dextep Apr 2, 2020

Author Owner

image

  • Add the getPossibleSuggestions() method also to the AutoCompleteSuggestionProvider

image

Because ContentSelectorSuggestionProvider implements AutoCompleteSuggestionProvider<String> i had to add
image

  • Then you should be able to add the suggestions via chipView.getSuggestions().addAll(suggestionProvider.getPossibleSuggestions())

The result is null.
image

This comment has been minimized.

Copy link
@tobiasdiez

tobiasdiez Apr 2, 2020

Can you please create a pull request so that I can see the complete code. Thanks

Your changes look good, but for some reason suggestionProvider is now null (it wasn't null before I hope)

This comment has been minimized.

Copy link
@dextep

dextep Apr 2, 2020

Author Owner

Sorry, Im not sure when i should create a pull request. I did it already but I'm not completely sure its correct. Feel free to give me comments and advice :) @tobiasdiez


AutoCompletionTextInputBinding.autoComplete(linkedEntriesBar.getInputTextField(), viewModel::complete, viewModel.getStringConverter());
Bindings.bindContentBidirectional(linkedEntriesBar.tagsProperty(), viewModel.linkedEntriesProperty());
chipView.setConverter(viewModel.getStringConverter());

chipView.setChipFactory(
(view, item) -> {
JFXChip<ParsedEntryLink> chip = new JFXDefaultChip<>(view, item);
chip.setOnMouseClicked(event -> viewModel.jumpToEntry(item) );
return chip;
});

Bindings.bindContentBidirectional(chipView.getChips(), viewModel.linkedEntriesProperty());
}

public LinkedEntriesEditorViewModel getViewModel() {
Expand Down

0 comments on commit 4f21af2

Please sign in to comment.