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

public Interface GuiUndoManager

extends UndoManager
Known Direct Implementers
org.jabref.gui.undo.JabRefGuiUndoManager
Annotations
@NullMarked
Imports
java.util.Optional, javafx.beans.property.ReadOnlyBooleanProperty, org.jabref.logic.undo.UndoManager, .UndoStep, org.jspecify.annotations.NullMarked

The undo journal as the GUI needs it: the stacks can be driven, and their state can be observed as JavaFX properties for menu and toolbar enablement.

Layered the way JabRef layers preferences — org.jabref.logic.preferences.CliPreferences to GuiPreferences, JabRefCliPreferences to JabRefGuiPreferences. UndoManager in jablib is the recording half that the ~118 classes editing the library depend on; this adds what only the undo UI needs, so a class's declared type still says what it does with the journal.

The control methods are declared here rather than inherited because an interface cannot inherit from a class: org.jabref.logic.undo.JabRefUndoManager already implements every one of them, and JabRefGuiUndoManager brings the two together.

Method Summary

Modifier and TypeMethod and Description
public void
addListener(Runnable listener)

Notified after every change to either stack, from whichever thread made it.

public boolean
public boolean
public void
clear()

Discards both stacks and the saved position.

public ReadOnlyBooleanProperty
hasChangedProperty()

Whether the library differs from the last saved position.

public boolean
public void
markUnchanged()

Marks the current position as saved.

public Optional<UndoStep>
redo()

Re-applies the change last undone.

public ReadOnlyBooleanProperty
redoableProperty()

Whether there is anything to redo.

public Optional<String>
suspendedBy()

The command currently applying changes to this library that are not yet on the stack, if one is — the reading end of org.jabref.logic.undo.UndoManager#suspendUndo.

public Optional<UndoStep>
undo()

Reverses the change on top of the undo stack.

public ReadOnlyBooleanProperty
undoableProperty()

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

Method Detail

addListenerback to summary
public void addListener(Runnable listener)

Notified after every change to either stack, from whichever thread made it.

canRedoback to summary
public boolean canRedo()
canUndoback to summary
public boolean canUndo()
clearback to summary
public void clear()

Discards both stacks and the saved position.

Nothing calls this today, which is a defect rather than a spare method: closing a library leaves its changes on the stack, so a later undo re-applies them against a database that is gone, and the entries they hold stay alive for the session. Calling it on close needs the journal to belong to a library first — one journal currently serves them all.

hasChangedPropertyback to summary
public ReadOnlyBooleanProperty hasChangedProperty()

Whether the library differs from the last saved position.

isApplyingback to summary
public boolean isApplying()

See org.jabref.logic.undo.JabRefUndoManager#isApplying.

markUnchangedback to summary
public void markUnchanged()

Marks the current position as saved.

redoback to summary
public Optional<UndoStep> redo()

Re-applies the change last undone.

redoablePropertyback to summary
public ReadOnlyBooleanProperty redoableProperty()

Whether there is anything to redo.

suspendedByback to summary
public Optional<String> suspendedBy()

The command currently applying changes to this library that are not yet on the stack, if one is — the reading end of org.jabref.logic.undo.UndoManager#suspendUndo. While it is present, undo and redo decline, and canUndo/canRedo are false for that reason rather than for an empty stack.

undoback to summary
public Optional<UndoStep> undo()

Reverses the change on top of the undo stack.

undoablePropertyback to summary
public ReadOnlyBooleanProperty undoableProperty()

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