Overview

 
Package  Use  Tree  Serialized  Deprecated  Index  Help 
SWT LPEX
v3.0.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

com.ibm.lpex.core
Class LpexView

java.lang.Object
  extended bycom.ibm.lpex.core.LpexView


public class LpexView
extends Object

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're just extending an existing LPEX-based application, view management (creation, disposal) is usually that application's resposibility.

Lines and elements

Most methods that access the document text use as argument an element ordinal number. An element is any line of text displayed in the LPEX view, including show lines (such as imbedded informational and error messages, not saved with the document). A line represents one line (or record) in the actual document (and its underlying file), as displayed on the LPEX status line.

In general, a document parser skips and ignores show lines:

 
 if (view.show(anElement)) 
  {
   // ignore it
  } 

LpexCharStream also ignores them, and does not send them to a 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() and removeMessages() 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 retrieve the document line number of a non-show 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, 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).

See Also:
LpexWindow


Nested Class Summary
static class LpexView.ViewInstantiationException
          Indicates a failed attempt to create a new 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 actionString)
          Retrieves the specified user-defined action.
 boolean actionAvailable(int actionId)
          Checks whether the specified action is available.
 int actionId(String actionString)
          Retrieves the id of the specified default or user-defined 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 editor 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 editor 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 editor view.
 LpexView blockView()
          Returns the view with the selection, if any.
 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 commandString)
          Retrieves the specified user-defined command.
 org.eclipse.swt.widgets.Widget commandLineFocusWidget()
          Returns the command line widget with the input focus, if any.
 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 actionString, LpexAction lpexAction)
          Defines a user action.
 LpexCommand defineCommand(String commandString, 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).
 int documentViews()
          Returns the number of views on this view's document.
 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 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.
 int elements()
          Retrieves 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.
 org.eclipse.swt.widgets.Shell frame()
          Retrieves the Shell that is used when dialogs are displayed.
 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.
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()
          Retrieves the NLS object associated with this LpexView.
 int notifyTruncateDocument(LpexDocumentListener listener, int textLimit)
          Issues document-listener notifications for the text-limit truncation of a document as done during save.
 void notifyTruncateDocumentRestore(LpexDocumentListener listener, int textLimit, int firstTruncatedElement)
          Issues document-listener notifications to restore the changes resulting from the text-limit truncation of a document as done during save.
 boolean otherShow(int element)
          Determines whether 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)
          Returns the parse-pending state of the specified element.
 LpexParser parser()
          Retrieves 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 editor 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 editor 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 editor view.
 boolean save(Writer writer)
          Saves the entire text of the document (or document section currently loaded in the editor) to the specified Writer.
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 setFont(org.eclipse.swt.graphics.Font swtFont)
          Sets a new font in this view.
 void setFrame(org.eclipse.swt.widgets.Shell frame)
          Sets the Shell that should be used when dialogs are displayed.
 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 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()
          Retrieves 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.
 void trimDocument()
          Trims any trailing blanks in the text of a document, as done during save.
 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

 

 

LpexView

public 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.

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.


 

 

LpexView

public 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. The file's character encoding is assumed to be the native (platform's default) encoding.

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

public LpexView(String fileName)

Use this constructor to create a document from the specified file name. The file's character encoding is assumed to be the native (platform's default) encoding.

The updateProfile command will be called, with the default settings.


 

 

LpexView

public LpexView()

Use this constructor to create an untitled document.

The updateProfile command will be called, with the default settings.


 

 

LpexView

public LpexView(boolean updateProfile)

Use this constructor to create an untitled document, indicating whether the updateProfile command should be called.

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

public LpexView(LpexView lpexView)
         throws LpexView.ViewInstantiationException

Use this constructor to create a new document view from the specified document view.

The updateProfile command will be called, with the default settings.

Throws:
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.


 

 

LpexView

public LpexView(LpexView lpexView,
                boolean updateProfile)
         throws LpexView.ViewInstantiationException

Use this constructor to create a new document view from the specified document view, indicating whether the updateProfile command should be called.

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.

Throws:
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

 

 

