Top Description Inners Fields Constructors Methods
org.fxmisc.undo.impl

public Class UndoManagerImpl<C>

extends Object
implements UndoManager<C>
Class Inheritance
All Implemented Interfaces
org.fxmisc.undo.UndoManager
Known Direct Subclasses
org.fxmisc.undo.impl.MultiChangeUndoManagerImpl
Type Parameters
<C>
the type of change to undo/redo
Imports
java.time.Duration, java.util.Optional, java.util.function.BiFunction, .Consumer, .Function, .Predicate, .Supplier, javafx.beans.binding.BooleanBinding, javafx.beans.value.ObservableBooleanValue, org.fxmisc.undo.UndoManager, org.fxmisc.undo.impl.ChangeQueue.QueuePosition, org.reactfx.EventSource, .EventStream, .Subscription, .SuspendableNo, org.reactfx.value.Val, .ValBase

Implementation for UndoManager for single changes. For multiple changes, see MultiChangeUndoManagerImpl.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Consumer<C>
private final BooleanBinding
private boolean
private C
private final EventSource<Void>
private final Function<? super C, ? extends C>
private final Predicate<C>
private ChangeQueue.QueuePosition
private final BiFunction<C, C, Optional<C>>
private final Val<C>
private final Val<C>
private final SuspendableNo
private final ChangeQueue<C>
private final Subscription

Constructor Summary

AccessConstructor and Description
public
UndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, EventStream<C> changeSource)

public
UndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, EventStream<C> changeSource, Duration preventMergeDelay)

Method Summary

Modifier and TypeMethod and Description
private void
addChange(C change)

private boolean
applyChange(boolean
same as `isUndoAvailable()` [Undo] or `isRedoAvailable()` [Redo]
isChangeAvailable
,
Supplier<C>
same as `invert.apply(queue.prev())` [Undo] or `queue.next()` [Redo]
changeToApply
)

Helper method for reducing code duplication

public ObservableBooleanValue
atMarkedPositionProperty()

Implements org.fxmisc.undo.UndoManager.atMarkedPositionProperty.

Indicates whether this UndoManager's current position within its history is the same as the last marked position.

private void
changeObserved(C change)

public void
close()

Implements org.fxmisc.undo.UndoManager.close.

Stops observing change events.

public void
forgetHistory()

Implements org.fxmisc.undo.UndoManager.forgetHistory.

Forgets all changes prior to the current position in the history.

public UndoManager.UndoPosition
getCurrentPosition()

Implements org.fxmisc.undo.UndoManager.getCurrentPosition.

Returns the current position within this UndoManager's history.

private void
public boolean
public boolean
public boolean
public boolean
public Val<C>
nextRedoProperty()

Implements org.fxmisc.undo.UndoManager.nextRedoProperty.

Gives a peek at the change that will be redone by redo().

public Val<C>
nextUndoProperty()

Implements org.fxmisc.undo.UndoManager.nextUndoProperty.

Gives a peek at the change that will be undone by undo().

public ObservableBooleanValue
performingActionProperty()

Implements org.fxmisc.undo.UndoManager.performingActionProperty.

Indicates whether this undo manager is currently performing undo or redo action.

public void
preventMerge()

Implements org.fxmisc.undo.UndoManager.preventMerge.

Prevents the next change from being merged with the latest one.

public boolean
redo()

Implements org.fxmisc.undo.UndoManager.redo.

Redo previously undone change, if there is any change to redo.

public Val<Boolean>
redoAvailableProperty()

Implements org.fxmisc.undo.UndoManager.redoAvailableProperty.

Indicates whether there is a change that can be redone.

public boolean
undo()

Implements org.fxmisc.undo.UndoManager.undo.

Undo the most recent change, if there is any change to undo.

public Val<Boolean>
undoAvailableProperty()

Implements org.fxmisc.undo.UndoManager.undoAvailableProperty.

Indicates whether there is a change that can be undone.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applyback to summary
private final Consumer<C> apply
atMarkedPositionback to summary
private final BooleanBinding atMarkedPosition
canMergeback to summary
private boolean canMerge
expectedChangeback to summary
private C expectedChange
invalidationRequestsback to summary
private final EventSource<Void> invalidationRequests
invertback to summary
private final Function<? super C, ? extends C> invert
isIdentityback to summary
private final Predicate<C> isIdentity
markback to summary
private ChangeQueue.QueuePosition mark
mergeback to summary
private final BiFunction<C, C, Optional<C>> merge
nextRedoback to summary
private final Val<C> nextRedo
nextUndoback to summary
private final Val<C> nextUndo
performingActionback to summary
private final SuspendableNo performingAction
queueback to summary
private final ChangeQueue<C> queue
subscriptionback to summary
private final Subscription subscription

Constructor Detail

UndoManagerImplback to summary
public UndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, EventStream<C> changeSource)
UndoManagerImplback to summary
public UndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, EventStream<C> changeSource, Duration preventMergeDelay)

Method Detail

addChangeback to summary
private void addChange(C change)
Annotations
@SuppressWarnings:unchecked
applyChangeback to summary
private boolean applyChange(boolean isChangeAvailable, Supplier<C> changeToApply)

Helper method for reducing code duplication

Parameters
isChangeAvailable:boolean

same as `isUndoAvailable()` [Undo] or `isRedoAvailable()` [Redo]

changeToApply:Supplier<C>

same as `invert.apply(queue.prev())` [Undo] or `queue.next()` [Redo]

atMarkedPositionPropertyback to summary
public ObservableBooleanValue atMarkedPositionProperty()

Implements org.fxmisc.undo.UndoManager.atMarkedPositionProperty.

