Package org.eclipse.jface.text
Class DocumentCommand
- java.lang.Object
-
- org.eclipse.jface.text.DocumentCommand
-
public class DocumentCommand extends Object
Represents a text modification as a document replace command. The text modification is given as aVerifyEventand translated into a document replace command relative to a given offset. A document command can also be used to initialize a givenVerifyEvent.A document command can also represent a list of related changes.
-
-
Field Summary
Fields Modifier and Type Field Description intcaretOffsetThe caret offset with respect to the document before the document command is executed.booleandoitMust the command be updatedintlengthThe length of the commandintoffsetThe offset of the command.IDocumentListenerownerThe owner of the document command which will not be notified.booleanshiftsCaretIndicates whether the caret should be shifted by this command.StringtextThe text to be inserted
-
Constructor Summary
Constructors Modifier Constructor Description protectedDocumentCommand()Creates a new document command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(int commandOffset, int commandLength, String commandText, IDocumentListener commandOwner)Adds an additional replace command.intgetCommandCount()Returns the number of commands including the original document command.Iterator<org.eclipse.jface.text.DocumentCommand.Command>getCommandIterator()Returns an iterator over the commands in ascending position order.
-
-
-
Field Detail
-
doit
public boolean doit
Must the command be updated
-
offset
public int offset
The offset of the command.
-
length
public int length
The length of the command
-
text
public String text
The text to be inserted
-
owner
public IDocumentListener owner
The owner of the document command which will not be notified.- Since:
- 2.1
-
caretOffset
public int caretOffset
The caret offset with respect to the document before the document command is executed.- Since:
- 2.1
-
shiftsCaret
public boolean shiftsCaret
Indicates whether the caret should be shifted by this command.- Since:
- 3.0
-
-
Method Detail
-
addCommand
public void addCommand(int commandOffset, int commandLength, String commandText, IDocumentListener commandOwner) throws BadLocationExceptionAdds an additional replace command. The added replace command must not overlap with existing ones. If the document command owner is notnull, it will not get document change notifications for the particular command.- Parameters:
commandOffset- the offset of the region to replacecommandLength- the length of the region to replacecommandText- the text to replace with, may benullcommandOwner- the command owner, may benull- Throws:
BadLocationException- if the added command intersects with an existing one- Since:
- 2.1
-
getCommandIterator
public Iterator<org.eclipse.jface.text.DocumentCommand.Command> getCommandIterator()
Returns an iterator over the commands in ascending position order. The iterator includes the original document command. Commands cannot be removed.- Returns:
- returns the command iterator
-
getCommandCount
public int getCommandCount()
Returns the number of commands including the original document command.- Returns:
- returns the number of commands
- Since:
- 2.1
-
-