Class DeleteTextCommand
java.lang.Object
fr.istic.aco.editor.commands.DeleteTextCommand
- All Implemented Interfaces:
Command
,CommandOriginator
,Originator
The
DeleteTextCommand
class implements the functionality for deleting the
currently selected text.-
Constructor Summary
ConstructorsConstructorDescriptionDeleteTextCommand
(Engine engine, Recorder recorder, UndoManager undoManager) Constructs aDeleteTextCommand
with the specified dependencies. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the command by deleting the selected text.Returnsnull
since this command does not require saving state for the Memento pattern.void
setMemento
(Memento memento) Does nothing since there is no state to restore for this command.
-
Constructor Details
-
DeleteTextCommand
Constructs aDeleteTextCommand
with the specified dependencies.- Parameters:
engine
- the text editing engine responsible for text editing actionsrecorder
- the command recorder for saving and replaying the commandundoManager
- the undo manager for handling undo and redo functionality
-
-
Method Details
-
getMemento
Returnsnull
since this command does not require saving state for the Memento pattern.- Specified by:
getMemento
in interfaceOriginator
- Returns:
- always
null
, as this command does not save state
-
setMemento
Does nothing since there is no state to restore for this command.- Specified by:
setMemento
in interfaceOriginator
- Parameters:
memento
- the memento object (ignored)
-
execute
public void execute()Executes the command by deleting the selected text.Before executing, the current state of the
Engine
is stored in theUndoManager
as a memento. The command is also saved in theRecorder
for replay functionality.
-