Doc from org.fxmisc.undo.UndoManager.atMarkedPositionProperty.

Indicates whether this UndoManager's current position within its history is the same as the last marked position.

Annotations
@Override
changeObservedback to summary
private void changeObserved(C change)
closeback to summary
public void close()

Implements org.fxmisc.undo.UndoManager.close.

Doc from org.fxmisc.undo.UndoManager.close.

Stops observing change events.

Annotations
@Override
forgetHistoryback to summary
public void forgetHistory()

Implements org.fxmisc.undo.UndoManager.forgetHistory.

Doc from org.fxmisc.undo.UndoManager.forgetHistory.

Forgets all changes prior to the current position in the history.

Annotations
@Override
getCurrentPositionback to summary
public UndoManager.UndoPosition getCurrentPosition()

Implements org.fxmisc.undo.UndoManager.getCurrentPosition.

Doc from org.fxmisc.undo.UndoManager.getCurrentPosition.

Returns the current position within this UndoManager's history.

Annotations
@Override
invalidatePropertiesback to summary
private void invalidateProperties()
isAtMarkedPositionback to summary
public boolean isAtMarkedPosition()

Implements org.fxmisc.undo.UndoManager.isAtMarkedPosition.

Annotations
@Override
isPerformingActionback to summary
public boolean isPerformingAction()

Implements org.fxmisc.undo.UndoManager.isPerformingAction.

Annotations
@Override
isRedoAvailableback to summary
public boolean isRedoAvailable()

Implements org.fxmisc.undo.UndoManager.isRedoAvailable.

Annotations
@Override
isUndoAvailableback to summary
public boolean isUndoAvailable()

Implements org.fxmisc.undo.UndoManager.isUndoAvailable.

Annotations
@Override
nextRedoPropertyback to summary
public Val<C> nextRedoProperty()

Implements org.fxmisc.undo.UndoManager.nextRedoProperty.

Doc from org.fxmisc.undo.UndoManager.nextRedoProperty.

Gives a peek at the change that will be redone by redo().

Annotations
@Override
nextUndoPropertyback to summary
public Val<C> nextUndoProperty()

Implements org.fxmisc.undo.UndoManager.nextUndoProperty.

Doc from org.fxmisc.undo.UndoManager.nextUndoProperty.

Gives a peek at the change that will be undone by undo().

Annotations
@Override
performingActionPropertyback to summary
public ObservableBooleanValue performingActionProperty()

Implements org.fxmisc.undo.UndoManager.performingActionProperty.

Doc from org.fxmisc.undo.UndoManager.performingActionProperty.

Indicates whether this undo manager is currently performing undo or redo action.

Annotations
@Override
preventMergeback to summary
public void preventMerge()

Implements org.fxmisc.undo.UndoManager.preventMerge.

Doc from org.fxmisc.undo.UndoManager.preventMerge.

Prevents the next change from being merged with the latest one.

Annotations
@Override
redoback to summary
public boolean redo()

Implements org.fxmisc.undo.UndoManager.redo.

Doc from org.fxmisc.undo.UndoManager.redo.

Redo previously undone change, if there is any change to redo.

Annotations
@Override
redoAvailablePropertyback to summary
public Val<Boolean> redoAvailableProperty()

Implements org.fxmisc.undo.UndoManager.redoAvailableProperty.

Doc from org.fxmisc.undo.UndoManager.redoAvailableProperty.

Indicates whether there is a change that can be redone.

Annotations
@Override
undoback to summary
public boolean undo()

Implements org.fxmisc.undo.UndoManager.undo.

Doc from org.fxmisc.undo.UndoManager.undo.

Undo the most recent change, if there is any change to undo.

Annotations
@Override
undoAvailablePropertyback to summary
public Val<Boolean> undoAvailableProperty()

Implements org.fxmisc.undo.UndoManager.undoAvailableProperty.

Doc from org.fxmisc.undo.UndoManager.undoAvailableProperty.

Indicates whether there is a change that can be undone.

Annotations
@Override
org.fxmisc.undo.impl back to summary

private Class UndoManagerImpl.UndoPositionImpl

extends Object
implements UndoPosition
Class Inheritance
All Implemented Interfaces
org.fxmisc.undo.UndoManager.UndoPosition

Field Summary

Modifier and TypeField and Description
private final ChangeQueue.QueuePosition

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
isValid()

Implements org.fxmisc.undo.UndoManager.UndoPosition.isValid.

Checks whether this history position is still valid.

public void
mark()

Implements org.fxmisc.undo.UndoManager.UndoPosition.mark.

Sets the mark of the underlying UndoManager at this position.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

queuePosback to summary
private final ChangeQueue.QueuePosition queuePos

Constructor Detail

UndoPositionImplback to summary
pack-priv UndoPositionImpl(ChangeQueue.QueuePosition queuePos)

Method Detail

isValidback to summary
public boolean isValid()

Implements org.fxmisc.undo.UndoManager.UndoPosition.isValid.

Doc from org.fxmisc.undo.UndoManager.UndoPosition.isValid.

Checks whether this history position is still valid. A position becomes invalid when

  • the change immediately preceding the position is undone and then discarded due to another incoming change; or
  • the change immediately following the position is forgotten due to history size limit.
Annotations
@Override
markback to summary
public void mark()

Implements org.fxmisc.undo.UndoManager.UndoPosition.mark.

Doc from org.fxmisc.undo.UndoManager.UndoPosition.mark.

Sets the mark of the underlying UndoManager at this position. The mark is set whether or not this position is valid. It is OK for an UndoManager to be marked at an invalid position.

Annotations
@Override