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

public Class JabRefGuiUndoManager

extends JabRefUndoManager
implements GuiUndoManager
Class Inheritance
All Implemented Interfaces
org.jabref.gui.undo.GuiUndoManager
Annotations
@NullMarked
Imports
javafx.beans.property.ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, org.jabref.gui.util.UiTaskExecutor, org.jabref.logic.undo.JabRefUndoManager, org.jspecify.annotations.NullMarked

The journal, plus the JavaFX properties the menus bind to.

The properties live in jabgui, and the marshalling is the reason: JavaFX properties are just observable values and need no toolkit, but hopping to the JavaFX thread does, and a manager that hops on every push cannot record a change in a plain unit test — it throws "Toolkit not initialized". Only an observer that feeds the UI needs the hop, so it lives with the observer while JabRefUndoManager stays plain Java.

Extends rather than wraps, following JabRefGuiPreferences extends JabRefCliPreferences. Wrapping meant every caller reached through a getUndoManager() accessor to do anything, and meant two objects where the application only ever has one.

Field Summary

Modifier and TypeField and Description
private final ReadOnlyBooleanWrapper
private final ReadOnlyBooleanWrapper
private final ReadOnlyBooleanWrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ReadOnlyBooleanProperty
hasChangedProperty()

Implements org.jabref.gui.undo.GuiUndoManager.hasChangedProperty.

Whether the library differs from the last saved position.

public ReadOnlyBooleanProperty
redoableProperty()

Implements org.jabref.gui.undo.GuiUndoManager.redoableProperty.

Whether there is anything to redo.

private void
refresh()

Reads the stacks on the JavaFX thread rather than where the notification arrived, so that what is written is what the journal holds at the moment of writing.

public ReadOnlyBooleanProperty
undoableProperty()

Implements org.jabref.gui.undo.GuiUndoManager.undoableProperty.

Whether there is anything to undo, for binding menu and toolbar enablement.

Field Detail

changedback to summary
private final ReadOnlyBooleanWrapper changed
redoableback to summary
private final ReadOnlyBooleanWrapper redoable
undoableback to summary
private final ReadOnlyBooleanWrapper undoable

Constructor Detail

JabRefGuiUndoManagerback to summary
public JabRefGuiUndoManager()

Method Detail

hasChangedPropertyback to summary
public ReadOnlyBooleanProperty hasChangedProperty()

Implements org.jabref.gui.undo.GuiUndoManager.hasChangedProperty.

Doc from org.jabref.gui.undo.GuiUndoManager.hasChangedProperty.

Whether the library differs from the last saved position.

Annotations
@Override
redoablePropertyback to summary
public ReadOnlyBooleanProperty redoableProperty()

Implements org.jabref.gui.undo.GuiUndoManager.redoableProperty.

Doc from org.jabref.gui.undo.GuiUndoManager.redoableProperty.

Whether there is anything to redo.

Annotations
@Override
refreshback to summary
private void refresh()

Reads the stacks on the JavaFX thread rather than where the notification arrived, so that what is written is what the journal holds at the moment of writing. Reading first and carrying the values over would let a thread that read an older state post after one that read a newer state, leaving the menu enabled over an empty stack until the next edit.

Applied inline when the edit was already made on the JavaFX thread, so a caller that records a change and then reads the property in the same event does not see the previous value. Deferring unconditionally would leave the menu stale for a pulse.

A burst of edits off the JavaFX thread therefore queues one update per edit, uncoalesced. That costs queue pressure and nothing else: each update reads the current state, so every one after the first sets the value already there, which a JavaFX property ignores without notifying anything. The burst worth worrying about was one push per keystroke, and typing is one step now; a command pushes once, however long it ran.

undoablePropertyback to summary
public ReadOnlyBooleanProperty undoableProperty()

Implements org.jabref.gui.undo.GuiUndoManager.undoableProperty.

Doc from org.jabref.gui.undo.GuiUndoManager.undoableProperty.

Whether there is anything to undo, for binding menu and toolbar enablement.

Annotations
@Override