Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix re-enabling "Jump to entry" for "linked" tokens in Field editors #8456

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.jabref.gui.fieldeditors;

import java.util.stream.Collectors;

import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;

import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.ParsedEntryLink;
Expand All @@ -34,12 +34,13 @@ public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, Sugg
.root(this)
.load();

chipView.setTooltip(new Tooltip(Localization.lang("Jump to entry")));
chipView.setConverter(viewModel.getStringConverter());
var autoCompletionItemFactory = new ViewModelListCellFactory<ParsedEntryLink>()
.withText(ParsedEntryLink::getKey);
chipView.getAutoCompletePopup().setSuggestionsCellFactory(autoCompletionItemFactory);
chipView.getAutoCompletePopup().setCellLimit(5);
chipView.getSuggestions().addAll(suggestionProvider.getPossibleSuggestions().stream().map(ParsedEntryLink::new).collect(Collectors.toList()));
chipView.getSuggestions().addAll(suggestionProvider.getPossibleSuggestions().stream().map(ParsedEntryLink::new).toList());

chipView.setChipFactory((view, item) -> {
JFXChip<ParsedEntryLink> chip = new JFXDefaultChip<>(view, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.collections.FXCollections;
import javafx.util.StringConverter;

import org.jabref.gui.JabRefGUI;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.util.BindingsHelper;
import org.jabref.logic.integrity.FieldCheckers;
Expand Down Expand Up @@ -39,10 +40,7 @@ public StringConverter<ParsedEntryLink> getStringConverter() {

@Override
public String toString(ParsedEntryLink linkedEntry) {
if (linkedEntry == null) {
return "";
}
return linkedEntry.getKey();
return linkedEntry == null ? "" : linkedEntry.getKey();
}

@Override
Expand All @@ -53,13 +51,12 @@ public ParsedEntryLink fromString(String key) {
}

public void jumpToEntry(ParsedEntryLink parsedEntryLink) {
// TODO: Implement jump to entry
// TODO: Add toolitp for tag: Localization.lang("Jump to entry")
// This feature was removed while converting the linked entries editor to JavaFX
// Right now there is no nice way to re-implement it as we have no good interface to control the focus of the main table
// (except directly using the JabRefFrame class as below)
// parsedEntryLink.getLinkedEntry().ifPresent(
// e -> frame.getCurrentBasePanel().highlightEntry(e)
// );
var linkedEntry = parsedEntryLink.getLinkedEntry();
if (linkedEntry.isPresent()) {
var currentLibraryTab = JabRefGUI.getMainFrame().getCurrentLibraryTab();
if (databaseContext.equals(currentLibraryTab.getBibDatabaseContext())) {
currentLibraryTab.clearAndSelect(linkedEntry.get());
}
}
}
}