Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.gui.entryeditor.citationrelationtab

public Class CitationRelationsTab

extends EntryEditorTab
Class Inheritance
Imports
java.io.IOException, .StringWriter, java.net.URI, .URLEncoder, java.nio.charset.StandardCharsets, java.util.ArrayList, .Arrays, .List, .Optional, java.util.concurrent.atomic.AtomicReference, java.util.function.BooleanSupplier, javafx.beans.binding.Bindings, .BooleanBinding, javafx.collections.FXCollections, .ObservableList, javafx.css.PseudoClass, javafx.geometry.HPos, .Insets, .Pos, .VPos, javafx.scene.Node, javafx.scene.control.Button, .ButtonType, .ComboBox, .ContextMenu, .DialogPane, .Hyperlink, .Label, .MenuItem, .ProgressIndicator, .ScrollPane, .SplitPane, .ToggleButton, .Tooltip, javafx.scene.input.ClipboardContent, .DragEvent, .Dragboard, .MouseButton, .MouseEvent, .TransferMode, javafx.scene.layout.BorderPane, .ColumnConstraints, .GridPane, .HBox, .Priority, .VBox, javafx.scene.text.Text, org.jabref.gui.DialogService, .DragAndDropDataFormats, .LibraryTab, .StateManager, org.jabref.gui.actions.StandardActions, org.jabref.gui.desktop.os.NativeDesktop, org.jabref.gui.entryeditor.EntryEditorPreferences, .EntryEditorTab, .EntryEditorTabModel, org.jabref.gui.icon.IconTheme, org.jabref.gui.maintable.MainTableTooltip, org.jabref.gui.mergeentries.threewaymerge.EntriesMergeResult, .MergeEntriesDialog, org.jabref.gui.preferences.GuiPreferences, org.jabref.gui.util.ControlHelper, .NoSelectionModel, .URLs, .ViewModelListCellFactory, org.jabref.logic.bibtex.BibEntryWriter, .FieldPreferences, .FieldWriter, org.jabref.logic.citation.SearchCitationsRelationsService, org.jabref.logic.database.DuplicateCheck, org.jabref.logic.exporter.BibWriter, org.jabref.logic.importer.FetcherException, org.jabref.logic.importer.fetcher.citation.CitationFetcher, .CitationFetcherType, org.jabref.logic.l10n.Localization, org.jabref.logic.os.OS, org.jabref.logic.util.BackgroundTask, .TaskExecutor, org.jabref.logic.util.strings.StringUtil, org.jabref.model.database.BibDatabase, .BibDatabaseContext, .BibDatabaseMode, org.jabref.model.entry.BibEntry, .BibEntryTypesManager, org.jabref.model.entry.field.StandardField, org.jabref.model.entry.identifier.DOI, org.jabref.model.sciteTallies.TalliesResponse, org.jabref.model.undo.UndoableInsertEntries, .UndoableRemoveEntries, org.jabref.model.util.FileUpdateMonitor, com.tobiasdiez.easybind.EasyBind, org.controlsfx.control.CheckListView, org.fxmisc.flowless.VirtualizedScrollPane, org.fxmisc.richtext.CodeArea, org.jspecify.annotations.Nullable, org.slf4j.Logger, .LoggerFactory

GUI for tab displaying an articles citation relations in two lists based on the currently selected BibEntry

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
CitationRelationsTab.CitationFetch

One of the two citation searches of SearchCitationsRelationsService, parameterized over the cancellation check so that createSearchTask can supply the one belonging to the task it is currently building.

private static record
CitationRelationsTab.LibrarySnapshot

Immutable snapshot of the active library, taken on the JavaFX Application Thread and consumed by the background duplicate matching in matchAgainstLibrary.

Field Summary

Modifier and TypeField and Description
private final CitationsRelationsTabViewModel
private @Nullable CitationComponents
private @Nullable CitationComponents
private final DialogService
private final DuplicateCheck
private final EntryEditorPreferences
private final BibEntryTypesManager
private ComboBox<CitationFetcherType>
private static final Logger
private final GuiPreferences
private final MainTableTooltip
private final ProgressIndicator
private final GridPane
private final SearchCitationsRelationsService
private boolean
private final StateManager
private final TaskExecutor

Constructor Summary

AccessConstructor and Description
public
CitationRelationsTab(DialogService dialogService, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor, GuiPreferences preferences, TaskExecutor taskExecutor, BibEntryTypesManager bibEntryTypesManager, SearchCitationsRelationsService searchCitationsRelationsService)

