Class MoveSelection
java.lang.Object
fr.istic.aco.editor.commands.MoveSelection
- All Implemented Interfaces:
Command
,CommandOriginator
,Originator
The
MoveSelection
class implements the functionality for selecting the text within the interval-
Constructor Summary
ConstructorsConstructorDescriptionMoveSelection
(Engine engine, Invoker invoker, Recorder recorder, UndoManager undoManager) Constructs aMoveSelection
with the specified dependencies. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the command to update the text selection range.Creates and returns a memento representing the current state of the selection command.void
setMemento
(Memento memento) Restores the state of the command from the provided memento.
-
Constructor Details
-
MoveSelection
Constructs aMoveSelection
with the specified dependencies.- Parameters:
engine
- the text editing engine responsible for text editing actionsinvoker
- the invoker object that provides the text to be insertedrecorder
- the command recorder for saving and replaying the commandundoManager
- the undo manager for handling undo and redo functionality
-
-
Method Details
-
getMemento
Creates and returns a memento representing the current state of the selection command.The memento stores the beginning and ending indices of the selection range, which are retrieved from the
Invoker
.- Specified by:
getMemento
in interfaceOriginator
- Returns:
- a memento containing the selection range (beginning and ending indices)
-
setMemento
Restores the state of the command from the provided memento.The beginning and ending indices stored in the memento are restored to the
Invoker
.- Specified by:
setMemento
in interfaceOriginator
- Parameters:
memento
- the memento object containing the state to restore
-
execute
public void execute()Executes the command to update the text selection range.This method performs the following steps:
- Saves the current state of the
Engine
in theUndoManager
to enable undo functionality. - Updates the selection range using the beginning and ending indices provided by the
Invoker
. - Records the command in the
Recorder
for replay functionality.
- Saves the current state of the
-