dispose

public void dispose()

This method disposes the document view.


 

 

isDisposed

public boolean isDisposed()

Returns whether the document view has been disposed.

See Also:
dispose(), LpexViewListener.disposed(LpexView)


 

 

setWindow

public void setWindow(LpexWindow lpexWindow)

Use this method to associate an LPEX window with this document view.


 

 

window

public LpexWindow window()

Returns the LPEX window currently associated with this view.


 

 

documentViews

public int documentViews()

Returns the number of views on this view's document.


 

 

nls

public LpexNls nls()

Retrieves the NLS object associated with this LpexView. The National Language Support functions in the editor are accessible via this object.

See Also:
LpexNls


 

 

setText

public void setText(String text)

Sets the entire text of the document (or document section).

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.

See Also:
text()


 

 

text

public String text()

Retrieves the entire text of the document (or document section currently loaded in the editor).

See Also:
setText(java.lang.String), save(Writer)


 

 

load

public boolean load(Reader reader)

Loads the entire text of the document (or document section) from the specified 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.

Returns:
true if the text was loaded successfully


 

 

save

public boolean save(Writer writer)

Saves the entire text of the document (or document section currently loaded in the editor) to the specified Writer.

Parameters:
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.
Returns:
true if the text was saved successfully
See Also:
text()


 

 

setSaveWriter

public void setSaveWriter(Writer writer)

Sets the 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(); 

Parameters:
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.


 

 

trimDocument

public void trimDocument()

Trims any trailing blanks in the text of a document, as done during save. During a save operation, trailing blanks are removed from text elements under these conditions:

  • the save command is neither 'save as' (saving under a different file name) nor 'save visible' (saving only visible elements), and
  • the trim parameter was specified for the save command, or no noTrim parameter was specified for the save command and the current.save.trim setting for the view is on.


 

 

notifyTruncateDocument

public int notifyTruncateDocument(LpexDocumentListener listener,
                                  int textLimit)

Issues document-listener notifications for the text-limit truncation of a document as done during save. No actual changes are done in the LPEX document.

During a save operation, text elements saved to the file are truncated to the text-limit value in effect, under these conditions:

  • the save command is neither 'save as' (saving under a different file name) nor 'save visible' (saving only visible elements), and
  • a non-zero textLimit parameter was specified for the save command, or no textLimit parameter was specified for the save command and the current.save.textLimit setting for the view is non-zero.

Returns:
the first truncated text element in the document, or 0 if no truncations needed
See Also:
notifyTruncateDocumentRestore(com.ibm.lpex.core.LpexDocumentListener, int, int)


 

 

notifyTruncateDocumentRestore

public void notifyTruncateDocumentRestore(LpexDocumentListener listener,
                                          int textLimit,
                                          int firstTruncatedElement)

Issues document-listener notifications to restore the changes resulting from the text-limit truncation of a document as done during save. No actual changes are done in the LPEX document.

See Also:
notifyTruncateDocument(com.ibm.lpex.core.LpexDocumentListener, int)


 

 

defineCommand

public LpexCommand defineCommand(String commandString,
                                 LpexCommand lpexCommand)

Defines a user command.

Returns:
the previously user-defined command for this commandString, if any
See Also:
LpexCommand


 

 

command

public LpexCommand command(String commandString)

Retrieves the specified user-defined command. Example:

 
 LpexCommand myInsertTextCommand = lpexView.command("myInsertText"); 


 

 

doDefaultCommand

public boolean doDefaultCommand(String commandString)

Runs the specified default editor command. Example:

 
 lpexView.doDefaultCommand("insertText xyz"); 

Parameters:
commandString - command name and optional parameters
Returns:
true if the command string is valid (correct command name and parameters), or
false if the command string is not valid


 

 

doDefaultCommand

public boolean doDefaultCommand(LpexDocumentLocation documentLocation,
                                String commandString)

