Class UndoManagerImpl<C>

    • Field Detail

      • invert

        private final java.util.function.Function<? super C,​? extends C> invert
      • apply

        private final java.util.function.Consumer<C> apply
      • merge

        private final java.util.function.BiFunction<C,​C,​java.util.Optional<C>> merge
      • isIdentity

        private final java.util.function.Predicate<C> isIdentity
      • subscription

        private final org.reactfx.Subscription subscription
      • performingAction

        private final org.reactfx.SuspendableNo performingAction
      • invalidationRequests

        private final org.reactfx.EventSource<java.lang.Void> invalidationRequests
      • nextUndo

        private final org.reactfx.value.Val<C> nextUndo
      • nextRedo

        private final org.reactfx.value.Val<C> nextRedo
      • atMarkedPosition

        private final javafx.beans.binding.BooleanBinding atMarkedPosition
      • canMerge

        private boolean canMerge
      • expectedChange

        private C expectedChange
    • Constructor Detail

      • UndoManagerImpl

        public UndoManagerImpl​(ChangeQueue<C> queue,
                               java.util.function.Function<? super C,​? extends C> invert,
                               java.util.function.Consumer<C> apply,
                               java.util.function.BiFunction<C,​C,​java.util.Optional<C>> merge,
                               java.util.function.Predicate<C> isIdentity,
                               org.reactfx.EventStream<C> changeSource)
      • UndoManagerImpl

        public UndoManagerImpl​(ChangeQueue<C> queue,
                               java.util.function.Function<? super C,​? extends C> invert,
                               java.util.function.Consumer<C> apply,
                               java.util.function.BiFunction<C,​C,​java.util.Optional<C>> merge,
                               java.util.function.Predicate<C> isIdentity,
                               org.reactfx.EventStream<C> changeSource,
                               java.time.Duration preventMergeDelay)
    • Method Detail

      • close

        public void close()
        Description copied from interface: UndoManager
        Stops observing change events.
        Specified by:
        close in interface UndoManager<C>
      • undo

        public boolean undo()
        Description copied from interface: UndoManager
        Undo the most recent change, if there is any change to undo.
        Specified by:
        undo in interface UndoManager<C>
        Returns:
        true if a change was undone, false otherwise.
      • redo

        public boolean redo()
        Description copied from interface: UndoManager
        Redo previously undone change, if there is any change to redo.
        Specified by:
        redo in interface UndoManager<C>
        Returns:
        true if a change was redone, false otherwise.
      • undoAvailableProperty

        public org.reactfx.value.Val<java.lang.Boolean> undoAvailableProperty()
        Description copied from interface: UndoManager
        Indicates whether there is a change that can be undone.
        Specified by:
        undoAvailableProperty in interface UndoManager<C>
      • redoAvailableProperty

        public org.reactfx.value.Val<java.lang.Boolean> redoAvailableProperty()
        Description copied from interface: UndoManager
        Indicates whether there is a change that can be redone.
        Specified by:
        redoAvailableProperty in interface UndoManager<C>
      • performingActionProperty

        public javafx.beans.value.ObservableBooleanValue performingActionProperty()
        Description copied from interface: UndoManager
        Indicates whether this undo manager is currently performing undo or redo action.
        Specified by:
        performingActionProperty in interface UndoManager<C>
      • atMarkedPositionProperty

        public javafx.beans.value.ObservableBooleanValue atMarkedPositionProperty()
        Description copied from interface: UndoManager
        Indicates whether this UndoManager's current position within its history is the same as the last marked position.
        Specified by:
        atMarkedPositionProperty in interface UndoManager<C>
      • preventMerge

        public void preventMerge()
        Description copied from interface: UndoManager
        Prevents the next change from being merged with the latest one.
        Specified by:
        preventMerge in interface UndoManager<C>
      • forgetHistory

        public void forgetHistory()
        Description copied from interface: UndoManager
        Forgets all changes prior to the current position in the history.
        Specified by:
        forgetHistory in interface UndoManager<C>
      • applyChange

        private boolean applyChange​(boolean isChangeAvailable,
                                    java.util.function.Supplier<C> changeToApply)
        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

        private void changeObserved​(C change)
      • addChange

        private void addChange​(C change)
      • invalidateProperties

        private void invalidateProperties()