Package org.fxmisc.undo.impl
Class UndoManagerImpl<C>
java.lang.Object
org.fxmisc.undo.impl.UndoManagerImpl<C>
- Type Parameters:
C- the type of change to undo/redo
- All Implemented Interfaces:
UndoManager<C>
- Direct Known Subclasses:
MultiChangeUndoManagerImpl
Implementation for
UndoManager for single changes. For multiple changes, see
MultiChangeUndoManagerImpl.-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.value.ObservableBooleanValueIndicates whether this UndoManager's current position within its history is the same as the last marked position.org.reactfx.value.Val<C> Gives a peek at the change that will be redone byUndoManager.redo().org.reactfx.value.Val<C> Gives a peek at the change that will be undone byUndoManager.undo().javafx.beans.value.ObservableBooleanValueIndicates whether this undo manager is currently performing undo or redo action.org.reactfx.value.Val<Boolean> Indicates whether there is a change that can be redone.org.reactfx.value.Val<Boolean> Indicates whether there is a change that can be undone. -
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.fxmisc.undo.UndoManager
UndoManager.UndoPosition -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final javafx.beans.binding.BooleanBindingprivate booleanprivate Cprivate final org.reactfx.EventSource<Void> private ChangeQueue.QueuePositionprivate final BiFunction<C, C, Optional<C>> private final org.reactfx.value.Val<C> private final org.reactfx.value.Val<C> private final org.reactfx.SuspendableNoprivate final ChangeQueue<C> private final org.reactfx.Subscription -
Constructor Summary
ConstructorsConstructorDescriptionUndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, org.reactfx.EventStream<C> changeSource) UndoManagerImpl(ChangeQueue<C> queue, Function<? super C, ? extends C> invert, Consumer<C> apply, BiFunction<C, C, Optional<C>> merge, Predicate<C> isIdentity, org.reactfx.EventStream<C> changeSource, Duration preventMergeDelay) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate booleanapplyChange(boolean isChangeAvailable, Supplier<C> changeToApply) Helper method for reducing code duplicationjavafx.beans.value.ObservableBooleanValueIndicates whether this UndoManager's current position within its history is the same as the last marked position.private voidchangeObserved(C change) voidclose()Stops observing change events.voidForgets all changes prior to the current position in the history.Returns the current position within this UndoManager's history.private voidbooleanbooleanbooleanbooleanorg.reactfx.value.Val<C> Gives a peek at the change that will be redone byUndoManager.redo().org.reactfx.value.Val<C> Gives a peek at the change that will be undone byUndoManager.undo().javafx.beans.value.ObservableBooleanValueIndicates whether this undo manager is currently performing undo or redo action.voidPrevents the next change from being merged with the latest one.booleanredo()Redo previously undone change, if there is any change to redo.org.reactfx.value.Val<Boolean> Indicates whether there is a change that can be redone.booleanundo()Undo the most recent change, if there is any change to undo.org.reactfx.value.Val<Boolean> Indicates whether there is a change that can be undone.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.fxmisc.undo.UndoManager
getNextRedo, getNextUndo, mark
-
Property Details
-
nextUndo
- Specified by:
nextUndoPropertyin interfaceUndoManager<C>- Returns:
- the
nextUndoproperty - See Also:
-
nextRedo
- Specified by:
nextRedoPropertyin interfaceUndoManager<C>- Returns:
- the
nextRedoproperty - See Also:
-
undoAvailable
- Specified by:
undoAvailablePropertyin interfaceUndoManager<C>- Returns:
- the
undoAvailableproperty - See Also:
-
redoAvailable
- Specified by:
redoAvailablePropertyin interfaceUndoManager<C>- Returns:
- the
redoAvailableproperty - See Also:
-
performingAction
public javafx.beans.value.ObservableBooleanValue performingActionProperty- Specified by:
performingActionPropertyin interfaceUndoManager<C>- Returns:
- the
performingActionproperty - See Also:
-
atMarkedPosition
public javafx.beans.value.ObservableBooleanValue atMarkedPositionProperty- Specified by:
atMarkedPositionPropertyin interfaceUndoManager<C>- Returns:
- the
atMarkedPositionproperty - See Also:
-
-
Field Details
-
queue
-
invert
-
apply
-
merge
-
isIdentity
-
subscription
private final org.reactfx.Subscription subscription -
performingAction
private final org.reactfx.SuspendableNo performingAction -
invalidationRequests
-
nextUndo
-
nextRedo
-
atMarkedPosition
private final javafx.beans.binding.BooleanBinding atMarkedPosition -
canMerge
private boolean canMerge -
mark
-
expectedChange
-
-
Constructor Details
-
UndoManagerImpl
-
UndoManagerImpl
-
-
Method Details
-
close
public void close()Description copied from interface:UndoManagerStops observing change events.- Specified by:
closein interfaceUndoManager<C>
-
undo
public boolean undo()Description copied from interface:UndoManagerUndo the most recent change, if there is any change to undo.- Specified by:
undoin interfaceUndoManager<C>- Returns:
trueif a change was undone,falseotherwise.
-
redo
public boolean redo()Description copied from interface:UndoManagerRedo previously undone change, if there is any change to redo.- Specified by:
redoin interfaceUndoManager<C>- Returns:
trueif a change was redone,falseotherwise.
-
nextUndoProperty
Description copied from interface:UndoManagerGives a peek at the change that will be undone byUndoManager.undo().- Specified by:
nextUndoPropertyin interfaceUndoManager<C>- Returns:
- the
nextUndoproperty - See Also:
-
nextRedoProperty
Description copied from interface:UndoManagerGives a peek at the change that will be redone byUndoManager.redo().- Specified by:
nextRedoPropertyin interfaceUndoManager<C>- Returns:
- the
nextRedoproperty - See Also:
-
isUndoAvailable
public boolean isUndoAvailable()- Specified by:
isUndoAvailablein interfaceUndoManager<C>
-
undoAvailableProperty
Description copied from interface:UndoManagerIndicates whether there is a change that can be undone.- Specified by:
undoAvailablePropertyin interfaceUndoManager<C>- Returns:
- the
undoAvailableproperty
-
isRedoAvailable
public boolean isRedoAvailable()- Specified by:
isRedoAvailablein interfaceUndoManager<C>
-
redoAvailableProperty
Description copied from interface:UndoManagerIndicates whether there is a change that can be redone.- Specified by:
redoAvailablePropertyin interfaceUndoManager<C>- Returns:
- the
redoAvailableproperty
-
isPerformingAction
public boolean isPerformingAction()- Specified by:
isPerformingActionin interfaceUndoManager<C>
-
performingActionProperty
public javafx.beans.value.ObservableBooleanValue performingActionProperty()Description copied from interface:UndoManagerIndicates whether this undo manager is currently performing undo or redo action.- Specified by:
performingActionPropertyin interfaceUndoManager<C>- Returns:
- the
performingActionproperty
-
isAtMarkedPosition
public boolean isAtMarkedPosition()- Specified by:
isAtMarkedPositionin interfaceUndoManager<C>
-
atMarkedPositionProperty
public javafx.beans.value.ObservableBooleanValue atMarkedPositionProperty()Description copied from interface:UndoManagerIndicates whether this UndoManager's current position within its history is the same as the last marked position.- Specified by:
atMarkedPositionPropertyin interfaceUndoManager<C>- Returns:
- the
atMarkedPositionproperty
-
getCurrentPosition
Description copied from interface:UndoManagerReturns the current position within this UndoManager's history.- Specified by:
getCurrentPositionin interfaceUndoManager<C>
-
preventMerge
public void preventMerge()Description copied from interface:UndoManagerPrevents the next change from being merged with the latest one.- Specified by:
preventMergein interfaceUndoManager<C>
-
forgetHistory
public void forgetHistory()Description copied from interface:UndoManagerForgets all changes prior to the current position in the history.- Specified by:
forgetHistoryin interfaceUndoManager<C>
-
applyChange
Helper method for reducing code duplication- Parameters:
isChangeAvailable- same as `isUndoAvailable()` [Undo] or `isRedoAvailable()` [Redo]changeToApply- same as `invert.apply(queue.prev())` [Undo] or `queue.next()` [Redo]
-
changeObserved
-
addChange
-
invalidateProperties
private void invalidateProperties()
-