Class UndoUtils


  • public final class UndoUtils
    extends java.lang.Object
    A class filled with factory methods to help easily construct an UndoManager for a GenericStyledArea.
    • Field Detail

      • DEFAULT_PREVENT_MERGE_DELAY

        public static final java.time.Duration DEFAULT_PREVENT_MERGE_DELAY
    • Method Detail

      • noOpUndoManager

        public static UndoManager noOpUndoManager()
        Constructs an UndoManager with no history
      • richTextUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<RichTextChange<PS,​SEG,​S>>> richTextUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                                                   java.time.Duration preventMergeDelay)
        Returns an UndoManager that can undo/redo RichTextChanges. New changes emitted from the stream will not be merged with the previous change after preventMergeDelay
      • richTextUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<RichTextChange<PS,​SEG,​S>>> richTextUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                                                   UndoManagerFactory factory,
                                                                                                                                   java.time.Duration preventMergeDelay)
        Returns an UndoManager that can undo/redo RichTextChanges. New changes emitted from the stream will not be merged with the previous change after preventMergeDelay
      • richTextSuspendableUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<RichTextChange<PS,​SEG,​S>>> richTextSuspendableUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                                                              SuspendableYes suspendUndo)
        Returns an UndoManager with an unlimited history that can undo/redo RichTextChanges. New changes emitted from the stream will not be merged with the previous change after DEFAULT_PREVENT_MERGE_DELAY

        Note: that only styling changes may occur during suspension of the undo manager.

      • richTextSuspendableUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<RichTextChange<PS,​SEG,​S>>> richTextSuspendableUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                                                              java.time.Duration preventMergeDelay,
                                                                                                                                              SuspendableYes suspendUndo)
        Returns an UndoManager with an unlimited history that can undo/redo RichTextChanges. New changes emitted from the stream will not be merged with the previous change after preventMergeDelay.

        Note: that only styling changes may occur during suspension of the undo manager.

      • plainTextUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<PlainTextChange>> plainTextUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                               java.time.Duration preventMergeDelay)
        Returns an UndoManager that can undo/redo PlainTextChanges. New changes emitted from the stream will not be merged with the previous change after preventMergeDelay
      • plainTextUndoManager

        public static <PS,​SEG,​S> UndoManager<java.util.List<PlainTextChange>> plainTextUndoManager​(GenericStyledArea<PS,​SEG,​S> area,
                                                                                                               UndoManagerFactory factory,
                                                                                                               java.time.Duration preventMergeDelay)
        Returns an UndoManager that can undo/redo PlainTextChanges. New changes emitted from the stream will not be merged with the previous change after preventMergeDelay
      • applyPlainTextChange

        public static <PS,​SEG,​S> java.util.function.Consumer<PlainTextChange> applyPlainTextChange​(GenericStyledArea<PS,​SEG,​S> area)
        Applies a PlainTextChange to the given area when the UndoManager's change stream emits an event by area.replaceText(change.getPosition(), change.getRemovalEnd(), change.getInserted().
      • applyRichTextChange

        public static <PS,​SEG,​S> java.util.function.Consumer<RichTextChange<PS,​SEG,​S>> applyRichTextChange​(GenericStyledArea<PS,​SEG,​S> area)
        Applies a RichTextChange to the given area when the UndoManager's change stream emits an event by area.replace(change.getPosition(), change.getRemovalEnd(), change.getInserted().
      • applyMultiPlainTextChange

        public static <PS,​SEG,​S> java.util.function.Consumer<java.util.List<PlainTextChange>> applyMultiPlainTextChange​(GenericStyledArea<PS,​SEG,​S> area)
        Applies a list of PlainTextChanges to the given area when the UndoManager's change stream emits an event by area.replaceAbsolutely(change.getPosition(), change.getRemovalEnd(), change.getInserted().
      • applyMultiRichTextChange

        public static <PS,​SEG,​S> java.util.function.Consumer<java.util.List<RichTextChange<PS,​SEG,​S>>> applyMultiRichTextChange​(GenericStyledArea<PS,​SEG,​S> area)
        Applies a list of RichTextChange to the given area when the UndoManager's change stream emits an event by area.replaceAbsolutely(change.getPosition(), change.getRemovalEnd(), change.getInserted().