|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.lpex.core.LpexView
public class LpexView
Use this class to manage an LPEX document view. It essentially provides all the editor widget programming support.
Creating an instance of this class creates a document view. When you are just extending an existing LPEX-based application, view management (creation, disposal) is usually that application's responsibility.
Lines and elements
The LPEX document maintains a list of elements. An element in this list constitutes any line of textual information that may be displayed in the edit area of a view of the document. Elements are:
Most methods that access the document contents use as argument an element ordinal number. The ordinal numbers of elements change as elements are being inserted and removed, as a result of, for example, the user editing the document and parsers adding and removing error messages.
In general, a document parser skips and ignores show elements:
if (view.show(elementNumber)) { // embedded message - skip it } else { // text line - parse it // . . . } |
LpexCharStream also ignores show elements, and does not send them to the token manager.
During the processing of one parse unit (i.e., during one total-parse or
one incremental-parse call from LpexCommonParser), requests to
addMessage()
, removeMessages()
,
addDocumentMessage()
, and removeDocumentMessages()
are stacked, and only processed afterwards. In other words, during one such
call, the parser will see the same element numbers throughout the document -
the messages will only be added and removed by LpexCommonParser when the parser
returns.
In view of the above, a parser should not concern itself with changes in
element numbers during a parse operation. If, however, your parser keeps
(caches) information across parse calls from LpexCommonParser, you
may consider keeping it in term of lines rather than elements.
To determine the document line number of a text element, you can use
lineOfElement()
.
Marks may also be set to tag particular elements for this purpose (see the
mark editor parameter).
If your code itself inserts a series of show lines (for example, compiler error messages) in a view, outside a parsing operation, the easiest way to do it is starting from the last (i.e., from the highest element number), and proceeding towards the first (lowest element number).
LpexWindow
Nested Class Summary | |
---|---|
static class |
LpexView.ViewInstantiationException
Indicates a failed attempt to create a new document view. |
Constructor Summary | |
---|---|
LpexView()
Use this constructor to create an untitled document. |
|
LpexView(boolean updateProfile)
Use this constructor to create an untitled document, indicating whether the updateProfile command should be called. |
|
LpexView(LpexView lpexView)
Use this constructor to create a new document view from the specified document view. |
|
LpexView(LpexView lpexView,
boolean updateProfile)
Use this constructor to create a new document view from the specified document view, indicating whether the updateProfile command should be called. |
|
LpexView(String fileName)
Use this constructor to create a document from the specified file name. |
|
LpexView(String fileName,
boolean updateProfile)
Use this constructor to create a document from the specified file name, indicating whether the updateProfile command should be called. |
|
LpexView(String fileName,
String fileEncoding,
boolean updateProfile)
Use this constructor to create a document from the given file name, specifying its character encoding and indicating whether the updateProfile command should be called. |
Method Summary | |
---|---|
LpexAction |
action(String actionName)
Returns the specified user-defined editor action. |
boolean |
actionAvailable(int actionId)
Returns whether the specified action is available. |
boolean |
actionChecked(int actionId)
Returns whether the specified action has a checked status. |
int |
actionId(String actionName)
Returns the id of the specified default or user-defined editor action. |
String |
actionKey(int actionId)
Returns the primary key associated with the specified action. |
String |
actionKeyText(int actionId)
Returns a translated text version of the primary key for the specified action. |
void |
addLpexCursorListener(LpexCursorListener cursorListener)
Adds a cursor listener to this document view. |
void |
addLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)
Adds a document-adjust listener to the editor document of this view. |
void |
addLpexDocumentListener(LpexDocumentListener documentListener)
Adds a document listener to the editor document of this view. |
void |
addLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
Adds a document-section listener to the editor document of this view. |
void |
addLpexKeyListener(LpexKeyListener keyListener)
Adds an LPEX key listener to this document view. |
void |
addLpexMarkListener(int markId,
LpexMarkListener markListener)
Adds a mark listener to the specified mark. |
void |
addLpexViewListener(LpexViewListener viewListener)
Adds a view listener to this document view. |
int |
charOffset(LpexDocumentLocation documentLocation,
int eolLength)
Returns a document (or document section) location's Unicode-character offset in its underlying file (section). |
long |
classMask(String classNames)
Returns the bit-mask allocated in this view for the registered element class(es) named. |
LpexCommand |
command(String commandName)
Returns the specified user-defined command. |
int |
currentElement()
Returns the ordinal number of the current (cursor) element in the document (or section of the document that is currently loaded in the editor). |
int |
currentPosition()
Convenience method to retrieve the current (cursor) position within the current (cursor) element. |
boolean |
defaultActionAvailable(int actionId)
Checks whether the specified default editor action is available. |
LpexAction |
defineAction(String actionName,
LpexAction lpexAction)
Defines a user action. |
LpexCommand |
defineCommand(String commandName,
LpexCommand lpexCommand)
Defines a user command. |
String |
deletedMarkName(int markId)
Returns the name of the deleted mark with the id specified. |
void |
dispose()
This method disposes the document view. |
void |
doAction(int actionId)
Runs the specified action. |
boolean |
doCommand(LpexDocumentLocation documentLocation,
String commandString)
Runs the specified command at the specified document (or document section) location. |
boolean |
doCommand(String commandString)
Runs the specified command. |
LpexDocumentLocation |
documentLocation()
Returns the view's current (cursor) location in the document (or section of the document that is currently loaded in the editor). |
LpexDocumentLocation |
documentLocation(int charOffset,
int eolLength)
Returns the location in the document (or section of the document that is currently loaded in the editor) which corresponds to the given Unicode-character offset in its underlying file (section). |
void |
doDefaultAction(int actionId)
Runs the default editor action for the specified action id. |
boolean |
doDefaultCommand(LpexDocumentLocation documentLocation,
String commandString)
Runs the specified default editor command. |
boolean |
doDefaultCommand(String commandString)
Runs the specified default editor command. |
static boolean |
doGlobalCommand(String commandString)
Runs the specified default editor global command. |
long |
elementClasses(int element)
Returns the bit-mask of the element classes set in an element of the document (or document section that is currently loaded in the editor). |
String |
elementFullText(int element)
Returns the full text (i.e., including the sequence numbers, if set) of an element in the document (or document section currently loaded in the editor). |
int |
elementOfLine(int line)
Returns the element for the specified line. |
int |
elementOfRow(int row)
Returns the element in the document (or that section of the document that is currently loaded in the editor) which is displayed on the given screen row. |
void |
elementParsed(int element)
Removes the specified element from the parse-pending list of this document view. |
int |
elements()
Returns the number of elements in the document (or section of the document that is currently loaded in the editor). |
String |
elementStyle(int element)
Returns the style string for an element in the document (or document section currently loaded in the editor). |
String |
elementText(int element)
Returns the text of an element in the document (or document section currently loaded in the editor). |
static void |
extendInstallProfile(Properties extension)
Extends the editor install profile. |
LpexView |
getBlockView()
Returns the view with the selection, if any, in this view's block instance. |
org.eclipse.swt.graphics.Font |
getFont()
Returns the font in this view. |
static String |
getLpexHelpPage(String lpexItem)
Returns the default HTML help panel for the editor item specified. |
LpexView[] |
getLpexViews()
Returns an array of the views currently open on this view's document. |
static String |
globalQuery(String parameter)
Queries a global editor parameter. |
boolean |
isDisposed()
Returns whether the document view has been disposed. |
void |
jump(int element,
int position)
Moves the cursor to the specified position in the document (or section of the document that is currently loaded in the editor). |
void |
jump(LpexDocumentLocation documentLocation)
Moves the cursor to the specified position in the document (or section of the document that is currently loaded in the editor). |
boolean |
keyAssigned(String keyString)
Checks whether the specified key is associated with an action. |
static String |
keyText(String keyString)
Returns a translated text version of a key definition. |
String |
lineFullText(int line)
Returns the full text (i.e., including the sequence numbers, if set) of a line in the document (or document section currently loaded in the editor). |
int |
lineOfElement(int element)
Returns the line for the specified element. |
int |
linesAfterEnd()
Returns the number of lines in the document following the currently-loaded document section. |
int |
linesBeforeStart()
Returns the number of lines in the document prior to the currently-loaded document section. |
boolean |
load(Reader reader)
Loads the entire text of the document (or document section) from the specified Reader. |
LpexView |
lpexView(String documentName)
Returns a view handling the given document, if any. |
LpexNls |
nls()
Returns the LpexNls object associated with this LpexView. |
int |
parsePending(int element)
Returns the parse-pending state of the specified element. |
LpexParser |
parser()
Returns the current document parser for this view. |
String |
query(String parameter)
Queries an editor parameter. |
String |
query(String parameter,
LpexDocumentLocation documentLocation)
Queries an editor parameter. |
int |
queryInt(String parameter)
Convenience method to query an editor integer parameter. |
int |
queryInt(String parameter,
LpexDocumentLocation documentLocation)
Convenience method to query an editor integer parameter. |
boolean |
queryOn(String parameter)
Convenience method to query an editor on/off parameter. |
boolean |
queryOn(String parameter,
LpexDocumentLocation documentLocation)
Convenience method to query an editor on/off parameter. |
long |
registerClass(String className)
Registers the specified element class in this view. |
void |
removeLpexCursorListener(LpexCursorListener cursorListener)
Removes a cursor listener from this document view. |
void |
removeLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)
Removes a document-adjust listener from the editor document of this view. |
void |
removeLpexDocumentListener(LpexDocumentListener documentListener)
Removes a document listener from the editor document of this view. |
void |
removeLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
Removes a document-section listener from the editor document of this view. |
void |
removeLpexKeyListener(LpexKeyListener keyListener)
Removes the specified LPEX key listener from this document view. |
void |
removeLpexMarkListener(int markId,
LpexMarkListener markListener)
Removes a mark listener from the specified mark. |
void |
removeLpexMarkListener(LpexMarkListener markListener)
Removes a mark listener from all the marks in this document view for which it is registered. |
void |
removeLpexViewListener(LpexViewListener viewListener)
Removes a view listener from this document view. |
boolean |
save(Writer writer)
Saves the entire text of the document (or document section currently loaded in the editor) to the specified Writer. |
void |
setBaseEncoding(String fileEncoding)
|
void |
setBlockInstance(LpexView lpexView)
Sets the block instance of this view. |
static void |
setClassLoader(ClassLoader classLoader)
Sets an alternative class loader to be used by the editor. |
void |
setElementClasses(int element,
long classes)
Sets the element classes bit-mask in an element of the document (or document section that is currently loaded in the editor). |
void |
setElementStyle(int element,
String style)
Sets the style string for an element in the document (or section of the document that is currently loaded in the editor). |
void |
setElementText(int element,
String text)
Sets the text for an element in the document (or document section that is currently loaded in the editor). |
void |
setFieldsProvider(LpexFieldsProvider fieldsProvider)
Sets or removes a fields-setting provider for the text elements in this document view. |
void |
setFont(org.eclipse.swt.graphics.Font swtFont)
Sets a new font in this view. |
boolean |
setLinesOutsideDocumentSection(int linesBeforeStart,
int linesAfterEnd)
Sets the number of lines in the complete document that are outside the boundaries of the currently-loaded document section. |
void |
setOwnerDrawMargin(boolean ownerDraw)
Sets whether the prefix-area margin of this view is being painted by an editor extension. |
void |
setParserOverrideName(String name)
Sets the name of the parser to be used instead of the associated parser. |
void |
setSaveWriter(Writer writer)
Sets the Writer object for the saveToWriter action. |
void |
setText(String text)
Sets the entire text of the document (or document section). |
void |
setWindow(LpexWindow lpexWindow)
Use this method to associate an LPEX window with this document view. |
boolean |
show(int element)
Returns the show setting for an element in the document (or document section that is currently loaded in the editor). |
String |
text()
Returns the entire text of the document (or document section currently loaded in the editor). |
void |
triggerAction(int actionId)
Runs the specified action. |
void |
triggerAction(int actionId,
boolean record)
Runs the specified action and optionally records it if keystroke recording is in progress. |
boolean |
viewShow(int element)
Returns whether the specified element in the document (or document section that is currently loaded in the editor) is a show element for this document view. |
LpexWindow |
window()
Returns the LPEX window currently associated with this view. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LpexView(String fileName, String fileEncoding, boolean updateProfile)
If you specify null
for fileEncoding, the native
(platform's default) encoding will be used. If you specify an empty String
(""
), the editor will attempt to detect the file encoding, and
will default to the native encoding if unsuccessful.
If you specify true
for updateProfile, then the
updateProfile command will be called with the default settings.
If you specify false
, then updateProfile will not be
called; you can then change updateProfile. settings and issue the
updateProfile command later.
public LpexView(String fileName, boolean updateProfile)
If you specify true
for updateProfile, then the
updateProfile command will be called with the default settings.
If you specify false
, then updateProfile will not be
called; you can then change the updateProfile settings and issue the
updateProfile command later.
public LpexView(String fileName)
The updateProfile command will be called, with the default settings.
public LpexView()
The updateProfile command will be called, with the default settings.
public LpexView(boolean updateProfile)
If you specify true
for updateProfile, then the
updateProfile command will be called with the default settings.
If you specify false
, then updateProfile will not be
called; you can then change the updateProfile settings and issue the
updateProfile command later.
public LpexView(LpexView lpexView) throws LpexView.ViewInstantiationException
The updateProfile command will be called, with the default settings.
LpexView.ViewInstantiationException
- if an additional view on the document
cannot be created. Possible reasons: a null lpexView parameter
was specified, or document-section management is in effect.public LpexView(LpexView lpexView, boolean updateProfile) throws LpexView.ViewInstantiationException
If you specify true
for updateProfile, then the
updateProfile command will be called with the default settings.
If you specify false
, then updateProfile will not be
called; you can then change the updateProfile settings and issue the
updateProfile command later.
LpexView.ViewInstantiationException
- if an additional view on the document
cannot be created. Possible reasons: a null lpexView parameter
was specified, or document-section management is in effect.Method Detail |
---|
public void dispose()
public boolean isDisposed()
dispose()
,
LpexViewListener.disposed(LpexView)
public void setWindow(LpexWindow lpexWindow)
public LpexWindow window()
public LpexView[] getLpexViews()
public LpexNls nls()
LpexNls
public void setText(String text)
This method is similar to the load editor command. It will clear the undo stack, reset the changes count, and issue updateProfile for all of the views of the current document.
text()
public String text()
setText(java.lang.String)
,
save(Writer)
public boolean load(Reader reader)
This method is similar to the load editor command. It will clear the undo stack, reset the changes count, and issue updateProfile for all of the views of the current document.
true
if the text was loaded successfullypublic boolean save(Writer writer)
writer
- a Writer object, for example a StringWriter, an
OutputStringWriter (one that uses the default character
encoding or one that uses a named encoding), etc.
true
if the text was saved successfullytext()
public void setParserOverrideName(String name)
public void setSaveWriter(Writer writer)
Writer
object for the saveToWriter action.
The saveToWriter action will then run the save command to
the specified Writer, rather than to the document's file. The save
command makes use of certain settings, such as save.textLimit, to
determine what text is actually saved.
Example of using saveToWriter with an OutputStreamWriter:
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(bytes, "UTF-8"); lpexView.setSaveWriter(writer); lpexView.triggerAction(lpexView.actionId("saveToWriter")); lpexView.setSaveWriter(null); |
Example of using saveToWriter to save to a String:
StringWriter writer = new StringWriter(); lpexView.setSaveWriter(writer); lpexView.doAction(lpexView.actionId("saveToWriter")); lpexView.setSaveWriter(null); String savedDocument = writer.toString(); |
writer
- a Writer object, for example a StringWriter, an
OutputStringWriter (one that uses the default character
encoding or one that uses a named encoding), etc.public LpexCommand defineCommand(String commandName, LpexCommand lpexCommand)
commandName
, or null
if noneLpexCommand
public LpexCommand command(String commandName)
LpexCommand myInsertTextCommand = lpexView.command("myInsertText"); |
public boolean doDefaultCommand(String commandString)
lpexView.doDefaultCommand("insertText xyz"); |
commandString
- command name and optional parameters
true
if the command string is valid (correct command name
and parameters), or false
if the command string is not validpublic boolean doDefaultCommand(LpexDocumentLocation documentLocation, String commandString)
documentLocation
- a document location (element, position) in the
document section currently loaded in the editorcommandString
- command name and optional parameters
true
if valid arguments and command string (correct
command name and parameters), false
otherwisepublic boolean doCommand(String commandString)
A user-defined command modifies the editor command set available in an LPEX view by overriding or extending a default editor command, or by adding an entirely new command. If there is no user-defined command for the specified command string, this method will run the default editor command, if any.
commandString
- command name and optional parameters
true
if the command string is valid (correct command name
and parameters), or false
if the command string is not validdoDefaultCommand(String)
public boolean doCommand(LpexDocumentLocation documentLocation, String commandString)
A user-defined command modifies the editor command set available in an LPEX view by overriding or extending a default editor command, or by adding an entirely new command. If there is no user-defined command for the specified command string, this method will run the default editor command, if any.
documentLocation
- a document location (element, position) in the
document section currently loaded in the editorcommandString
- command name and optional parameters
true
if valid arguments and command string (correct
command name and parameters), false
otherwisedoDefaultCommand(LpexDocumentLocation,String)
public static boolean doGlobalCommand(String commandString)
LpexView.doGlobalCommand("updateProfile all"); LpexView.doGlobalCommand("set default.print.footer %p"); |
commandString
- command name and optional parameters
true
if the command string is valid (correct command name
and parameters), or false
if the command string is not validpublic LpexAction defineAction(String actionName, LpexAction lpexAction)
actionName
, if anyLpexAction
,
actionId(String)
public int actionId(String actionName)
public LpexAction action(String actionName)
public void doDefaultAction(int actionId)
actionId
- id of a default editor actionpublic boolean defaultActionAvailable(int actionId)
actionId
- id of a default editor actionpublic void doAction(int actionId)
Note that the LPEX built-in action ids defined in LpexActionConstants (for example, LpexActionConstants.ACTION_BLOCK_COPY) are reserved for the internal use of the editor, and change between releases. You must query, and eventually cache, the id of a built-in action before using it, for example:
int blockCopyId = lpexView.actionId("blockCopy"); lpexView.triggerAction(blockCopyId); |
actionId
- id of a default or user-defined editor actiontriggerAction(int)
,
actionId(java.lang.String)
public void triggerAction(int actionId)
Note that the LPEX built-in action ids defined in LpexActionConstants (for example, LpexActionConstants.ACTION_BLOCK_COPY) are reserved for the internal use of the editor, and change between releases. You must query, and eventually cache, the id of a built-in action before using it, for example:
int blockCopyId = lpexView.actionId("blockCopy"); lpexView.triggerAction(blockCopyId); |
actionId
- id of a default or user-defined editor actiondoAction(int)
,
actionId(java.lang.String)
public void triggerAction(int actionId, boolean record)
actionId
- id of a default or user-defined editor actionrecord
- record this action in the keystroke recordertriggerAction(int)
public boolean actionAvailable(int actionId)
actionId
- id of a default or user-defined editor actionpublic boolean actionChecked(int actionId)
actionId
- id of a default or user-defined editor actionpublic String actionKey(int actionId)
actionId
- id of a default or user-defined editor action
actionKeyText(int)
public String actionKeyText(int actionId)
actionId
- id of a default or user-defined editor action
actionKey(int)
public static String keyText(String keyString)
keyString
- a key definition, for example, "a-pageDown.t"
public boolean keyAssigned(String keyString)
For example,
boolean assigned = keyAssigned("c-o.t"); |
returns true
if an action was defined and associated with
Ctrl+O in the text area.
public int elements()
Note: the elements editor parameter always returns the number of elements in the complete document.
public void jump(int element, int position)
Note: the locate editor command always applies to elements or lines in the complete document.
element
- an element in the document section currently
loaded in the editorposition
- the position in the element (the position of the first
character in an element is 1)jump(LpexDocumentLocation)
public void jump(LpexDocumentLocation documentLocation)
Note: the locate editor command always applies to elements or lines in the complete document.
documentLocation
- a document location (element, position) in the
document section currently loaded in the editorjump(int,int)
public LpexParser parser()
public int parsePending(int element)
LpexConstants.PARSE_PENDING_CHANGE_MASK
,
LpexConstants.PARSE_PENDING_INSERT_MASK
,
LpexConstants.PARSE_PENDING_NEXT_DELETED_MASK
,
LpexConstants.PARSE_PENDING_PREV_DELETED_MASK
,
LpexConstants.PARSE_PENDING_NEXT_SHOW_DELETED_MASK
,
LpexConstants.PARSE_PENDING_PREV_SHOW_DELETED_MASK
,
LpexConstants.PARSE_PENDING_UNDO_MASK
.
For an element which is not in the parse-pending list of this document view,
the method will return 0.
Note that additional flags may be defined in future releases.
public void elementParsed(int element)
public String elementText(int element)
null
is returned.
If the element has no text, an empty String is returned.
Note: the text editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editorpublic String elementFullText(int element)
null
is returned.
If the element has no text (and no sequence numbers are set), an empty
String is returned.
element
- an element in the document section currently
loaded in the editorelementText(int)
,
lineFullText(int)
public String lineFullText(int line)
null
is returned.
If the line has no text (and no sequence numbers are set), an empty
String is returned.
line
- a line in the document section currently
loaded in the editorelementFullText(int)
public void setElementText(int element, String text)
Note: the text editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editortext
- the text to setpublic boolean show(int element)
Note: the show editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editor
true
if the specified element is a show element in this or
another view of the document; or false
if the element is not available in the document or
is not a show elementviewShow(int)
public boolean viewShow(int element)
The code example below checks whether errorElement
is a parser
embedded message of another view:
boolean otherShow = lpexView.show(errorElement) && !lpexView.viewShow(errorElement); |
element
- an element in the document section currently
loaded in the editor
true
if the specified element is a show element for
this view of the document; or false
if the element is not available in the document, or
is not a show element, or is a show element that belongs to another viewshow(int)
public String elementStyle(int element)
null
is returned.
If the element has no style string set, an empty String is returned.
Note: the style editor parameter applies to the current element.
element
- an element in the section of the document that
is currently loaded in the editorpublic void setElementStyle(int element, String style)
Note: the style editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editorstyle
- the style string to setpublic long elementClasses(int element)
Note: the elementClasses editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editor
public void setElementClasses(int element, long classes)
Note: the elementClasses editor parameter applies to the current element.
element
- an element in the document section currently
loaded in the editorclasses
- bit-mask of the element class(es) to setpublic long registerClass(String className)
classMask(java.lang.String)
public long classMask(String classNames)
registerClass(java.lang.String)
public int currentElement()
Note: the element editor parameter returns the ordinal number of the (current) element in the complete document.
lineOfElement(int)
,
currentPosition()
,
documentLocation()
public int currentPosition()
lpexView.queryInt("position"); |
currentElement()
,
documentLocation()
public LpexDocumentLocation documentLocation()
Note: the element editor parameter returns the ordinal number of the (current) element in the complete document.
currentElement()
,
currentPosition()
public LpexDocumentLocation documentLocation(int charOffset, int eolLength)
This method assumes that a consistent line separator is used throughout the underlying file (section).
charOffset
- ZERO-based character offset from the start of the fileeolLength
- length of file's line separator, for example, 2 for CRLF ("\r\n")charOffset(com.ibm.lpex.core.LpexDocumentLocation, int)
public int charOffset(LpexDocumentLocation documentLocation, int eolLength)
This method assumes that a consistent line separator is used throughout the underlying file (section).
documentLocation
- a location (element, position) in the document
section currently loaded in the editoreolLength
- length of file's line separator, for example, 2 for CRLF ("\r\n")
documentLocation(int,int)
public LpexView lpexView(String documentName)
documentName
- a document name
null
if the document name is null or it is not opened in the editorpublic void setBlockInstance(LpexView lpexView)
Use this method to assign a different block instance for the view. When a view is used as a text widget, for example as a text field in a dialog, it is preferable that it doesn't participate in the global block instance, but have its own instead. Also, several such widgets may share one private block instance.
lpexView
- null
= use the default block instance, or
this
= create own block instance, or
an existing lpexView = use the block instance of the given viewpublic LpexView getBlockView()
null
if there is no selectionpublic String query(String parameter)
public int queryInt(String parameter)
String value = query(parameter); return (value != null)? Integer.parseInt(value) : -1; |
Note that if the underlying query returns null
,
this method returns -1.
query(String)
public boolean queryOn(String parameter)
String value = query(parameter); return value != null && value.equals("on"); |
true
for a valid editor parameter whose value is "on"query(String)
public String query(String parameter, LpexDocumentLocation documentLocation)
documentLocation
- a document location (element, position) in the
document section currently loaded in the editorpublic int queryInt(String parameter, LpexDocumentLocation documentLocation)
String value = query(parameter, documentLocation); return (value != null)? Integer.parseInt(value) : -1; |
Note that if the underlying query returns null
,
this method returns -1.
documentLocation
- a document location (element, position) in the
document section currently loaded in the editorquery(String,LpexDocumentLocation)
public boolean queryOn(String parameter, LpexDocumentLocation documentLocation)
String value = query(parameter, documentLocation); return value != null && value.equals("on"); |
documentLocation
- a document location (element, position) in the
document section currently loaded in the editor
true
for a valid editor parameter whose value is "on"query(String,LpexDocumentLocation)
public int elementOfRow(int row)
Elements include show lines and text lines. Show lines are not saved when the document is saved.
row
- ONE-based screen row
public int elementOfLine(int line)
Elements include show lines and text lines. Show lines are not saved when the document is saved.
Note: the element editor parameter returns the ordinal number of the (current) element in the complete document.
lineOfElement(int)
,
Lines and elementspublic int lineOfElement(int element)
Elements include show lines and text lines. Show lines are not saved when the document is saved.
If the element is a show element, the first document line above it is returned. If the element does not exist, or if there is no document line corresponding to the given element (for example, one or more show elements at the top of the document), this method returns 0.
Note: the line editor parameter returns the ordinal number of the (current) line in the complete document.
currentElement()
,
elementOfLine(int)
,
Lines and elementspublic String deletedMarkName(int markId)
public static String globalQuery(String parameter)
LpexView.globalQuery("version"); |
public boolean setLinesOutsideDocumentSection(int linesBeforeStart, int linesAfterEnd)
This feature is only provided for certain specific applications. Normally, the editor loads and operates on a complete document (file).
A call to this method may fail under certain circumstances. For example,
you cannot use the document section feature when several views have been
opened on the same document. In such a case false
will be
returned.
LpexDocumentSectionListener
public int linesBeforeStart()
LpexDocumentSectionListener
public int linesAfterEnd()
LpexDocumentSectionListener
public void setFieldsProvider(LpexFieldsProvider fieldsProvider)
fieldsProvider
- a (new) fields-setting provider, or
null
to remove any previously set providerLpexFieldsProvider
public void addLpexViewListener(LpexViewListener viewListener)
LpexViewListener
,
removeLpexViewListener(com.ibm.lpex.core.LpexViewListener)
public void removeLpexViewListener(LpexViewListener viewListener)
public void addLpexCursorListener(LpexCursorListener cursorListener)
LpexCursorListener
,
removeLpexCursorListener(com.ibm.lpex.core.LpexCursorListener)
public void removeLpexCursorListener(LpexCursorListener cursorListener)
public void addLpexMarkListener(int markId, LpexMarkListener markListener)
markId
- id of a mark in this document viewmarkListener
- listener to addLpexMarkListener
,
removeLpexMarkListener(int,LpexMarkListener)
,
removeLpexMarkListener(LpexMarkListener)
public void removeLpexMarkListener(int markId, LpexMarkListener markListener)
markId
- id of a mark in this document viewmarkListener
- listener to removepublic void removeLpexMarkListener(LpexMarkListener markListener)
markListener
- listener to removepublic void addLpexDocumentListener(LpexDocumentListener documentListener)
A listener is only registered once, subsequent calls to add the same listener have no effect.
LpexDocumentListener
,
removeLpexDocumentListener(com.ibm.lpex.core.LpexDocumentListener)
,
addLpexDocumentAdjustListener(com.ibm.lpex.core.LpexDocumentListener)
public void removeLpexDocumentListener(LpexDocumentListener documentListener)
public void addLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)
Examples of text being further adjusted when set in the editor: padding of the text up to (the end of) the sequence-numbers area; reinterpretation of document text as sequence numbers; resequencing; MBCS bytes vs. Unicode characters inconsistencies in sequence-numbers columns; MBCS adjustment with spaces added prior to the sequence-numbers area.
A listener is only registered once, subsequent calls to add the same listener have no effect.
LpexDocumentListener
,
addLpexDocumentListener(com.ibm.lpex.core.LpexDocumentListener)
,
removeLpexDocumentAdjustListener(com.ibm.lpex.core.LpexDocumentListener)
public void removeLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)
public void addLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
LpexDocumentSectionListener
,
removeLpexDocumentSectionListener(com.ibm.lpex.core.LpexDocumentSectionListener)
public void removeLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
public static void setClassLoader(ClassLoader classLoader)
Class loaders registered through this method are only used when a class cannot be loaded by the current LPEX loader. Used for loading the user profile, user-defined commands and actions, and document parsers.
public static void extendInstallProfile(Properties extension)
This method should be called before any document views are created. Any of the editor parameters that are available with the install parameter can have installation settings specified in the install profile. Only new "install." values should be set in this manner.
Here is the Install.properties file shipped with LPEX.
Example:
Properties sabreTalkProperties = new Properties(); sabreTalkProperties.setProperty("install.updateProfile.parserClass.sabreTalk", "com.ibm.etools.tpf.sbt.SabreTalkParser"); sabreTalkProperties.setProperty("install.updateProfile.parserAssociation.sbt", "sabreTalk"); sabreTalkProperties.setProperty("install.updateProfile.parserAssociation.SBT", "sabreTalk"); LpexView.extendInstallProfile(sabreTalkProperties); |
public static String getLpexHelpPage(String lpexItem)
For example, getLpexHelpPage("tabs");
will return "ref/rlptabs.htm"
.
An application using LPEX must redefine the help command (by
implementing the LpexCommand
interface) to use its own
help-delivery mechanism.
LpexCommand
public void setOwnerDrawMargin(boolean ownerDraw)
public void addLpexKeyListener(LpexKeyListener keyListener)
doit
field of the event to false
.
A listener is only registered once, subsequent calls to add the same listener have no effect.
LpexKeyListener
,
removeLpexKeyListener(com.ibm.lpex.core.LpexKeyListener)
public void removeLpexKeyListener(LpexKeyListener keyListener)
addLpexKeyListener(com.ibm.lpex.core.LpexKeyListener)
public void setFont(org.eclipse.swt.graphics.Font swtFont)
public org.eclipse.swt.graphics.Font getFont()
public void setBaseEncoding(String fileEncoding)
|
LPEX 4.4.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |