Class InsertTextCommand

  • All Implemented Interfaces:
    Command

    public class InsertTextCommand
    extends AbstractCommand
    Inserts text into a property value at specified position
    • Field Detail

      • property

        protected final Property property
      • position

        protected final int position
      • oldvalue

        protected Object oldvalue
      • oldlength

        protected int oldlength
      • newvalue

        protected String newvalue
    • Constructor Detail

      • InsertTextCommand

        public InsertTextCommand​(Property property,
                                 String text,
                                 int position)
        Command to insert a text at the specified position of the property value
        Parameters:
        property - the property value to be modified
        text - the text to be inserted
        position - the position of the insertion.
    • Method Detail

      • execute

        public void execute()
      • merge

        public boolean merge​(Command next)
        attempt to merge another insertion into the same command
        Specified by:
        merge in interface Command
        Overrides:
        merge in class AbstractCommand
        Parameters:
        next - the next command to be stored together
        Returns:
        true if merge is successful, otherwise the command needs to be stored separately
      • undo

        public void undo()
      • getModifiedElement

        public Element getModifiedElement()
        Returns:
        the modified element or its closest relative (sibling or parent) if the element is not displayed.
      • getBeginIndex

        public int getBeginIndex()
      • getEndIndex

        public int getEndIndex()