public class SpreadsheetHistoryManager extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected LinkedList<Command> |
commands
All executed command in chronological order
|
protected int |
historyIndex
Current index within the history
|
protected Spreadsheet |
spreadsheet
Target Spreadsheet component
|
| Constructor and Description |
|---|
SpreadsheetHistoryManager(Spreadsheet spreadsheet)
Creates a new history manager for the given Spreadsheet.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCommand(Command command)
Adds a command to the end of the command history.
|
boolean |
canRedo()
Determines if redo is possible at the moment.
|
boolean |
canUndo()
Determines if undo is possible at the moment.
|
protected void |
changeSelection(Command command)
Applies the cell selection from the given Command.
|
void |
clear()
Clears the history.
|
protected void |
discardAllAfter(int index)
Clears all history after the given history index NOT including the
command at the given index.
|
Command |
getCommand(int historyIndex)
Gets the Command at the given history index.
|
int |
getHistoryIndex()
Gets the current index within the Command history.
|
int |
getHistorySize()
Gets the current size of the Command history.
|
protected void |
makeSureCorrectSheetActive(Command command)
Ensures that the correct sheet is active, as recorded in the given
Command.
|
void |
redo()
Does redo if possible.
|
void |
setHistorySize(int historySize)
Changes the history size.
|
void |
undo()
Does undo if possible.
|
protected int historyIndex
protected final LinkedList<Command> commands
protected final Spreadsheet spreadsheet
public SpreadsheetHistoryManager(Spreadsheet spreadsheet)
spreadsheet - Target spreadsheetpublic void clear()
public void addCommand(Command command)
command - Command to add as the latest command in historypublic Command getCommand(int historyIndex)
historyIndex - Index of Command to get, 0-basedIndexOutOfBoundsExceptionpublic boolean canRedo()
redo() possible, false otherwise.public boolean canUndo()
undo() possible, false otherwise.public void redo()
public void undo()
public void setHistorySize(int historySize)
historySize - New size for Command historypublic int getHistorySize()
public int getHistoryIndex()
protected void makeSureCorrectSheetActive(Command command)
command - Command to fetch the sheet fromprotected void changeSelection(Command command)
command - Command to fetch the cell selection from.protected void discardAllAfter(int index)
index - History index to start the clearing from.Copyright © 2013–2026 Vaadin Ltd. All rights reserved.