Extension SDK 10.1.2

oracle.ide.cmd.buffer
Class EditProcessor

java.lang.Object
  extended byoracle.ide.cmd.buffer.EditProcessor

public final class EditProcessor
extends java.lang.Object

The EditProcessor class contains static utility routines for apply simple or complex edits to a Document. The EditProcessor will take care of buffer locking, notifications by sending an UpdateMessage to document 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 document 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.


Method Summary
static void doEdit(Edit edit, Document document, java.lang.Object origin)
          Utility routine to invoke the specified edit for the given document as a command.
static void doInsert(char[] insertData, int insertOffset, Document document, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
          Utility routine to perform a single insert in the document.
static void doRemove(int removeOffset, int removeCount, Document document, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
          Utility routine to perform a single remove in the document.
static void doReplace(char[] replaceData, int replaceStartOffset, int replaceEndOffset, Document document, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
          Utility routine to perform a single replace in the document with the specified replace data.
static void doReplaceAll(char[] replaceData, Document document, boolean isUndoable, java.lang.String editName, java.lang.Object origin)
          Utility routine to perform a replace all in the document with the new contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doInsert

public static void doInsert(char[] insertData,
                            int insertOffset,
                            Document document,
                            boolean isUndoable,
                            java.lang.String editName,
                            java.lang.Object origin)
Utility routine to perform a single insert in the document. This performs the edit as an IDE command.

Parameters:
insertData - the data to insert into the document
insertOffset - the offset location to perform the insert
document - the document to apply the edit to
isUndoable - whether this edit should be undoable
editName - the name of the edit to use for undo
origin - the origin of this edit, used for the UpdateMessage

doRemove

public static void doRemove(int removeOffset,
                            int removeCount,
                            Document document,
                            boolean isUndoable,
                            java.lang.String editName,
                            java.lang.Object origin)
Utility routine to perform a single remove in the document. This performs the edit as an IDE command.

Parameters:
removeOffset - the start of the remove in the document
removeCount - the number of characters to remove
document - the document to apply the edit to
isUndoable - whether this edit should be undoable
editName - the name of the edit to use for undo
origin - the origin of this edit, used for the UpdateMessage

doReplace

public static void doReplace(char[] replaceData,
                             int replaceStartOffset,
                             int replaceEndOffset,
                             Document document,
                             boolean isUndoable,
                             java.lang.String editName,
                             java.lang.Object origin)
Utility routine to perform a single replace in the document with the specified replace data. This performs the edit as an IDE command.

Parameters:
replaceData - the replace data for the location in the document
replaceStartOffset - the starting offset of the location to replace
replaceEndOffset - the ending offset of the location to replace
document - the document to apply the edit to
isUndoable - whether this edit should be undoable
editName - the name of the edit to use for undo
origin - the origin of this edit, used for the UpdateMessage

doReplaceAll

public static void doReplaceAll(char[] replaceData,
                                Document document,
                                boolean isUndoable,
                                java.lang.String editName,
                                java.lang.Object origin)
Utility routine to perform a replace all in the document with the new contents. This performs the edit as an IDE command.

Parameters:
replaceData - the new data for the document
document - the document to apply the edit to
isUndoable - whether this edit should be undoable
editName - the name of the edit to use for undo
origin - the origin of this edit, used for the UpdateMessage

doEdit

public static void doEdit(Edit edit,
                          Document document,
                          java.lang.Object origin)
Utility routine to invoke the specified edit for the given document as a command.

Parameters:
edit - the edit to apply
document - the document to apply the edit to
origin - the origin of this edit, used for the UpdateMessage

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.