Class PasteTextCommand

java.lang.Object
fr.istic.aco.editor.commands.PasteTextCommand
All Implemented Interfaces:
Command, CommandOriginator, Originator

public class PasteTextCommand extends Object implements CommandOriginator
The PasteTextCommand class implements the functionality for replacing the currently selected text with the contents of the clipboard.
  • Constructor Details

    • PasteTextCommand

      public PasteTextCommand(Engine engine, Recorder recorder, UndoManager undoManager)
      Constructs a PasteTextCommand with the specified dependencies.
      Parameters:
      engine - the text editing engine responsible for text editing actions
      recorder - the command recorder for saving and replaying the command
      undoManager - the undo manager for handling undo and redo functionality
  • Method Details

    • getMemento

      public EngineMemento getMemento()
      Returns null since this command does not require saving state for the Memento pattern.
      Specified by:
      getMemento in interface Originator
      Returns:
      always null, as this command does not save state
    • setMemento

      public void setMemento(Memento memento)
      Does nothing since there is no state to restore for this command.
      Specified by:
      setMemento in interface Originator
      Parameters:
      memento - the memento object (ignored)
    • execute

      public void execute()
      Executes the command by replacing the selected text with the contents of the clipboard.

      Before executing, the current state of the Engine is stored in the UndoManager as a memento. The command is also saved in the Recorder for replay functionality.

      Specified by:
      execute in interface Command