public class TextEditProcessor extends Object
TextEditProcessor
manages a set of edits and applies
them as a whole to an IDocument
.
This class isn't intended to be subclassed.
TextEdit.apply(IDocument)
Constructor and Description |
---|
TextEditProcessor(IDocument document,
TextEdit root,
int style)
Constructs a new edit processor for the given
document.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canPerformEdits()
Checks if the processor can execute all its edits.
|
protected boolean |
considerEdit(TextEdit edit)
Tells whether this processor considers the given edit.
|
IDocument |
getDocument()
Returns the document to be manipulated.
|
TextEdit |
getRoot()
Returns the edit processor's root edit.
|
int |
getStyle()
Returns the style bits of the text edit processor
|
UndoEdit |
performEdits()
Executes the text edits.
|
public TextEditProcessor(IDocument document, TextEdit root, int style)
document
- the document to manipulateroot
- the root of the text edit tree describing
the modifications. By passing a text edit a a text edit
processor the ownership of the edit is transfered to the
text edit processors. Clients must not modify the edit
(e.g adding new children) any longer.style
- TextEdit.NONE
, TextEdit.CREATE_UNDO
or TextEdit.UPDATE_REGIONS
)public IDocument getDocument()
public TextEdit getRoot()
public int getStyle()
TextEdit.CREATE_UNDO
,
TextEdit.UPDATE_REGIONS
public boolean canPerformEdits()
true
if the edits can be executed. Return false
otherwise. One major reason why edits cannot be executed are wrong
offset or length values of edits. Calling perform in this case will very
likely end in a BadLocationException
.public UndoEdit performEdits() throws MalformedTreeException, BadLocationException
MalformedTreeException
- is thrown if the edit tree isn't
in a valid state. This exception is thrown before any edit is executed.
So the document is still in its original state.BadLocationException
- is thrown if one of the edits in the
tree can't be executed. The state of the document is undefined if this
exception is thrown.protected boolean considerEdit(TextEdit edit)
Note that this class isn't intended to be subclassed.
edit
- the text edittrue
if this processor considers the given edit
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.