SWT LPEX
v3.0.5

com.ibm.lpex.core
Interface LpexDocumentListener


public interface LpexDocumentListener

Interface LpexDocumentListener can be implemented to listen to text changes and adjustments in the document. 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 notifications may change in future releases.

The information provided applies to the entire text of the line, 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, for example, LpexView's addLpexDocumentListener() method. When text changes occur in the currently-loaded document section, the appropriate 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
          This notification is sent when a text element is inserted in the document.
static int ELEMENT_REMOVED
          This notification is sent when a text element is deleted from the document.
static int ELEMENT_REPLACED
          This notification is sent when a text element is replaced in the document.
static int END_CHANGES
          This informational notification is sent to indicate the end of the series of non-overlapping changes.
static int START_CHANGES
          This informational notification is sent to indicate the start of a series of non-overlapping changes.
static int TEXT_INSERTED
          This notification is sent when text is inserted in a text element.
static int TEXT_REMOVED
          This notification is sent when text is deleted in a text element.
static int TEXT_REPLACED
          This notification is 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

public static final int TEXT_REMOVED
This notification is sent when text is deleted in a text element. It is sent before the actual change takes place in the LPEX document.

See Also:
Constant Field Values

TEXT_REPLACED

public static final int TEXT_REPLACED
This notification is sent when text is replaced in a text element. It is sent after the actual change takes place in the LPEX document.

See Also:
Constant Field Values

TEXT_INSERTED

public static final int TEXT_INSERTED
This notification is sent when text is inserted in a text element. It is sent after the actual change takes place in the LPEX document.

See Also:
Constant Field Values

ELEMENT_REMOVED

public static final int ELEMENT_REMOVED
This notification is sent when a text element is deleted from the document. It is sent before the actual change takes place in the LPEX document.

See Also:
Constant Field Values

ELEMENT_REPLACED

public static final int ELEMENT_REPLACED
This notification is sent when a text element is replaced in the document. It is sent after the actual change takes place in the LPEX document.

See Also:
Constant Field Values

ELEMENT_INSERTED

public static final int ELEMENT_INSERTED
This notification is sent when a text element is inserted in the document. It is sent after the actual change takes place in the LPEX document.

See Also:
Constant Field Values

START_CHANGES

public static final int START_CHANGES
This informational notification is sent to indicate the start of a series of non-overlapping changes. It allows the listener to optimize its action on these changes.

See Also:
Constant Field Values

END_CHANGES

public static final int END_CHANGES
This informational notification is sent to indicate the end of the series of non-overlapping changes.

See Also:
Constant Field Values
Method Detail

documentChanged

public 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 - 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 the line, or 0 for element and informational notifications
count - character count of the change in the line, or 0 for element notifications, or 0 for informational notifications

SWT LPEX
v3.0.5

(C) Copyright IBM Corporation 1998, 2005.  All Rights Reserved.