Runs the specified default editor command. If the command requires a document location, then the specified document (or document section) location will be used. If the command changes the view's document location, then the specified document location will be updated; the view's actual current (cursor) document location will not be affected, to the extent that its underlying text is not affected.

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor
commandString - command name and optional parameters
Returns:
true if the command string is valid (correct command name and parameters), or
false if the command string is not valid


 

 

doCommand

public boolean doCommand(String commandString)

Runs the specified command.

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.

Parameters:
commandString - command name and optional parameters
Returns:
true if the command string is valid (correct command name and parameters), or
false if the command string is not valid
See Also:
doDefaultCommand(String)


 

 

doCommand

public boolean doCommand(LpexDocumentLocation documentLocation,
                         String commandString)

Runs the specified command at the specified document (or document section) location. If the command requires a document location, then the specified document (or document section) location will be used. If the command changes the view's document location, then the given document location will be updated; the view's actual current (cursor) document location will not be affected, to the extent that its underlying text is not affected.

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.

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor
commandString - command name and optional parameters
Returns:
true if the command string is valid (correct command name and parameters), or
false if the command string is not valid
See Also:
doDefaultCommand(LpexDocumentLocation,String)


 

 

doGlobalCommand

public static boolean doGlobalCommand(String commandString)

Runs the specified global command. The command should be a globally-scoped command, i.e., one that does not require a document view. Examples:

 
 LpexView.doGlobalCommand("updateProfile all");
 LpexView.doGlobalCommand("set default.print.footer %p"); 

Parameters:
commandString - command name and optional parameters
Returns:
true if the command string is valid (correct command name and parameters), or
false if the command string is not valid


 

 

defineAction

public LpexAction defineAction(String actionString,
                               LpexAction lpexAction)

Defines a user action. An action which overrides a default editor action will keep the editor action's id. A new action will be allocated the next available running action id; note that the id of such an action redefined each time the updateProfile command is run will, consequently, change.

Returns:
the previously user-defined action for this actionString, if any
See Also:
LpexAction, actionId(String)


 

 

actionId

public int actionId(String actionString)

Retrieves the id of the specified default or user-defined action.

Returns:
0 if the action is not defined


 

 

action

public LpexAction action(String actionString)

Retrieves the specified user-defined action.


 

 

doDefaultAction

public void doDefaultAction(int actionId)

Runs the default editor action for the specified action id.

Parameters:
actionId - id of a default editor action


 

 

defaultActionAvailable

public boolean defaultActionAvailable(int actionId)

Checks whether the specified default editor action is available.

Parameters:
actionId - id of a default editor action


 

 

doAction

public void doAction(int actionId)

Runs the specified action. Use this method instead of triggerAction() if you are implementing your own command or action. No screen refresh will be done after the action has completed.

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); 

Parameters:
actionId - id of a default or user-defined editor action
See Also:
triggerAction(int), actionId(java.lang.String)


 

 

triggerAction

public void triggerAction(int actionId)

Runs the specified action. Use this method instead of doAction() if you are processing anything other than your own action or command (for example, a listener notification, a menu or toolbar action, etc.). This method ensures that the screen will be refreshed.

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); 

Parameters:
actionId - id of a default or user-defined editor action
See Also:
doAction(int), actionId(java.lang.String)


 

 

triggerAction

public void triggerAction(int actionId,
                          boolean record)

Runs the specified action and optionally records it if keystroke recording is in progress. Applications which employ their own mechanism of mapping (selected) key events to LPEX actions may still want to ensure that these triggered actions are recorded by the keystroke recorder, as if the LPEX widget itself was processing these keys.

Parameters:
actionId - id of a default or user-defined editor action
record - record this action in the keystroke recorder
See Also:
triggerAction(int)


 

 

actionAvailable

public boolean actionAvailable(int actionId)

Checks whether the specified action is available.

Parameters:
actionId - id of a default or user-defined editor action


 

 

actionKey

public String actionKey(int actionId)

Returns the primary key associated with the specified action.

Parameters:
actionId - id of a default or user-defined editor action
Returns:
primary key definition, for example, "a-pageDown.t"
See Also:
actionKeyText(int)


 

 

actionKeyText

public String actionKeyText(int actionId)

Returns a translated text version of the primary key for the specified action.

Parameters:
actionId - id of a default or user-defined editor action
Returns:
primary key, for example, "Alt+Page down"
See Also:
actionKey(int)


 

 

keyText

public static String keyText(String keyString)

Returns a translated text version of a key definition.

Parameters:
keyString - a key definition, for example, "a-pageDown.t"
Returns:
key text, for example, "Alt+Page down"


 

 

keyAssigned

public boolean keyAssigned(String keyString)

Checks whether the specified key is associated with an action. A key associated with action nullAction is considered unassigned. This method allows to associate actions to keys without overriding previous assignments. For example,

 
 keyAssigned("c-o.t"); 

will return true if an action was defined and associated with Ctrl+O in the text area.


 

 

elements

public int elements()

Retrieves the number of elements in the document (or section of the document that is currently loaded in the editor). Elements include show lines and non-show lines. Show lines are not saved when the document is saved.

Note: the elements editor parameter always returns the number of elements in the complete document.


 

 

jump

public 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).

Note: the locate editor command always applies to elements or lines in the complete document.

Parameters:
element - an element in the document section currently loaded in the editor
See Also:
jump(LpexDocumentLocation)


 

 

jump

public 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).

Note: the locate editor command always applies to elements or lines in the complete document.

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor
See Also:
jump(int,int)


 

 

parser

public LpexParser parser()

Retrieves the current document parser for this view.


 

 

parsePending

public int parsePending(int element)

Returns the parse-pending state of the specified element.

Returns:
one or more of these flags:
LpexConstants.PARSE_PENDING_CHANGE_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


 

 

elementParsed

public void elementParsed(int element)

Removes the specified element from the parse-pending list. This view's document parser will not be called for this element until after a subsequent change.


 

 

elementText

public String elementText(int element)

Returns the text of an element in the document (or document section currently loaded in the editor). If there is no such 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.

Parameters:
element - an element in the document section currently loaded in the editor


 

 

elementFullText

public 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). If there is no such element, null is returned. If the element has no text (and no sequence numbers are set), an empty String is returned.

Parameters:
element - an element in the document section currently loaded in the editor
See Also:
elementText(int), lineFullText(int)


 

 

lineFullText

public 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). If there is no such line, null is returned. If the line has no text (and no sequence numbers are set), an empty String is returned.

Parameters:
line - a line in the document section currently loaded in the editor
See Also:
elementFullText(int)


 

 

setElementText

public 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).

Note: the text editor parameter applies to the current element.

Parameters:
element - an element in the document section currently loaded in the editor
text - the text to set


 

 

show

public boolean show(int element)

Returns the show setting for an element in the document (or document section that is currently loaded in the editor).

Note: the show editor parameter applies to the current element.

Parameters:
element - an element in the document section currently loaded in the editor


 

 

otherShow

public boolean otherShow(int element)

Determines whether the specified element in the document (or document section that is currently loaded in the editor) is a show line for another document view.

Parameters:
element - an element in the document section currently loaded in the editor


 

 

elementStyle

public String elementStyle(int element)

Returns the style string for an element in the document (or document section currently loaded in the editor). If there is no such 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.

Parameters:
element - an element in the section of the document that is currently loaded in the editor


 

 

setElementStyle

public 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).

Note: the style editor parameter applies to the current element.

Parameters:
element - an element in the document section currently loaded in the editor
style - the style string to set


 

 

elementClasses

public 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).

Note: the elementClasses editor parameter applies to the current element.

Parameters:
element - an element in the document section currently loaded in the editor
Returns:
the classes bit-mask set in the given element, or 0 if the element was not found


 

 

setElementClasses

public 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).

Note: the elementClasses editor parameter applies to the current element.

Parameters:
element - an element in the document section currently loaded in the editor
classes - bit-mask of the element class(es) to set


 

 

registerClass

public long registerClass(String className)

Registers the specified element class in this view. This method is equivalent to the command set class.className on.

Returns:
the allocated bit-mask of this element class in this view
See Also:
classMask(java.lang.String)


 

 

classMask

public long classMask(String classNames)

Returns the bit-mask allocated in this view for the registered element class(es) named.

See Also:
registerClass(java.lang.String)


 

 

currentElement

public 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). If there is no current element (no elements are visible in the document), this method returns 0. Elements include show lines and non-show 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.

See Also:
lineOfElement(int), currentPosition(), documentLocation()


 

 

currentPosition

public int currentPosition()

Convenience method to retrieve the current (cursor) position within the current (cursor) element. An equivalent command to query the position editor parameter is:

 
 lpexView.queryInt("position"); 

See Also:
currentElement(), documentLocation()


 

 

documentLocation

public LpexDocumentLocation documentLocation()

Returns the view's current (cursor) location in the document (or section of the document that is currently loaded in the editor). If no elements are currently visible, the returned LpexDocumentLocation.element will be 0.

Note: the element editor parameter returns the ordinal number of the (current) element in the complete document.

See Also:
currentElement(), currentPosition()


 

 

documentLocation

public 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). If the specified offset is beyond the end of the document (section), the location returned will be the end of the document (section).

This method assumes that a consistent line separator is used throughout the underlying file (section).

Parameters:
charOffset - ZERO-based character offset from the start of the file
eolLength - length of file's line separator, for example, 2 for CRLF ("\r\n")
See Also:
charOffset(com.ibm.lpex.core.LpexDocumentLocation, int)


 

 

charOffset

public int charOffset(LpexDocumentLocation documentLocation,
                      int eolLength)

Returns a document (or document section) location's Unicode-character offset in its underlying file (section). If the specified location is beyond the end of the document (section), the offset returned will be for the end of the document (section).

This method assumes that a consistent line separator is used throughout the underlying file (section).

Parameters:
documentLocation - a location (element, position) in the document section currently loaded in the editor
eolLength - length of file's line separator, for example, 2 for CRLF ("\r\n")
Returns:
ZERO-based character offset from the start of the file
See Also:
documentLocation(int,int)


 

 

lpexView

public LpexView lpexView(String documentName)

Returns a view handling the given document, if any.

Parameters:
documentName - a document name
Returns:
a view for the specified document, or
null if the document name is null or it is not opened in the editor


 

 

blockView

public LpexView blockView()

Returns the view with the selection, if any. In LPEX there is only one block selection, regardless of the number of documents and views.

Returns:
the document view with the selection, or null if there is no selection


 

 

query

public String query(String parameter)

Queries an editor parameter.


 

 

queryInt

public int queryInt(String parameter)

Convenience method to query an editor integer parameter. Shortcut for

 
 String value = query(parameter);
 return (value != null)? Integer.parseInt(value) : -1

Note that if the underlying query returns null, this method returns -1.

See Also:
query(String)


 

 

queryOn

public boolean queryOn(String parameter)

Convenience method to query an editor on/off parameter. Shortcut for

 
 String value = query(parameter);
 return value != null && value.equals("on"); 

Returns:
true for a valid editor parameter whose value is "on"
See Also:
query(String)


 

 

query

public String query(String parameter,
                    LpexDocumentLocation documentLocation)

Queries an editor parameter. If the parameter requires a document location, then the specified document (or document section) location will be used rather than the view's actual current document (or document section) location.

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor


 

 

queryInt

public int queryInt(String parameter,
                    LpexDocumentLocation documentLocation)

Convenience method to query an editor integer parameter. Shortcut for

 
 String value = query(parameter, documentLocation);
 return (value != null)? Integer.parseInt(value) : -1

Note that if the underlying query returns null, this method returns -1.

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor
See Also:
query(String,LpexDocumentLocation)


 

 

queryOn

public boolean queryOn(String parameter,
                       LpexDocumentLocation documentLocation)

Convenience method to query an editor on/off parameter. Shortcut for

 
 String value = query(parameter, documentLocation); 
 return value != null && value.equals("on"); 

Parameters:
documentLocation - a document location (element, position) in the document section currently loaded in the editor
Returns:
true for a valid editor parameter whose value is "on"
See Also:
query(String,LpexDocumentLocation)


 

 

