public final class EditProcessor
extends java.lang.Object
EditProcessor
class contains static utility
routines for apply simple or complex edits to a
Node
. The EditProcessor
will take
care of buffer locking, notifications by sending an
UpdateMessage
to Node observers, and undo by
wrapping the edit with an IDE command.
For a single simple edit such as an insert, remove, replace, or
replace all, Addins can simply call the corresponding
doInsert()
, doRemove()
,
doReplace
, or doReplaceAll
method to
perform the edit.
If the simple edit should be undoable by the user using Edit->Undo,
Addins should specify true
for the
isUndoable
parameter, and also specify an appropriate
human-readable (i.e., translateable) undo edit name for use with
the Edit->Undo menu item.
For a complex edit, such as a sequence of inserts or removes,
Addins should encapsulate the complex edit in the Edit
interface, and use the doEdit()
to perform the
edit.
For all edit utility methods, the origin parameter is optional. It
is used with the UpdateMessage
so that Addins that
also observe the Node can identify the specify edit that they
just applied. Note that it is only used with
UpdateMessage
notification for the first application
of the edit. All subsequent Undo and Redo operations will use
null
for the origin.
Modifier and Type | Method and Description |
---|---|
static void |
doEdit(Edit edit,
Node node,
java.lang.Object origin)
Utility routine to invoke the specified edit for the given Node
as a command.
|
static void |
doInsert(char[] insertData,
int insertOffset,
Node node,
boolean isUndoable,
java.lang.String editName,
java.lang.Object origin)
Utility routine to perform a single insert in the Node.
|
static void |
doRemove(int removeOffset,
int removeCount,
Node node,
boolean isUndoable,
java.lang.String editName,
java.lang.Object origin)
Utility routine to perform a single remove in the Node.
|
static void |
doReplace(char[] replaceData,
int replaceStartOffset,
int replaceEndOffset,
Node node,
boolean isUndoable,
java.lang.String editName,
java.lang.Object origin)
Utility routine to perform a single replace in the Node with
the specified replace data.
|
static void |
doReplaceAll(char[] replaceData,
Node node,
boolean isUndoable,
java.lang.String editName,
java.lang.Object origin)
Utility routine to perform a replace all in the Node with the
new contents.
|
public static void doInsert(char[] insertData, int insertOffset, Node node, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
insertData
- the data to insert into the NodeinsertOffset
- the offset location to perform the insertnode
- the Node to apply the edit toisUndoable
- whether this edit should be undoableeditName
- the name of the edit to use for undoorigin
- the origin of this edit, used for the UpdateMessagepublic static void doRemove(int removeOffset, int removeCount, Node node, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
removeOffset
- the start of the remove in the NoderemoveCount
- the number of characters to removenode
- the Node to apply the edit toisUndoable
- whether this edit should be undoableeditName
- the name of the edit to use for undoorigin
- the origin of this edit, used for the UpdateMessagepublic static void doReplace(char[] replaceData, int replaceStartOffset, int replaceEndOffset, Node node, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
replaceData
- the replace data for the location in the NodereplaceStartOffset
- the starting offset of the location to replacereplaceEndOffset
- the ending offset of the location to replacenode
- the Node to apply the edit toisUndoable
- whether this edit should be undoableeditName
- the name of the edit to use for undoorigin
- the origin of this edit, used for the UpdateMessagepublic static void doReplaceAll(char[] replaceData, Node node, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
replaceData
- the new data for the Nodenode
- the Node to apply the edit toisUndoable
- whether this edit should be undoableeditName
- the name of the edit to use for undoorigin
- the origin of this edit, used for the UpdateMessage