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

public final Class CompoundEdit

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.util.ArrayList, .Collection, .List, .Optional, org.jabref.model.FieldChange, org.jspecify.annotations.NullMarked

Collects the changes of one user action so they undo as one step.

Usually obtained from org.jabref.logic.undo.UndoManager#addEdit, which owns the recorder's lifetime and pushes what it collected. Constructing one directly is for the commands that cannot use a block: those that collect on a background thread and push on the JavaFX thread, or that abandon the operation part-way through. Those hand org.jabref.logic.undo.UndoManager#addEdit the result of toChangeSet themselves.

The overloads taking FieldChange exist because that is what the model already returns from setField, putKeywords, setCitationKey and friends, so recording a change is a matter of handing the return value over rather than restating it.

Field Summary

Modifier and TypeField and Description
private final List<BibChange>
private final String

Constructor Summary

AccessConstructor and Description
public
CompoundEdit(String
what the user did, as they would recognise it — see ChangeSet. It travels unchanged into the set that toChangeSet builds, so whatever is passed here is what a reader eventually sees.
name
)

Method Summary

Modifier and TypeMethod and Description
public void
addAll(Collection<FieldChange> fieldChanges)

public void
public void
addEdit(Optional<FieldChange> change)

Records a field change if one happened.

public void
public void
addEdit(CompoundEdit nested)

Folds another recorder in as a nested change, so one user action stays one undo step even when a command delegates its collecting.

public ApplyResult

Returns:

what was applied, and what was not — see BibChange#apply
applyEdit
(BibChange change)

Performs change and records it in this step, the recorder's counterpart to org.jabref.logic.undo.UndoManager#applyEdit.

public boolean
public ChangeSet
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changesback to summary
private final List<BibChange> changes
nameback to summary
private final String name

Constructor Detail

CompoundEditback to summary
public CompoundEdit(String name)
Parameters
name:String

what the user did, as they would recognise it — see ChangeSet. It travels unchanged into the set that toChangeSet builds, so whatever is passed here is what a reader eventually sees.

Method Detail

addAllback to summary
public void addAll(Collection<FieldChange> fieldChanges)
addEditback to summary
public void addEdit(BibChange change)
addEditback to summary
public void addEdit(Optional<FieldChange> change)

Records a field change if one happened. An empty Optional means the model rejected the write or the value was unchanged, and nothing is recorded.

addEditback to summary
public void addEdit(FieldChange change)
addEditback to summary
public void addEdit(CompoundEdit nested)

Folds another recorder in as a nested change, so one user action stays one undo step even when a command delegates its collecting.

applyEditback to summary
public ApplyResult applyEdit(BibChange change)

Performs change and records it in this step, the recorder's counterpart to org.jabref.logic.undo.UndoManager#applyEdit. As there, the difference from addEdit(BibChange) is only who performs the change.

No lock, unlike the manager's method: a recorder belongs to the thread running its block, and nothing it collects is reachable from another thread until the block ends.

Returns:ApplyResult

what was applied, and what was not — see BibChange#apply

hasEditsback to summary
public boolean hasEdits()
toChangeSetback to summary
public ChangeSet toChangeSet()