elementOfRow

public 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. Screen rows are 1 .. n, where n if specified by the rows editor parameter. Elements include show lines and non-show lines. Show lines are not saved when the document is saved.

Returns:
0 if the row doesn't display a visible element


 

 

elementOfLine

public int elementOfLine(int line)

Returns the element for the specified line. Both the specified line and the returned element are defined inside the document section that is currently loaded in the editor. Elements include show lines and non-show 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.

Returns:
0 if the line doesn't exist in the document (or currently loaded section of it)
See Also:
lineOfElement(int)


 

 

lineOfElement

public int lineOfElement(int element)

Returns the line for the specified element. Both the specified element and the returned line are defined inside the document section that is currently loaded in the editor. Elements include show lines and non-show 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.

See Also:
currentElement(), elementOfLine(int)


 

 

deletedMarkName

public String deletedMarkName(int markId)

Returns the name of the deleted mark with the id specified. Can be used during the processing of LpexMarkListener markDeleted() notifications.


 

 

globalQuery

public static String globalQuery(String parameter)

Queries a global editor parameter. The parameter should be a globally-scoped parameter, i.e., one that does not require a document view. Example:

 
 LpexView.globalQuery("version"); 


 

 

setLinesOutsideDocumentSection

public 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.

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.

Returns:
false if unsuccessful
See Also:
LpexDocumentSectionListener


 

 

linesBeforeStart

public int linesBeforeStart()

Returns the number of lines in the document prior to the currently-loaded document section. Normally, the complete document is loaded in the editor, and this method will return 0.

See Also:
LpexDocumentSectionListener


 

 

linesAfterEnd

public int linesAfterEnd()

Returns the number of lines in the document following the currently-loaded document section. Normally, the complete document is loaded in the editor, and this method will return 0.

See Also:
LpexDocumentSectionListener


 

 

addLpexViewListener

public void addLpexViewListener(LpexViewListener viewListener)

Adds a view listener to this editor view. A listener is only registered once, subsequent calls to add the same listener have no effect.

See Also:
LpexViewListener, removeLpexViewListener(com.ibm.lpex.core.LpexViewListener)


 

 

removeLpexViewListener

public void removeLpexViewListener(LpexViewListener viewListener)

Removes a view listener from this editor view. Removes the specified listener if it is registered with this view.


 

 

addLpexCursorListener

public void addLpexCursorListener(LpexCursorListener cursorListener)

Adds a cursor listener to this editor view. A listener is only registered once, subsequent calls to add the same listener have no effect.

See Also:
LpexCursorListener, removeLpexCursorListener(com.ibm.lpex.core.LpexCursorListener)


 

 

removeLpexCursorListener

public void removeLpexCursorListener(LpexCursorListener cursorListener)

Removes a cursor listener from this editor view. Removes the specified listener if it is registered with this view.


 

 

addLpexMarkListener

public void addLpexMarkListener(int markId,
                                LpexMarkListener markListener)

Adds a mark listener to the specified mark.

See Also:
LpexMarkListener, removeLpexMarkListener(int,LpexMarkListener), removeLpexMarkListener(LpexMarkListener)


 

 

removeLpexMarkListener

public void removeLpexMarkListener(int markId,
                                   LpexMarkListener markListener)

Removes a mark listener from the specified mark.


 

 

removeLpexMarkListener

public void removeLpexMarkListener(LpexMarkListener markListener)

Removes a mark listener from all the marks in this document view for which it is registered.


 

 

addLpexDocumentListener

public void addLpexDocumentListener(LpexDocumentListener documentListener)

Adds a document listener to the editor document of this view. In general, the incremental-parser calls are sufficient for an application.

A listener is only registered once, subsequent calls to add the same listener have no effect.

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


 

 

removeLpexDocumentListener

public void removeLpexDocumentListener(LpexDocumentListener documentListener)

Removes a document listener from the editor document of this view. Removes the specified listener if it is registered with this view's document.


 

 

addLpexDocumentAdjustListener

public void addLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)

