LPEX
4.4.0

com.ibm.lpex.core
Interface LpexDocumentListener


public interface LpexDocumentListener

Interface LpexDocumentListener can be implemented to listen to text changes and adjustments in the document.

Note: In general, the document-parser calls are sufficient for applications that use the LPEX widget, and this specialized listener is not needed. The performance overhead of creating this listener's notifications should be taken into consideration before using it. It is mainly intended for internal use inside the editor, and the definition of its notifications (types and parameters) may change in future releases.

The information provided applies to the entire text of the line(s), i.e., including the sequence numbers, if set. No notifications are sent for show elements (such as document parser error-message lines).

Certain editing operations may trigger several consecutive notifications for one change which has already been recorded in the text of an element. For example, one replaceText command may trigger notifications indicating the text replaced, the text inserted beyond the end of the original line, and a sequence-numbers text part change.

Create a listener object using this class, and then register it with a document view using LpexView's addLpexDocumentListener() or addLpexDocumentAdjustListener(). When text changes occur in the currently-loaded document section, the documentChanged() method in the listener object is invoked. Example:

 
 lpexView.addLpexDocumentListener(new LpexDocumentListener() {
  // document text change
  public void documentChanged(LpexView view, int type,
                              int line, int position, int count) 
  {
   handleDocumentChange(view, type, line, position, count);
  }
 }); 

See Also:
LpexView.addLpexDocumentListener(com.ibm.lpex.core.LpexDocumentListener), LpexView.removeLpexDocumentListener(com.ibm.lpex.core.LpexDocumentListener), LpexView.addLpexDocumentAdjustListener(com.ibm.lpex.core.LpexDocumentListener), LpexView.removeLpexDocumentAdjustListener(com.ibm.lpex.core.LpexDocumentListener)

Field Summary
static int ELEMENT_INSERTED
          Notification sent when one or more consecutive text element(s) are inserted in the document.
static int ELEMENT_REMOVED
          Notification sent when one or more consecutive text elements are deleted from the document.
static int ELEMENT_REPLACED
          Notification sent when one or more consecutive text element(s) are replaced in the document.
static int END_CHANGES
          Informational notification sent for certain operations to indicate the end of the series of non-overlapping changes.
static int START_CHANGES
          Informational notification sent for certain operations to indicate the start of a series of non-overlapping changes.
static int TEXT_INSERTED
          Notification sent when text is inserted in a text element.
static int TEXT_REMOVED
          Notification sent when text is deleted in a text element.
static int TEXT_REPLACED
          Notification sent when text is replaced in a text element.
 
Method Summary
 void documentChanged(LpexView lpexView, int type, int line, int position, int count)
          This method is invoked when a text event occurs in the LPEX document.
 

Field Detail

TEXT_REMOVED

static final int TEXT_REMOVED
Notification sent when text is deleted in a text element. It is issued before the actual change takes place in the LPEX document. count indicates the number of characters being deleted.

See Also:
Constant Field Values

TEXT_REPLACED

static final int TEXT_REPLACED
Notification sent when text is replaced in a text element. It is issued after the actual change takes place in the LPEX document. count indicates the number of characters replaced.

See Also:
Constant Field Values

TEXT_INSERTED

static final int TEXT_INSERTED
Notification sent when text is inserted in a text element. It is issued after the actual change takes place in the LPEX document. count indicates the number of characters inserted.

See Also:
Constant Field Values

ELEMENT_REMOVED

static final int ELEMENT_REMOVED
Notification sent when one or more consecutive text elements are deleted from the document. It is issued before the actual change takes place in the LPEX document. count indicates the number of text elements being deleted.

See Also:
Constant Field Values

ELEMENT_REPLACED

static final int ELEMENT_REPLACED
Notification sent when one or more consecutive text element(s) are replaced in the document. It is issued after the actual change takes place in the LPEX document. count indicates the number of text elements replaced.

See Also:
Constant Field Values

ELEMENT_INSERTED

static final int ELEMENT_INSERTED
Notification sent when one or more consecutive text element(s) are inserted in the document. It is issued after the actual change takes place in the LPEX document. count indicates the number of text elements inserted.

See Also:
Constant Field Values

START_CHANGES

static final int START_CHANGES
Informational notification sent for certain operations to indicate the start of a series of non-overlapping changes. It allows the listener to optimize its action on these changes. count is 0.

See Also:
Constant Field Values

END_CHANGES

static final int END_CHANGES
Informational notification sent for certain operations to indicate the end of the series of non-overlapping changes. count is 0.

See Also:
Constant Field Values
Method Detail

documentChanged

void documentChanged(LpexView lpexView,
                     int type,
                     int line,
                     int position,
                     int count)
This method is invoked when a text event occurs in the LPEX document.

Parameters:
lpexView - the view of the editor document that triggered the notification
type - notification type
line - first or only document line affected (defined inside the document section that is currently loaded in the editor), or 0 for informational notifications
position - first change position inside line, or 0 for element and informational notifications
count - character / element count of the change, or 0 for informational notifications

LPEX
4.4.0

Copyright � 2016 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.