Method Summary

Modifier and TypeMethod and Description
protected void
private ContextMenu

Returns:

a ContextMenu with the "Open API URL in browser" option
createCitationContextMenu
(BibEntry
the BibEntry to get the API URL for
entry
,
SearchType
the type of search (CITES for references, CITED_BY for citations)
searchType
)

Creates a context menu for citation relation labels with an option to open the API URL in browser

private org.jabref.logic.util.BackgroundTask<List<CitationRelationItem>>
createCitationSearchTask(BibEntry entry, SearchType searchType, boolean bypassCache, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode)

private org.jabref.logic.util.BackgroundTask<List<CitationRelationItem>>
createSearchTask(CitationRelationsTab.CitationFetch fetch, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode)

Wraps fetching and duplicate matching into a task whose cancellation checks are bound to that very task.

private void
executeSearch(CitationComponents citationComponents, boolean bypassCache)

private VBox
private SplitPane

Returns:

SplitPane to display
getPaneAndStartSearch
(BibEntry
BibEntry which is currently selected in JabRef Database
entry
)

Method to create main SplitPane holding all lists, buttons and labels for tab and starts search

private String
getSourceString(BibEntry entry, BibDatabaseMode type, FieldPreferences fieldPreferences, BibEntryTypesManager entryTypesManager)

private BorderPane
private HBox
private void
private void
private void
private void
handleRefresh(CitationComponents citationComponents, CitationComponents otherCitationComponents)

private void
hideNodes(Node... nodes)

private void
importEntries(List<CitationRelationItem>
entries to import
entriesToImport
,
SearchType searchType, BibEntry existingEntry)

Function to import selected entries to the database.

private void
private void
private List<CitationRelationItem>
matchAgainstLibrary(List<BibEntry> fetchedList, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode, BooleanSupplier isCancelled)

private void
private void
private void
private void
private void
private void
openPossibleDuplicateEntriesWindow(CitationRelationItem
duplicate in the citation relations tab
citationRelationItem
,
CheckListView<CitationRelationItem>
CheckListView to display citations
listView
)

Function to open possible duplicate entries window to compare duplicate entries

private void
private void
private void
searchForRelations(CitationComponents citationComponents, CitationComponents otherCitationComponents, boolean bypassCache)

private static void
private static void
private void
private void
setUpEmptyPanel(CitationComponents citationComponents, CitationComponents otherCitationComponents)

private void
private void
showNodes(Node... nodes)

private CitationRelationsTab.LibrarySnapshot
snapshotActiveLibrary()

Snapshots the active library on the JavaFX Application Thread, so the background matching task never iterates the live entry list, which the user can modify while the search runs.

private void
styleFetchedListView(CheckListView<CitationRelationItem>
CheckListView to style
listView
,
CitationComponents citationComponents)

Styles a given CheckListView to display BibEntries either with a hyperlink or an add button.

private void
styleLabel(Label
label to style
label
,
String
tooltip text
tooltipText
)

Method to style heading labels

private void
Inherited from org.jabref.gui.entryeditor.EntryEditorTab:
currentEntryPropertydisposegetCurrentEntryhandleFocusnotifyAboutFocussetContentDrivenVisibilitysetPreferenceDrivenVisibilityvisibility

Field Detail

citationsRelationsTabViewModelback to summary
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel
currentCitedByComponentsback to summary
private @Nullable CitationComponents currentCitedByComponents
currentCitingComponentsback to summary
private @Nullable CitationComponents currentCitingComponents
dialogServiceback to summary
private final DialogService dialogService
duplicateCheckback to summary
private final DuplicateCheck duplicateCheck
entryEditorPreferencesback to summary
private final EntryEditorPreferences entryEditorPreferences
entryTypesManagerback to summary
private final BibEntryTypesManager entryTypesManager
fetcherComboback to summary
private ComboBox<CitationFetcherType> fetcherCombo
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.gui.entryeditor.EntryEditorTab.LOGGER.

preferencesback to summary
private final GuiPreferences preferences
previewTooltipback to summary
private final MainTableTooltip previewTooltip
progressIndicatorback to summary
private final ProgressIndicator progressIndicator
sciteResultsPaneback to summary
private final GridPane sciteResultsPane
searchCitationsRelationsServiceback to summary
private final SearchCitationsRelationsService searchCitationsRelationsService
shouldClearSelectionOnDropback to summary
private boolean shouldClearSelectionOnDrop
stateManagerback to summary
private final StateManager stateManager
taskExecutorback to summary
private final TaskExecutor taskExecutor

