Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.externalfiles

public Class EntryImportHandlerTracker

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.util.ArrayList, .List, org.jabref.gui.StateManager, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, org.jspecify.annotations.NullMarked, .Nullable

Tracks the import state

SIDE EFFECTS:

  1. Calls onFinish in case all entries have been imported (based on the given totalEntries count)
  2. Selects the imported entries after importing

Imports run concurrently: ImportHandler schedules one BackgroundTask chain per entry, so markImported/markSkipped are invoked from different threads. The mutating methods are therefore synchronized so that the counter update, list append, completion check, and onFinish execution happen atomically. This guarantees onFinish runs exactly once and only after every imported entry is visible in importedEntries.

Field Summary

Modifier and TypeField and Description
private boolean
private int
private final List<BibEntry>
private @Nullable Runnable
private int
private final StateManager
private final BibDatabaseContext
private final int

Constructor Summary

AccessConstructor and Description
public
EntryImportHandlerTracker(StateManager stateManager, BibDatabaseContext targetDatabaseContext)

public
EntryImportHandlerTracker(StateManager stateManager, BibDatabaseContext targetDatabaseContext, int totalEntries)

Method Summary

Modifier and TypeMethod and Description
private void
checkDone()

Checks if all entries have been processed; if yes, execute the onFinish action exactly once.

public synchronized int
public synchronized List<BibEntry>
getImportedEntries()

Returns an immutable snapshot of the actually imported BibEntry instances (the copies inserted into the database), not the originals passed to the import call.

public synchronized int
public synchronized void
markImported(BibEntry entry)

Marks the given entry as imported

public synchronized void
private void
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

finishedback to summary
private boolean finished
importedback to summary
private int imported
importedEntriesback to summary
private final List<BibEntry> importedEntries
onFinishback to summary
private @Nullable Runnable onFinish
skippedback to summary
private int skipped
stateManagerback to summary
private final StateManager stateManager
targetDatabaseContextback to summary
private final BibDatabaseContext targetDatabaseContext
totalEntriesback to summary
private final int totalEntries

Constructor Detail

EntryImportHandlerTrackerback to summary
public EntryImportHandlerTracker(StateManager stateManager, BibDatabaseContext targetDatabaseContext)
EntryImportHandlerTrackerback to summary
public EntryImportHandlerTracker(StateManager stateManager, BibDatabaseContext targetDatabaseContext, int totalEntries)

Method Detail

checkDoneback to summary
private void checkDone()

Checks if all entries have been processed; if yes, execute the onFinish action exactly once. Must be called while holding this object's monitor (i.e. from a synchronized method).

getImportedCountback to summary
public synchronized int getImportedCount()
getImportedEntriesback to summary
public synchronized List<BibEntry> getImportedEntries()

Returns an immutable snapshot of the actually imported BibEntry instances (the copies inserted into the database), not the originals passed to the import call.

getSkippedCountback to summary
public synchronized int getSkippedCount()
markImportedback to summary
public synchronized void markImported(BibEntry entry)

Marks the given entry as imported

markSkippedback to summary
public synchronized void markSkipped()
selectImportedEntriesInActiveTabback to summary
private void selectImportedEntriesInActiveTab(List<BibEntry> importedEntriesSnapshot)
setOnFinishback to summary
public synchronized void setOnFinish(@Nullable Runnable onFinish)