Adds a document-adjust listener to the editor document of this view. In certain cases, text being set in LPEX will be adjusted depending on the editor settings in effect. While client code which sets text in LPEX will temporarily disable its own document listener during a text-setting operation, it may still need to listen to the text adjustments carried out in the editor.

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.

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


 

 

removeLpexDocumentAdjustListener

public void removeLpexDocumentAdjustListener(LpexDocumentListener documentAdjustListener)

Removes a document-adjust listener from the editor document of this view. Removes the specified listener if it is registered with this view's document.


 

 

addLpexDocumentSectionListener

public void addLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)

Adds a document-section listener to the editor document of this view. A listener is only registered once, subsequent calls to add the same listener have no effect.

See Also:
LpexDocumentSectionListener, removeLpexDocumentSectionListener(com.ibm.lpex.core.LpexDocumentSectionListener)


 

 

removeLpexDocumentSectionListener

public void removeLpexDocumentSectionListener(LpexDocumentSectionListener sectionListener)

Removes a document-section listener from the editor document of this view. Removes the specified listener if it is registered with this view's document.


 

 

setClassLoader

public static void setClassLoader(ClassLoader classLoader)

Sets an alternative class loader to be used by the editor. This method is needed, for example, in the Eclipse workbench, where the LPEX plug-in cannot load a class outside its own runtime library, and consequently cannot process commands such as set updateProfile.parserClass for a parser shipped by another plug-in.

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.


 

 

extendInstallProfile

public static void extendInstallProfile(Properties extension)

Extends the editor install profile. On a platform on which one LPEX instance is shared by several applications (such as the Eclipse platform, where one LPEX plug-in may be used by various solution plug-ins), each application may extend the install profile with additional installation settings of editor parameters. Such settings may be, for example, new document parsers being made available to all the other applications, and their file-extension associations.

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); 


 

 

getLpexHelpPage

public static String getLpexHelpPage(String lpexItem)

Returns the default HTML help panel for the editor item specified. The help panels are defined in the LPEX-help map, com.ibm.lpex.core.HelpCommand.properties. If no suitable help is found, the help panel corresponding to the key "default_help" in the LPEX-help map is returned.

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.

See Also:
LpexCommand


 

 

setFrame

public void setFrame(org.eclipse.swt.widgets.Shell frame)

Sets the Shell that should be used when dialogs are displayed.


 

 

frame

public org.eclipse.swt.widgets.Shell frame()

Retrieves the Shell that is used when dialogs are displayed. This is the Shell of the LpexWindow associated with this view or, if none, the Shell previously set with setFrame().


 

 

commandLineFocusWidget

public org.eclipse.swt.widgets.Widget commandLineFocusWidget()

Returns the command line widget with the input focus, if any. This information is not available from the FocusEvent notifications of a FocusListener on the command line, as these events' widget field is set to the command-line Composite.


 

 

addLpexKeyListener

public void addLpexKeyListener(LpexKeyListener keyListener)

Adds an LPEX key listener to this editor view. A keyPressed(Event) notification is sent by LPEX when a key is pressed. LPEX ignores the key press if the listener consumes the key by setting the doit field of the event to false.

A listener is only registered once, subsequent calls to add the same listener have no effect.

See Also:
LpexKeyListener, removeLpexKeyListener(com.ibm.lpex.core.LpexKeyListener)


 

 

removeLpexKeyListener

public void removeLpexKeyListener(LpexKeyListener keyListener)

Removes the specified LPEX key listener from this editor view. Removes the specified listener if it is registered with this view.

See Also:
addLpexKeyListener(com.ibm.lpex.core.LpexKeyListener)


 

 

setFont

public void setFont(org.eclipse.swt.graphics.Font swtFont)

Sets a new font in this view. The font passed in is an SWT Font.


 

 

getFont

public org.eclipse.swt.graphics.Font getFont()

Returns the font in this view. The font returned is an SWT Font.


 

Overview

 
Package  Use  Tree  Serialized  Deprecated  Index  Help 
SWT LPEX
v3.0.0
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD