|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ibm.lpex.core.LpexView
The class LpexView can be used to manage an LPEX document view. It essentially provides all the editor programming support. Creating an instance of this class creates a document view.
LpexWindow| Constructor Summary | |
LpexView()
This constructor can be used to create an untitled document. |
|
LpexView(boolean updateProfile)
This constructor can be used to create an untitled document, indicating whether the updateProfile command should be called. |
|
LpexView(LpexView lpexView)
This constructor can be used to create a new document view from the specified document view. |
|
LpexView(LpexView lpexView,
boolean updateProfile)
This constructor can be used to create a new document view from the specified document view, indicating whether the updateProfile command should be called. |
|
LpexView(java.lang.String fileName)
This constructor can be used to create a document from the specified file name. |
|
LpexView(java.lang.String fileName,
boolean updateProfile)
This constructor can be used to create a document from the specified file name, indicating whether the updateProfile command should be called. |
|
| Method Summary | |
LpexAction |
action(java.lang.String actionString)
Retrieve the specified action. |
boolean |
actionAvailable(int actionId)
Check whether the specified action is available. |
int |
actionId(java.lang.String actionString)
Retrieve the id of the specified action. |
java.lang.String |
actionKey(int actionId)
Get the primary key associated with the specified action. |
java.lang.String |
actionKeyText(int actionId)
Get a translated text version of the primary key for the specified action. |
void |
addLpexCursorListener(LpexCursorListener cursorListener)
Add a cursor listener to this editor view. |
void |
addLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
Add a document-section listener to the editor document of this view. |
void |
addLpexMarkListener(int markId,
LpexMarkListener markListener)
Add a mark listener to the specified mark. |
void |
addLpexViewListener(LpexViewListener viewListener)
Add a view listener to this editor view. |
int |
charOffset(LpexDocumentLocation documentLocation,
int eolLength)
Get a document (or document section) location's Unicode-character offset in its underlying file (section). |
long |
classMask(java.lang.String names)
Get the bit-mask allocated for the registered element class(es) named. |
LpexCommand |
command(java.lang.String commandString)
Retrieve the specified command. |
org.eclipse.swt.widgets.Widget |
commandLineFocusWidget()
Return the command line widget with the input focus, if any. |
int |
currentElement()
Get 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)
Check whether the specified default editor action is available. |
java.lang.String |
defaultHelp()
Retrieve the default help URL for this view. |
LpexAction |
defineAction(java.lang.String actionString,
LpexAction lpexAction)
Define a user action. |
LpexCommand |
defineCommand(java.lang.String commandString,
LpexCommand lpexCommand)
Define a user command. |
java.lang.String |
deletedMarkName(int markId)
Return the name of the deleted mark with the id specified. |
void |
dispose()
This method disposes the view. |
void |
doAction(int actionId)
Perform the specified action. |
boolean |
doCommand(LpexDocumentLocation documentLocation,
java.lang.String commandString)
Perform the specified command at the specified document (or document section) location. |
boolean |
doCommand(java.lang.String commandString)
Perform the specified command. |
LpexDocumentLocation |
documentLocation()
Get 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)
Get 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)
Perform the default editor action for the specified action id. |
boolean |
doDefaultCommand(LpexDocumentLocation documentLocation,
java.lang.String commandString)
Perform the default editor command for the specified command string. |
boolean |
doDefaultCommand(java.lang.String commandString)
Perform the default editor command for the specified command string. |
static boolean |
doGlobalCommand(java.lang.String commandString)
Perform the specified command. |
long |
elementClasses(int element)
Retrieve the bit-mask of the element classes set in an element of the document (or document section that is currently loaded in the editor). |
int |
elementOfLine(int line)
Retrieve the element for the specified line. |
int |
elementOfRow(int row)
Return 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)
Remove the specified element from the parse-pending list. |
int |
elements()
Retrieve the number of elements in the document (or section of the document that is currently loaded in the editor). |
java.lang.String |
elementStyle(int element)
Get the style string for an element in the document (or document section currently loaded in the editor). |
java.lang.String |
elementText(int element)
Get the text of an element in the document (or document section currently loaded in the editor). |
org.eclipse.swt.widgets.Shell |
frame()
Retrieve the Shell that is used when dialogs are displayed. |
org.eclipse.swt.graphics.Font |
getFont()
Retrieve the font in the view. |
static java.lang.String |
globalQuery(java.lang.String parameter)
Query a global editor parameter. |
void |
jump(int element,
int position)
Move 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)
Move the cursor to the specified position in the document (or section of the document that is currently loaded in the editor). |
boolean |
keyAssigned(java.lang.String keyString)
Check whether the specified key is associated with an action. |
int |
lineOfElement(int element)
Retrieve the line for the specified element. |
int |
linesAfterEnd()
Return the number of lines in the document following the currently-loaded document section. |
int |
linesBeforeStart()
Return the number of lines in the document prior to the currently-loaded document section. |
boolean |
load(java.io.Reader reader)
Load the entire text of the document (or document section) from the specified Reader. |
LpexNls |
nls()
Retrieve the NLS object associated with this LpexView. |
boolean |
otherShow(int element)
Determine if the specified element in the document (or document section that is currently loaded in the editor) is a show line for another document view. |
int |
parsePending(int element)
Query the parse-pending state of the specified element. |
LpexParser |
parser()
Get the current document parser for this view. |
java.lang.String |
query(java.lang.String parameter)
Query an editor parameter. |
java.lang.String |
query(java.lang.String parameter,
LpexDocumentLocation documentLocation)
Query an editor parameter. |
int |
queryInt(java.lang.String parameter)
Convenience method to query an editor integer parameter. |
int |
queryInt(java.lang.String parameter,
LpexDocumentLocation documentLocation)
Convenience method to query an editor integer parameter. |
boolean |
queryOn(java.lang.String parameter)
Convenience method to query an editor on/off parameter. |
boolean |
queryOn(java.lang.String parameter,
LpexDocumentLocation documentLocation)
Convenience method to query an editor on/off parameter. |
long |
registerClass(java.lang.String name)
Register the specified element class. |
void |
removeLpexCursorListener(LpexCursorListener cursorListener)
Remove a cursor listener from this editor view. |
void |
removeLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
Remove a document-section listener from the editor document of this view. |
void |
removeLpexMarkListener(int markId,
LpexMarkListener markListener)
Remove a mark listener from the specified mark. |
void |
removeLpexMarkListener(LpexMarkListener markListener)
Remove a mark listener from all the marks in this document view for which it is registered. |
void |
removeLpexViewListener(LpexViewListener viewListener)
Remove a view listener from this editor view. |
boolean |
save(java.io.Writer writer)
Save the entire text of the document (or document section currently loaded in the ditor) to the specified Writer. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set an alternate class loader to be used by this view. |
void |
setDefaultHelp(java.lang.String URL)
Set the default URL to load for this view when language-sensitive help is not available. |
void |
setElementClasses(int element,
long classes)
Set 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,
java.lang.String style)
Set 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,
java.lang.String text)
Set the text for an element in the document (or document section that is currently loaded in the editor). |
void |
setFont(org.eclipse.swt.graphics.Font swtFont)
Set a new font in the view. |
void |
setFrame(org.eclipse.swt.widgets.Shell frame)
Set the Shell that should be used when dialogs are displayed. |
void |
setLinesOutsideDocumentSection(int linesBeforeStart,
int linesAfterEnd)
Set the number of lines in the complete document outside the boundaries of the currently-loaded document section. |
void |
setSaveLineSeparator(java.lang.String eol)
Set the line separator for the save, saveAs, and saveToWriter actions. |
void |
setSaveWriter(java.io.Writer writer)
Set the Writer object for the saveToWriter action. |
void |
setText(java.lang.String text)
Set 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)
Get the show setting for an element in the document (or document section that is currently loaded in the editor). |
java.lang.String |
text()
Retrieve the entire text of the document (or document section currently loaded in the editor). |
void |
triggerAction(int actionId)
Perform the specified action. |
LpexWindow |
window()
Retrieve 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(java.lang.String fileName,
boolean updateProfile)
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(java.lang.String fileName)
public LpexView()
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)
public LpexView(LpexView 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.
| Method Detail |
public void dispose()
public void setWindow(LpexWindow lpexWindow)
public LpexWindow window()
public LpexNls nls()
LpexNlspublic void setText(java.lang.String text)
text()public java.lang.String text()
setText(java.lang.String),
save(Writer)public boolean load(java.io.Reader reader)
true if the text was loaded successfullypublic boolean save(java.io.Writer writer)
true if the text was saved successfullytext()public void setSaveWriter(java.io.Writer writer)
Writer object for the saveToWriter action.
The saveToWriter action will run the save command to the
specified Writer, instead of 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);
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(); public void setSaveLineSeparator(java.lang.String eol)
lpexView.setSaveLineSeparator("\r\n"); // use Windows-style CR LF
If not set, the platform's default line separator is used.
public LpexCommand defineCommand(java.lang.String commandString,
LpexCommand lpexCommand)
LpexCommandpublic LpexCommand command(java.lang.String commandString)
public boolean doDefaultCommand(java.lang.String commandString)
lpexView.doDefaultCommand("insertText xyz"); true if the command string is valid, or
false if the command string is not valid
public boolean doDefaultCommand(LpexDocumentLocation documentLocation,
java.lang.String commandString)
documentLocation - a document location (element, position) in the
document section currently loaded in the editortrue if the command string is valid, or
false if the command string is not validpublic boolean doCommand(java.lang.String commandString)
true if the command string is valid, or
false if the command string is not validpublic static boolean doGlobalCommand(java.lang.String commandString)
LpexView.doGlobalCommand("updateProfile all"); true if the command string is valid, or
false if the command string is not valid
public boolean doCommand(LpexDocumentLocation documentLocation,
java.lang.String commandString)
documentLocation - a document location (element, position) in the
document section currently loaded in the editortrue if the command string is valid, or
false if the command string is not valid
public LpexAction defineAction(java.lang.String actionString,
LpexAction lpexAction)
actionString, if anyLpexActionpublic int actionId(java.lang.String actionString)
public LpexAction action(java.lang.String actionString)
public void doDefaultAction(int actionId)
public boolean defaultActionAvailable(int actionId)
public void doAction(int actionId)
Note that the LPEX built-in action ids defined in LpexConstants (e.g., LpexConstants.ACTION_BLOCK_COPY) may change between releases. In order to isolate your code from dependency on a certain LPEX release, you should first query, and eventually cache, the id of a built-in action before using it, for example:
int blockCopyId = lpexView.actionId("blockCopy");
lpexView.triggerAction(blockCopyId); triggerAction(int),
actionId(java.lang.String)public boolean actionAvailable(int actionId)
public java.lang.String actionKey(int actionId)
actionKeyText(int)public java.lang.String actionKeyText(int actionId)
actionKey(int)public boolean keyAssigned(java.lang.String keyString)
keyAssigned("c-o.t");
will return true if an action was defined and associated with
Ctrl+O in the text area.public void triggerAction(int actionId)
Note that the LPEX built-in action ids defined in LpexConstants (e.g., LpexConstants.ACTION_BLOCK_COPY) may change between releases. In order to isolate your code from dependency on a certain LPEX release, you should first query, and eventually cache, the id of a built-in action before using it, for example:
int blockCopyId = lpexView.actionId("blockCopy");
lpexView.triggerAction(blockCopyId); doAction(int),
actionId(java.lang.String)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 editorjump(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)
public void elementParsed(int element)
public java.lang.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 editor
public void setElementText(int element,
java.lang.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 editorpublic boolean otherShow(int element)
element - an element in the document section currently
loaded in the editorpublic java.lang.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 editor
public void setElementStyle(int element,
java.lang.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(java.lang.String name)
public long classMask(java.lang.String names)
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)
charOffset - ZERO-based character offset from the start of the fileeolLength - length of file's line delimiter, e.g., 2 for CRLF ("\r\n")charOffset(com.ibm.lpex.core.LpexDocumentLocation, int)
public int charOffset(LpexDocumentLocation documentLocation,
int eolLength)
documentLocation - a location (element, position) in the document
section currently loaded in the editoreolLength - length of file's line delimiter, e.g., 2 for CRLF ("\r\n")documentLocation(int,int)public java.lang.String query(java.lang.String parameter)
public int queryInt(java.lang.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(java.lang.String parameter)
String value = query(parameter);
return value != null && value.equals("on"); true for a valid LPEX parameter whose value is "on"query(String)
public java.lang.String query(java.lang.String parameter,
LpexDocumentLocation documentLocation)
documentLocation - a document location (element, position) in the
document section currently loaded in the editor
public int queryInt(java.lang.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(java.lang.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 editortrue for a valid LPEX parameter whose value is "on"query(String,LpexDocumentLocation)public int elementOfRow(int row)
public int elementOfLine(int line)
Note: the element editor parameter returns the ordinal number of the (current) element in the complete document.
lineOfElement(int)public int lineOfElement(int element)
Note: the line editor parameter returns the ordinal number of the (current) line in the complete document.
currentElement(),
elementOfLine(int)public java.lang.String deletedMarkName(int markId)
public org.eclipse.swt.widgets.Widget commandLineFocusWidget()
public static java.lang.String globalQuery(java.lang.String parameter)
LpexView.globalQuery("version");
public void setLinesOutsideDocumentSection(int linesBeforeStart,
int linesAfterEnd)
LpexDocumentSectionListenerpublic int linesBeforeStart()
LpexDocumentSectionListenerpublic int linesAfterEnd()
LpexDocumentSectionListenerpublic 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)
LpexMarkListener,
removeLpexMarkListener(int,LpexMarkListener),
removeLpexMarkListener(LpexMarkListener)
public void removeLpexMarkListener(int markId,
LpexMarkListener markListener)
public void removeLpexMarkListener(LpexMarkListener markListener)
public void addLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
LpexDocumentSectionListener,
removeLpexDocumentSectionListener(com.ibm.lpex.core.LpexDocumentSectionListener)public void removeLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)
public void setFrame(org.eclipse.swt.widgets.Shell frame)
public org.eclipse.swt.widgets.Shell frame()
public void setClassLoader(java.lang.ClassLoader classLoader)
public void setFont(org.eclipse.swt.graphics.Font swtFont)
public org.eclipse.swt.graphics.Font getFont()
public void setDefaultHelp(java.lang.String URL)
public java.lang.String defaultHelp()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||