Constructor Detail

CitationRelationsTabback to summary
public CitationRelationsTab(DialogService dialogService, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor, GuiPreferences preferences, TaskExecutor taskExecutor, BibEntryTypesManager bibEntryTypesManager, SearchCitationsRelationsService searchCitationsRelationsService)

Method Detail

bindToEntryback to summary
protected void bindToEntry(BibEntry entry)

Implements abstract org.jabref.gui.entryeditor.EntryEditorTab.bindToEntry.

Annotations
@Override
createCitationContextMenuback to summary
private ContextMenu createCitationContextMenu(BibEntry entry, SearchType searchType)

Creates a context menu for citation relation labels with an option to open the API URL in browser

Parameters
entry:BibEntry

the BibEntry to get the API URL for

searchType:SearchType

the type of search (CITES for references, CITED_BY for citations)

Returns:ContextMenu

a ContextMenu with the "Open API URL in browser" option

createCitationSearchTaskback to summary
private org.jabref.logic.util.BackgroundTask<List<CitationRelationItem>> createCitationSearchTask(BibEntry entry, SearchType searchType, boolean bypassCache, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode)
createSearchTaskback to summary
private org.jabref.logic.util.BackgroundTask<List<CitationRelationItem>> createSearchTask(CitationRelationsTab.CitationFetch fetch, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode)

Wraps fetching and duplicate matching into a task whose cancellation checks are bound to that very task. They must not read the mutable per-direction task references instead: those references are reassigned - or set to null - on the JavaFX Application Thread as soon as another entry is selected, so a check evaluated after the fetch returned would either hit null or observe an unrelated, newer task.

executeSearchback to summary
private void executeSearch(CitationComponents citationComponents, boolean bypassCache)
getErrorPaneback to summary
private VBox getErrorPane()
getPaneAndStartSearchback to summary
private SplitPane getPaneAndStartSearch(BibEntry entry)

Method to create main SplitPane holding all lists, buttons and labels for tab and starts search

Parameters
entry:BibEntry

BibEntry which is currently selected in JabRef Database

Returns:SplitPane

SplitPane to display

getSourceStringback to summary
private String getSourceString(BibEntry entry, BibDatabaseMode type, FieldPreferences fieldPreferences, BibEntryTypesManager entryTypesManager) throws IOException

Implementation Note

This code is similar to org.jabref.gui.collab.entrychange.PreviewWithSourceTab.

getTalliesPaneback to summary
private BorderPane getTalliesPane(TalliesResponse tallModel)
getTopBarback to summary
private HBox getTopBar()
handleDragDetectedback to summary
private void handleDragDetected(CheckListView<CitationRelationItem> listView, CitationRelationItem item, MouseEvent event)
handleDragDoneback to summary
private void handleDragDone(CheckListView<CitationRelationItem> listView, DragEvent event)
handleItemClickback to summary
private void handleItemClick(CitationRelationItem item, MouseEvent event, CheckListView<CitationRelationItem> listView, CitationComponents citationComponents)
handleRefreshback to summary
private void handleRefresh(CitationComponents citationComponents, CitationComponents otherCitationComponents)
hideNodesback to summary
private void hideNodes(Node... nodes)
importEntriesback to summary
private void importEntries(List<CitationRelationItem> entriesToImport, SearchType searchType, BibEntry existingEntry)

Function to import selected entries to the database. Also writes the entries to import to the CITING/CITED field

Parameters
entriesToImport:List<CitationRelationItem>

entries to import

initFetcherComboback to summary
private void initFetcherCombo()
jumpToEntryback to summary
private void jumpToEntry(CitationRelationItem entry)
matchAgainstLibraryback to summary
private List<CitationRelationItem> matchAgainstLibrary(List<BibEntry> fetchedList, List<BibEntry> libraryEntries, BibDatabaseMode databaseMode, BooleanSupplier isCancelled)
onDoiLookUpback to summary
private void onDoiLookUp()
onDoiLookUpErrorback to summary
private void onDoiLookUpError()
onDoiMissingback to summary
private void onDoiMissing()
onSciteLookUpback to summary
private void onSciteLookUp()
onSearchForRelationsSucceedback to summary
private void onSearchForRelationsSucceed(CitationComponents citationComponents, List<CitationRelationItem> citationRelationItems, ObservableList<CitationRelationItem> observableList)
openPossibleDuplicateEntriesWindowback to summary
private void openPossibleDuplicateEntriesWindow(CitationRelationItem citationRelationItem, CheckListView<CitationRelationItem> listView)

