Verified Owner
Top Fields Constructors Methods
org.jabref.gui.entryeditor

public Class EntryEditorViewModel

extends AbstractViewModel
Class Inheritance
Imports
java.util.ArrayList, .List, .Optional, .SortedSet, java.util.function.Supplier, javafx.beans.InvalidationListener, javafx.beans.property.ObjectProperty, .ReadOnlyStringProperty, .SimpleObjectProperty, .SimpleStringProperty, javafx.beans.value.ObservableValue, javafx.collections.FXCollections, .ObservableList, javafx.scene.control.Tab, org.jabref.gui.AbstractViewModel, .DialogService, .LibraryTab, .StateManager, org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction, org.jabref.gui.cleanup.CleanupSingleAction, org.jabref.gui.importer.GrobidUseDialogHelper, org.jabref.gui.mergeentries.FetchAndMergeEntry, org.jabref.gui.preferences.GuiPreferences, org.jabref.logic.bibtex.TypedBibEntry, org.jabref.logic.importer.EntryBasedFetcher, .WebFetchers, org.jabref.logic.importer.fileformat.pdf.PdfMergeMetadataImporter, org.jabref.logic.journals.JournalAbbreviationRepository, org.jabref.logic.util.TaskExecutor, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jabref.model.entry.types.EntryType, com.tobiasdiez.easybind.EasyBind, com.tobiasdiez.easybind.Subscription, org.jspecify.annotations.Nullable

Field Summary

Modifier and TypeField and Description
private final List<EntryEditorTab>
allPossibleTabs

Every tab that can possibly be shown for the current entry, in display order.

private final ObjectProperty<@Nullable EntryType>
currentEntryType

The current entry's type, updated by the single typeSubscription.

private final ObjectProperty<@Nullable BibEntry>
private final DialogService
private final JournalAbbreviationRepository
private final GuiPreferences
private final List<com.tobiasdiez.easybind.Subscription>
shouldShowSubscriptions

One subscription per tab, observing its EntryEditorTab#visibility().

private @Nullable SourceTab
private final StateManager
private final EntryEditorTabFactory
private final Supplier<LibraryTab>
private final TaskExecutor
private final SimpleStringProperty
typeLabelText

Display name of the current entry's type — the single source for the entry editor's type label.

private @Nullable com.tobiasdiez.easybind.Subscription
typeSubscription

Single subscription to the current entry's typeProperty; feeds both the type label and currentEntryType.

private final ObservableList<Tab>
unmodifiableVisibleTabs

Read-only view handed to the editor for Bindings.bindContent.

private final ObservableList<Tab>
visibleTabs

The subset of allPossibleTabs currently shown — mutated incrementally so a bound TabPane replays adds/removes one by one (a full replace causes an ugly shift-in animation).

Constructor Summary

AccessConstructor and Description
public
EntryEditorViewModel(StateManager stateManager, GuiPreferences preferences, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationRepository journalAbbreviationRepository, Supplier<LibraryTab> tabSupplier, EntryEditorTabFactory tabFactory)

Method Summary

Modifier and TypeMethod and Description
private BibDatabaseContext
public void
public void
clearTabs()

Tears down the tab state when no entry is being edited (e.g. the last library was closed).

public ObservableValue<@Nullable EntryType>
currentEntryTypeProperty()

The current entry's type, exposed so the editor can rebuild its toolbar when the type changes.

public ObjectProperty<@Nullable BibEntry>
public void
private void
disposeTabs()

Unsubscribes the visibility listeners and unbinds each tab's entry property before the old tab instances are dropped, so discarded tabs are not kept alive by the binding to currentlyEditedEntry.

public void
fetchAndMerge(EntryBasedFetcher fetcher)

Fetches and merges bibliographic data for the current entry from the given fetcher.

public void
public List<EntryEditorTab>
getAllPossibleTabs()

All tabs that can possibly be shown for the current entry (regardless of visibility), in display order.

public @Nullable BibEntry
public SortedSet<EntryBasedFetcher>
getEntryBasedFetchers()

Entry-based fetchers available for the active library; used to populate the "fetch and merge" menu.

public Optional<SourceTab>
preferredInitialTab()

The tab the editor should select when it (re)binds to an entry: the Source tab when the user opted into "show source by default", otherwise empty (the editor keeps the current selection).

private void
rebindToEntryType(@Nullable BibEntry entry)

(Re)subscribes the single listener on the current entry's type, driving both the type label and the currentEntryType property that the editor observes.

public void
rebuildTabs()

Recreates every possible tab and re-renders the visible set.

private void
refreshVisibleTabs()

Adds/removes incrementally instead of replacing the whole list, to preserve order without triggering the TabPane's shift-in animation on a full replace.

public ReadOnlyStringProperty
private void
public ObservableList<Tab>
visibleTabs()

Live, ordered list of the tabs that should currently be shown for the edited entry.

Field Detail

allPossibleTabsback to summary
private final List<EntryEditorTab> allPossibleTabs

Every tab that can possibly be shown for the current entry, in display order.

currentEntryTypeback to summary
private final ObjectProperty<@Nullable EntryType> currentEntryType

The current entry's type, updated by the single typeSubscription. The editor observes this to rebuild its toolbar, so there is no second listener on the entry's typeProperty.

currentlyEditedEntryback to summary
private final ObjectProperty<@Nullable BibEntry> currentlyEditedEntry
dialogServiceback to summary
private final DialogService dialogService
journalAbbreviationRepositoryback to summary
private final JournalAbbreviationRepository journalAbbreviationRepository
preferencesback to summary
private final GuiPreferences preferences
shouldShowSubscriptionsback to summary
private final List<com.tobiasdiez.easybind.Subscription> shouldShowSubscriptions

One subscription per tab, observing its EntryEditorTab#visibility().

sourceTabback to summary
private @Nullable SourceTab sourceTab
stateManagerback to summary
private final StateManager stateManager
tabFactoryback to summary
private final EntryEditorTabFactory tabFactory
tabSupplierback to summary
private final Supplier<LibraryTab> tabSupplier
taskExecutorback to summary
private final TaskExecutor taskExecutor
typeLabelTextback to summary
private final SimpleStringProperty typeLabelText

Display name of the current entry's type — the single source for the entry editor's type label.

typeSubscriptionback to summary
private @Nullable com.tobiasdiez.easybind.Subscription typeSubscription

Single subscription to the current entry's typeProperty; feeds both the type label and currentEntryType.

unmodifiableVisibleTabsback to summary
private final ObservableList<Tab> unmodifiableVisibleTabs

Read-only view handed to the editor for Bindings.bindContent. Held in a field on purpose: the unmodifiable wrapper keeps only a weak listener on visibleTabs, so it must stay strongly referenced or a GC silently kills the content binding (the TabPane would stop updating).

visibleTabsback to summary
private final ObservableList<Tab> visibleTabs

The subset of allPossibleTabs currently shown — mutated incrementally so a bound TabPane replays adds/removes one by one (a full replace causes an ugly shift-in animation).

Constructor Detail

EntryEditorViewModelback to summary
public EntryEditorViewModel(StateManager stateManager, GuiPreferences preferences, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationRepository journalAbbreviationRepository, Supplier<LibraryTab> tabSupplier, EntryEditorTabFactory tabFactory)

Method Detail

activeDatabaseContextback to summary
private BibDatabaseContext activeDatabaseContext()
cleanupback to summary
public void cleanup()
clearTabsback to summary
public void clearTabs()

Tears down the tab state when no entry is being edited (e.g. the last library was closed).

currentEntryTypePropertyback to summary
public ObservableValue<@Nullable EntryType> currentEntryTypeProperty()

The current entry's type, exposed so the editor can rebuild its toolbar when the type changes. Backed by the single typeSubscription shared with the type label — no duplicate listener on the entry.

currentlyEditedEntryPropertyback to summary
public ObjectProperty<@Nullable BibEntry> currentlyEditedEntryProperty()
deleteEntryback to summary
public void deleteEntry()
disposeTabsback to summary
private void disposeTabs()

Unsubscribes the visibility listeners and unbinds each tab's entry property before the old tab instances are dropped, so discarded tabs are not kept alive by the binding to currentlyEditedEntry.

fetchAndMergeback to summary
public void fetchAndMerge(EntryBasedFetcher fetcher)

Fetches and merges bibliographic data for the current entry from the given fetcher. The PDF-metadata fetcher first resolves the Grobid opt-in with the user — that policy lives here, not in the editor.

generateCiteKeyback to summary
public void generateCiteKey()
getAllPossibleTabsback to summary
public List<EntryEditorTab> getAllPossibleTabs()

All tabs that can possibly be shown for the current entry (regardless of visibility), in display order.

getCurrentlyEditedEntryback to summary
public @Nullable BibEntry getCurrentlyEditedEntry()
getEntryBasedFetchersback to summary
public SortedSet<EntryBasedFetcher> getEntryBasedFetchers()

Entry-based fetchers available for the active library; used to populate the "fetch and merge" menu.

preferredInitialTabback to summary
public Optional<SourceTab> preferredInitialTab()

The tab the editor should select when it (re)binds to an entry: the Source tab when the user opted into "show source by default", otherwise empty (the editor keeps the current selection). The policy lives here, not in the view.

rebindToEntryTypeback to summary
private void rebindToEntryType(@Nullable BibEntry entry)

(Re)subscribes the single listener on the current entry's type, driving both the type label and the currentEntryType property that the editor observes.

rebuildTabsback to summary
public void rebuildTabs()

Recreates every possible tab and re-renders the visible set. Called by the View when the active library tab changes, and internally when the configured tab models change.

refreshVisibleTabsback to summary
private void refreshVisibleTabs()

Adds/removes incrementally instead of replacing the whole list, to preserve order without triggering the TabPane's shift-in animation on a full replace.

typeLabelTextPropertyback to summary
public ReadOnlyStringProperty typeLabelTextProperty()
updateTypeLabelTextback to summary
private void updateTypeLabelText()
visibleTabsback to summary
public ObservableList<Tab> visibleTabs()

Live, ordered list of the tabs that should currently be shown for the edited entry. The EntryEditor binds its TabPane to this; it is mutated incrementally to avoid a full replace.