com.ibm.lpex.core
Interface LpexDocumentSectionListener
public interface LpexDocumentSectionListener
Interface LpexDocumentSectionListener can be implemented to manage the
document section currently loaded in the editor. After loading a document
section and setting information regarding the number of lines in the complete
document, the application responds to the document-listener notifications by
expanding the document section as requested.
Create a listener object using this class, and then register it with a
document view using the view's addLpexDocumentSectionListener()
method. When the editor determines that the currently-loaded document
section must be extended, the addLines()
method in the listener
object is invoked.
Example:
lpexView.addLpexDocumentSectionListener(new LpexDocumentSectionListener() {
// we must extend the document section
public boolean addLines(LpexView view, int lineNeeded)
{
return loadItUp(view, lineNeeded);
}
}); |
Note: This feature is only provided for certain specific applications.
Normally, the editor loads and operates on complete documents (files).
When an application only loads a section of the document, it should take
certain features into consideration:
- Most editor parameters and commands apply to the complete document.
For example, the "Line" field on the status line, displayed line numbers,
the numeric part of sequence numbers, the resequence command,
etc. apply to the entire document.
- API methods defined in LpexView, on the other hand, allow the application
to easily control the editor widget for the current document section only.
For example, while "query elements" entered on the editor command line
(and, consequently, the method lpexView.queryInt("elements");) will
return, say, 500, the API method call lpexView.elements() will return 100
if the current document section has 100 text elements (i.e., is preceded
and/or followed by a total of 400 lines which have not been loaded in the
editor).
- Most actions and commands only operate on the current document section.
For example,
- the commands print, save, set mark, findText (and,
consequently, the live find/replace dialogs), sort, compare, locate
sequenceNumber, locate sequenceText, and
- the actions blockMarkAll, blockMarkTop, blockMarkBottom,
setQuickMarkAll.
They do not trigger a request for extending this document section.
To make them operate on the entire document, the application should
extend these actions and commands to first load the complete document in,
or redefine them with custom implementations.
- Similarly, filtered views - such as filter selection, and Ctrl+G (action
functions) which displays only the function headers in C/C++
documents - only apply to the elements in the document section that is
currently loaded in the editor.
The horizontal scroll bar only reflects the longest element in the
current document section, and it may change when the section is expanded.
- Document parsers, unless specifically written to handle a partial
document appropriately, operate only on the currently-loaded section and
do not trigger requests to extend it. This section's boundaries should
not split multiline language-specific constructs, or parsers may
misinterpret the document syntax.
- A request to expand the current document section may be issued, before
or after the operation, by
- these commands: locate element, locate line, delete,
- these actions: top, bottom, up, down, pageUp, pageDown,
blockMarkUp, blockMarkDown, blockMarkPageUp, blockMarkPageDown,
blockDelete, newLine, and by
- user selection of the vertical scroll bar in the edit window.
- Multiple views cannot be opened on the same document when document-section
management is in effect. Also, document-section management cannot be
initiated when there are
several views opened on a document.
This restriction results from the fact that applications that employ
document-section management may choose to replace the current document
section as needed, rather than extend it.
- See Also:
LpexView.addLpexDocumentSectionListener(com.ibm.lpex.core.LpexDocumentSectionListener)
,
LpexView.removeLpexDocumentSectionListener(com.ibm.lpex.core.LpexDocumentSectionListener)
,
LpexView.setLinesOutsideDocumentSection(int, int)
,
LpexView.linesBeforeStart()
,
LpexView.linesAfterEnd()
Method Summary |
boolean |
addLines(LpexView lpexView,
int lineNeeded)
This method is invoked when it was determined that the currently-loaded
document section should be extended. |
addLines
boolean addLines(LpexView lpexView,
int lineNeeded)
- This method is invoked when it was determined that the currently-loaded
document section should be extended. A minimum of about two screen rows
of lines is expected to be loaded around the current line in each document
view.
Scroll down example:
before after
scroll down scroll down
----------------- -----------------
^ | | | | ^
| | | | | |
linesBeforeStart | | | | linesBeforeStart
|XXXXXXXXXXXXXXX| .. |XXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXX| |XXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXX| |XXXXXXXXXXXXXXX|
| cursor | |XXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXX| |XXXXXXXXXXXXXXX|
|XXXXXXXXXXXXXXX| |XXXXXXXXXXXXXXX|
linesAfterEnd | | |XXXXXXXXXXXXXXX|
| | | |XXXXXXXXXXXXXXX|
| | scroll target | .. | cursor |
| | | |XXXXXXXXXXXXXXX|
| | [threshold] | |XXXXXXXXXXXXXXX|
| | | |XXXXXXXXXXXXXXX|
| | lineNeeded | .. |XXXXXXXXXXXXXXX|
| | | | | linesAfterEnd
| | | | | |
v | | | | v
----------------- ----------------- |
- Parameters:
lpexView
- the view of the editor document which triggered the request
to add lineslineNeeded
- the document line delimiting the new range needed to expand
the current document section in the implied direction. This is
- the first line prior to the start of the current document section,
or
- the last line beyond the end of the current document section
in the range of lines with which the current document section must
be expanded;
lineNeeded already includes the minimum threshold indicated
- Returns:
true
to indicate that the document section has been
updated (any other registered document-section listeners will
not be called)
Copyright © 2013 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.