Function to open possible duplicate entries window to compare duplicate entries

Parameters
citationRelationItem:CitationRelationItem

duplicate in the citation relations tab

listView:CheckListView<CitationRelationItem>

CheckListView to display citations

refreshCurrentEntryAfterDoiLookupback to summary
private void refreshCurrentEntryAfterDoiLookup(BibEntry entry)
resetEmptyPanelsback to summary
private void resetEmptyPanels()
searchForRelationsback to summary
private void searchForRelations(CitationComponents citationComponents, CitationComponents otherCitationComponents, boolean bypassCache)
setLabelOnback to summary
private static void setLabelOn(CheckListView<CitationRelationItem> listView, String message)
setLoadingPlaceholderback to summary
private static void setLoadingPlaceholder(CheckListView<CitationRelationItem> listView)
setSciteResultsPaneback to summary
private void setSciteResultsPane()
setUpEmptyPanelback to summary
private void setUpEmptyPanel(CitationComponents citationComponents, CitationComponents otherCitationComponents)
showEntrySourceDialogback to summary
private void showEntrySourceDialog(BibEntry entry)
showNodesback to summary
private void showNodes(Node... nodes)
snapshotActiveLibraryback to summary
private CitationRelationsTab.LibrarySnapshot snapshotActiveLibrary()

Snapshots the active library on the JavaFX Application Thread, so the background matching task never iterates the live entry list, which the user can modify while the search runs.

Todo

This could be a wrong database, because the user might have switched to another library. Snapshotting when the search is triggered instead of when its result arrives narrows the window, but does not close it - this is still the active library, not the entry's own one. If we were on fixing this, we would need to a) associate a BibEntry with a database or b) pass the database at "bindToEntry".

styleFetchedListViewback to summary
private void styleFetchedListView(CheckListView<CitationRelationItem> listView, CitationComponents citationComponents)

Styles a given CheckListView to display BibEntries either with a hyperlink or an add button. Also adds the handling of mouse clicks.

Parameters
listView:CheckListView<CitationRelationItem>

CheckListView to style

styleLabelback to summary
private void styleLabel(Label label, String tooltipText)

Method to style heading labels

Parameters
label:Label

label to style

tooltipText:String

tooltip text

triggerDoiLookupback to summary
private void triggerDoiLookup()
org.jabref.gui.entryeditor.citationrelationtab back to summary

private Interface CitationRelationsTab.CitationFetch

Annotations
@FunctionalInterface

One of the two citation searches of SearchCitationsRelationsService, parameterized over the cancellation check so that createSearchTask can supply the one belonging to the task it is currently building.

Method Summary

Modifier and TypeMethod and Description
public List<BibEntry>
fetch(BooleanSupplier isCancelled)

Method Detail

fetchback to summary
public List<BibEntry> fetch(BooleanSupplier isCancelled) throws org.jabref.logic.importer.FetcherException
org.jabref.gui.entryeditor.citationrelationtab back to summary

private final Record CitationRelationsTab.LibrarySnapshot

extends Record
Class Inheritance
Record Components
entries:List<BibEntry> 
mode:BibDatabaseMode 

Immutable snapshot of the active library, taken on the JavaFX Application Thread and consumed by the background duplicate matching in matchAgainstLibrary.

Field Summary

Modifier and TypeField and Description
private final List<BibEntry>
entries

Record Component accessed by entries().

private final BibDatabaseMode
mode

Record Component accessed by mode().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public List<BibEntry>
entries()

Record Component getter of entries.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public BibDatabaseMode
mode()

Record Component getter of mode.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

entriesback to summary
private final List<BibEntry> entries

Record Component accessed by entries().

modeback to summary
private final BibDatabaseMode mode

Record Component accessed by mode().

Constructor Detail

LibrarySnapshotback to summary
private LibrarySnapshot(List<BibEntry> entries, BibDatabaseMode mode)

Method Detail

entriesback to summary
public List<BibEntry> entries()

Record Component getter of entries.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

modeback to summary
public BibDatabaseMode mode()

Record Component getter of mode.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.