- java.lang.Object
-
- io.github.interacto.undo.UndoCollector
-
public class UndoCollector extends Object
A collector of undone/redone objects.- Author:
- Arnaud BLOUIN
-
-
Field Summary
Fields Modifier and Type Field Description static StringEMPTY_REDOThe standard text for redo.static StringEMPTY_UNDOThe standard text for undo.
-
Constructor Summary
Constructors Constructor Description UndoCollector()Creates the undo collector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Undoable undoable)Adds an undoable object to the collector.voidclear()Removes all the undoable objects of the collector.static UndoCollectorgetInstance()Optional<Undoable>getLastRedo()Optional<String>getLastRedoMessage()Optional<Undoable>getLastUndo()Optional<String>getLastUndoMessage()Deque<Undoable>getRedo()intgetSizeMax()Deque<Undoable>getUndo()voidredo()Redoes the last undoable object.io.reactivex.Observable<Optional<Undoable>>redos()A stream for observing changes regarding the last redoable object.voidsetBundle(ResourceBundle bundle)Sets the language bundle to be used by the undo redo manager.static voidsetInstance(UndoCollector newInstance)Sets the single instance.voidsetSizeMax(int max)voidundo()Undoes the last undoable object.io.reactivex.Observable<Optional<Undoable>>undos()A stream for observing changes regarding the last undoable object.
-
-
-
Field Detail
-
EMPTY_REDO
public static final String EMPTY_REDO
The standard text for redo.- See Also:
- Constant Field Values
-
EMPTY_UNDO
public static final String EMPTY_UNDO
The standard text for undo.- See Also:
- Constant Field Values
-
-
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.
-
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.
-
-