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

public Class AutosaveManager

extends Object
Class Inheritance
Imports
java.util.HashSet, .Set, java.util.concurrent.ScheduledThreadPoolExecutor, .TimeUnit, java.util.concurrent.atomic.AtomicBoolean, org.jabref.logic.util.CoarseChangeFilter, org.jabref.model.database.BibDatabaseContext, org.jabref.model.database.event.AutosaveEvent, .BibDatabaseContextChangedEvent, com.google.common.eventbus.EventBus, .Subscribe, org.slf4j.Logger, .LoggerFactory

Saves the given BibDatabaseContext on every BibDatabaseContextChangedEvent by posting a new AutosaveEvent. An intelligent ScheduledThreadPoolExecutor prevents a high load while saving and rejects all redundant save tasks. The scheduled action is stored and canceled if a newer save action is proposed.

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
private final CoarseChangeFilter
private static final int
private final EventBus
private final ScheduledThreadPoolExecutor
private static final Logger
private final AtomicBoolean
private static Set<AutosaveManager>

Constructor Summary

AccessConstructor and Description
private
AutosaveManager(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter)

pack-priv
AutosaveManager(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, ScheduledThreadPoolExecutor executor)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public void
listen(BibDatabaseContextChangedEvent event)

Every change counts, including the keystrokes the filter marks as minor: the filter exists to spare listeners expensive work per keystroke, but a flag is cheap and the timer throttles the saves anyway.

public void
pack-priv synchronized void
public static void
shutdown(BibDatabaseContext bibDatabaseContext)

Shuts down the Autosaver which is associated with the given BibDatabaseContext.

public static AutosaveManager
start(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter)

Starts the Autosaver which is associated with the given BibDatabaseContext.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bibDatabaseContextback to summary
private final BibDatabaseContext bibDatabaseContext
coarseChangeFilterback to summary
private final CoarseChangeFilter coarseChangeFilter
DELAY_BETWEEN_AUTOSAVE_ATTEMPTS_IN_SECONDSback to summary
private static final int DELAY_BETWEEN_AUTOSAVE_ATTEMPTS_IN_SECONDS
eventBusback to summary
private final EventBus eventBus
executorback to summary
private final ScheduledThreadPoolExecutor executor
LOGGERback to summary
private static final Logger LOGGER
needsSaveback to summary
private final AtomicBoolean needsSave
runningInstancesback to summary
private static Set<AutosaveManager> runningInstances

Constructor Detail

AutosaveManagerback to summary
private AutosaveManager(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter)
AutosaveManagerback to summary
pack-priv AutosaveManager(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, ScheduledThreadPoolExecutor executor)

Method Detail

isSavePendingback to summary
pack-priv boolean isSavePending()
listenback to summary
public void listen(BibDatabaseContextChangedEvent event)

Every change counts, including the keystrokes the filter marks as minor: the filter exists to spare listeners expensive work per keystroke, but a flag is cheap and the timer throttles the saves anyway. Ignoring minor changes would leave a field the user only types in unsaved until the user moves to another field.

Annotations
@Subscribe
registerListenerback to summary
public void registerListener(Object listener)
shutdownback to summary
pack-priv synchronized void shutdown()
shutdownback to summary
public static void shutdown(BibDatabaseContext bibDatabaseContext)

Shuts down the Autosaver which is associated with the given BibDatabaseContext.

Parameters
bibDatabaseContext:BibDatabaseContext

Associated BibDatabaseContext

startback to summary
public static AutosaveManager start(BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter)

Starts the Autosaver which is associated with the given BibDatabaseContext. impl->req~jabgui.autosaveandbackup.autosave-listens~1

Parameters
bibDatabaseContext:BibDatabaseContext

Associated BibDatabaseContext

unregisterListenerback to summary
public void unregisterListener(Object listener)