Class UndoCollector


  • public class UndoCollector
    extends Object
    A collector of undone/redone objects.
    Author:
    Arnaud BLOUIN
    • Constructor Detail

      • UndoCollector

        public UndoCollector()
        Creates the undo collector.
    • Method Detail

      • getInstance

        public static UndoCollector getInstance()
        Returns:
        The single instance. Cannot be null.
      • setInstance

        public static void setInstance​(UndoCollector newInstance)
        Sets the single instance.
        Parameters:
        newInstance - The new single instance. Nothing done if null.
      • undos

        public io.reactivex.Observable<Optional<Undoable>> undos()
        A stream for observing changes regarding the last undoable object.
        Returns:
        An observable value of optional undoable objects: if empty, this means that no undoable object are stored anymore.
      • redos

        public io.reactivex.Observable<Optional<Undoable>> redos()
        A stream for observing changes regarding the last redoable object.
        Returns:
        An observable value of optional redoable objects: if empty, this means that no redoable object are stored anymore.
      • clear

        public void clear()
        Removes all the undoable objects of the collector.
      • add

        public void add​(Undoable undoable)
        Adds an undoable object to the collector.
        Parameters:
        undoable - The undoable object to add.
      • undo

        public void undo()
        Undoes the last undoable object.
      • redo

        public void redo()
        Redoes the last undoable object.
      • getLastUndoMessage

        public Optional<String> getLastUndoMessage()
        Returns:
        The last undoable object name or null if there is no last object.
      • getLastRedoMessage

        public Optional<String> getLastRedoMessage()
        Returns:
        The last redoable object name or null if there is no last object.
      • getLastUndo

        public Optional<Undoable> getLastUndo()
        Returns:
        The last undoable object or null if there is no last object.
      • getLastRedo

        public Optional<Undoable> getLastRedo()
        Returns:
        The last redoable object or null if there is no last object.
      • getSizeMax

        public int getSizeMax()
        Returns:
        The max number of saved undoable objects.
      • setSizeMax

        public void setSizeMax​(int max)
        Parameters:
        max - The max number of saved undoable objects. Must be great than 0.
      • getUndo

        public Deque<Undoable> getUndo()
        Returns:
        The stack of saved undoable objects.
      • getRedo

        public Deque<Undoable> getRedo()
        Returns:
        The stack of saved redoable objects
      • setBundle

        public void setBundle​(ResourceBundle bundle)
        Sets the language bundle to be used by the undo redo manager.
        Parameters:
        bundle - The language bundle. Can be null.