com.ibm.lpex.alef
Class LpexTextViewer

java.lang.Object
  |
  +--org.eclipse.jface.viewers.Viewer
        |
        +--com.ibm.lpex.alef.LpexTextViewer
All Implemented Interfaces:
org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.jface.text.ITextOperationTarget, org.eclipse.jface.text.ITextViewer
Direct Known Subclasses:
LpexSourceViewer

public class LpexTextViewer
extends org.eclipse.jface.viewers.Viewer
implements org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.ITextOperationTarget

A line-oriented, LPEX-based partial implementation of org.eclipse.jface.text.ITextViewer. Like TextViewer, once this viewer and its text widget have been created, the viewer can only indirectly be disposed by disposing its primary SWT control (the LpexWindow). Clients should not subclass this class, as it is likely that subclasses will be broken by future releases.

One major difference from TextViewer, this viewer's stream-oriented IDocument is not kept up-to-date with the text changes in the underlying LPEX text widget. Always use LpexView to query the text of the edited document.

Several TextViewer classes, methods, and fields are not available in LpexTextViewer. Most programming of the underlying LPEX widget should be done directly via its LpexView and LpexWindow.

TextViewer classes, methods, and fields which are not available, not implemented, or whose function differs significantly in LpexTextViewer are listed below, along with explanations and any LPEX alternatives. While the list is rather long, it should be noted that several (such as those geared towards specific Eclipse solutions, like the shift-string operations, or those specific to the underlying StyledText) are indicated for completness, even if their visibility is package or private.

Other notable differences:

See Also:
ITextViewer, getLpexView(), getLpexWindow()

Field Summary
protected  int fLastTopPixel
          The last visible vertical position of the top line.
protected  boolean fReplaceTextPresentation
          Indicates whether the viewer's text presentation should be replaced are modified.
protected  java.util.Map fTextHovers
          The text viewer's text hovers.
protected  java.util.List fTextInputListeners
          All registered text input listeners.
protected  java.util.List fViewportListeners
          All registered viewport listeners.
protected static int INTERNAL
          Id for originator of view port changes.
protected static int KEY
          Id for originator of view port changes.
protected static int MOUSE
          Id for originator of view port changes.
protected static int MOUSE_END
          Id for originator of view port changes.
protected static int RESIZE
          Id for originator of view port changes.
protected static int SCROLLER
          Id for originator of view port changes.
static boolean TRACE_ERRORS
           
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Fields inherited from interface org.eclipse.jface.text.ITextOperationTarget
COPY, CUT, DELETE, PASTE, PREFIX, PRINT, REDO, SELECT_ALL, SHIFT_LEFT, SHIFT_RIGHT, STRIP_PREFIX, UNDO
 
Constructor Summary
protected LpexTextViewer()
          Internal-use constructor.
  LpexTextViewer(org.eclipse.swt.widgets.Composite parent, int styles)
          Create an LpexTextViewer with the given SWT style bits.
 
Method Summary
 void activatePlugins()
          Activate the installed TextViewer 'plugins' (hover, etc.).
 void addTextInputListener(org.eclipse.jface.text.ITextInputListener listener)
          Add a text input listener to the ITextViewer.
 void addTextListener(org.eclipse.jface.text.ITextListener listener)
          The implementation of this method does nothing.
 void addViewportListener(org.eclipse.jface.text.IViewportListener listener)
           
 boolean canDoOperation(int operation)
          Check whether the action specified by the operation id can be performed.
 void changeTextPresentation(org.eclipse.jface.text.TextPresentation presentation, boolean controlRedraw)
          This method does nothing.
protected  void createControl(org.eclipse.swt.widgets.Composite parent, int styles)
          Creates the viewer's SWT control.
protected  org.eclipse.jface.text.IDocumentAdapter createDocumentAdapter()
          Factory method to create the document adapter to be used by this viewer.
 void doOperation(int operation)
          Performs the action specified by the operation id.
protected  void fireInputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument oldInput, org.eclipse.jface.text.IDocument newInput)
          Informs all registered text input listeners about the forthcoming input change.
protected  void fireInputDocumentChanged(org.eclipse.jface.text.IDocument oldInput, org.eclipse.jface.text.IDocument newInput)
          Informs all registered text input listeners about the sucessful input change.
 int getBottomIndex()
          Return the ZERO-based index of the visible document-section line with the highest line number.
 int getBottomIndexEndOffset()
          Return the character position which is at the lower-right corner of the widget's viewport, i.e., the visible character with the highest character position.
 org.eclipse.swt.widgets.Control getControl()
          Return the primary SWT Control (LpexWindow) associated with this viewer.
 org.eclipse.jface.text.IDocument getDocument()
          Return this text viewer's stream-oriented IDocument.
 java.lang.String getEOL()
          Return the line delimiter used by the document currently handled by this text viewer.
 org.eclipse.jface.text.IFindReplaceTarget getFindReplaceTarget()
          This method returns null.
 java.lang.Object getInput()
          Return the input (IDocument) of this viewer.
 LpexView getLpexView()
          Retrieve the underlying LPEX text widget view on the document.
 LpexWindow getLpexWindow()
          Retrieve the underlying LPEX text widget window (an SWT Composite).
 org.eclipse.swt.graphics.Point getSelectedRange()
          Return the range of the current selection in coordinates of this viewer's document.
 org.eclipse.jface.viewers.ISelection getSelection()
          Return the current selection.
 org.eclipse.jface.viewers.ISelectionProvider getSelectionProvider()
           
 org.eclipse.jface.text.ITextOperationTarget getTextOperationTarget()
          Return the text-operations target of this viewer.
 org.eclipse.swt.custom.StyledText getTextWidget()
          This method returns null.
 int getTopIndex()
          Return the ZERO-based index of the visible document-section line with the smallest line number.
 int getTopIndexStartOffset()
          Return the character position which is at the upper-left corner of the widget's viewport.
 int getTopInset()
          Return the top, in pixels, of the text-widget screen.
 org.eclipse.jface.text.IDocument getVisibleDocument()
          Returns the viewer's visible document.
protected  int getVisibleLinesInViewport()
          Return the number of rows displayable in the viewport.
 org.eclipse.jface.text.IRegion getVisibleRegion()
          This method always returns a 0,0 region.
protected  int getVisibleRegionOffset()
          This method always returns 0.
protected  void handleDispose()
          Frees all resources allocated by this viewer.
protected  void initializeLpexView(LpexView lpexView)
          Hook to initialize a newly instantiated LpexView.
protected  org.eclipse.jface.text.IRegion internalGetVisibleRegion()
          This method always return null.
 boolean isEditable()
          Query whether the shown text can be manipulated.
protected  boolean isPrintable()
          Query whether the shown text can be printed.
 boolean overlapsWithVisibleRegion(int start, int length)
          This method always returns true.
 void refresh()
          Refresh this viewer completely with information freshly obtained from this viewer's model (its IDocument).
 void removeTextInputListener(org.eclipse.jface.text.ITextInputListener listener)
          Remove the text input listener from the ITextViewer.
 void removeTextListener(org.eclipse.jface.text.ITextListener listener)
          The implementation of this method does nothing.
 void removeViewportListener(org.eclipse.jface.text.IViewportListener listener)
           
 void resetPlugins()
          Resets the installed plug-ins.
 void resetVisibleRegion()
          This method does nothing.
 void revealRange(int start, int end)
          Ensure that the given character range is visible.
protected  java.lang.Object selectContentTypePlugin(int offset, java.util.Map plugins)
          Selects from the given map the one which is registered under the content type of the partition in which the given offset is located.
protected  void selectionChanged(int offset, int len)
          Sends out a selection-changed event to all registered listeners.
 void setAutoIndentStrategy(org.eclipse.jface.text.IAutoIndentStrategy strategy, java.lang.String contentType)
          This method does nothing.
 void setDefaultPrefix(java.lang.String defaultPrefix, java.lang.String contentType)
          This method does nothing in LpexTextViewer.
 void setDocument(org.eclipse.jface.text.IDocument document)
          Set the given IDocument as the text viewer's model, and update the presentation accordingly.
 void setDocument(org.eclipse.jface.text.IDocument document, int visibleRegionOffset, int visibleRegionLength)
          The implementation of this method calls setDocument(document).
 void setEditable(boolean editable)
          Set the editable mode.
protected  void setEditorInput(org.eclipse.ui.IEditorInput editorInput)
          Indicate which is the editor-input resource for this text viewer.
 void setEventConsumer(org.eclipse.jface.text.IEventConsumer consumer)
          This method does nothing.
 void setIndentPrefixes(java.lang.String[] indentPrefixes, java.lang.String contentType)
          This method does nothing.
 void setInput(java.lang.Object input)
          Set or clear the input (IDocument) for this viewer.
 void setSelectedRange(int offset, int length)
          Sets the selection to the specified range.
 void setSelection(org.eclipse.jface.viewers.ISelection selection, boolean reveal)
           
 void setTextColor(org.eclipse.swt.graphics.Color color)
          This method does nothing.
 void setTextColor(org.eclipse.swt.graphics.Color color, int start, int length, boolean controlRedraw)
          This method does nothing.
 void setTextDoubleClickStrategy(org.eclipse.jface.text.ITextDoubleClickStrategy strategy, java.lang.String contentType)
          This method does nothing in LpexTextViewer.
 void setTextHover(org.eclipse.jface.text.ITextHover hover, java.lang.String contentType)
          Defined by ITextViewer, as part of its plugins support.
 void setTopIndex(int index)
          Scrolls the edit window so that ZERO-based index is the smallest document-section line number of all visible lines.
 void setUndoManager(org.eclipse.jface.text.IUndoManager undoManager)
          This method does nothing in LpexTextViewer.
 void setVisibleRegion(int start, int len)
          This method does nothing.
protected  void updateProfile()
          Hook for post-updateProfile command processing.
protected  void updateViewportListeners(int origin)
          Checks whether the viewport changed and if so informs all registered listeners about the change.
 
Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, inputChanged, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_ERRORS

public static boolean TRACE_ERRORS

SCROLLER

protected static final int SCROLLER
Id for originator of view port changes.

MOUSE

protected static final int MOUSE
Id for originator of view port changes.

MOUSE_END

protected static final int MOUSE_END
Id for originator of view port changes.

KEY

protected static final int KEY
Id for originator of view port changes.

RESIZE

protected static final int RESIZE
Id for originator of view port changes.

INTERNAL

protected static final int INTERNAL
Id for originator of view port changes.

fTextHovers

protected java.util.Map fTextHovers
The text viewer's text hovers.

fViewportListeners

protected java.util.List fViewportListeners
All registered viewport listeners.

fLastTopPixel

protected int fLastTopPixel
The last visible vertical position of the top line.

fTextInputListeners

protected java.util.List fTextInputListeners
All registered text input listeners.

fReplaceTextPresentation

protected boolean fReplaceTextPresentation
Indicates whether the viewer's text presentation should be replaced are modified.
Constructor Detail

LpexTextViewer

protected LpexTextViewer()
Internal-use constructor. This constructor is the one called by the extending class LpexSourceViewer; afterwards, methods createControl(), setEditorInput(), and setDocument() will be called.

LpexTextViewer

public LpexTextViewer(org.eclipse.swt.widgets.Composite parent,
                      int styles)
Create an LpexTextViewer with the given SWT style bits. The viewer's text widget (consisting of an LpexView and an LpexWindow) is created.
Parameters:
parent - the parent of the viewer's control
styles - the SWT style bits for the viewer's control
See Also:
createControl(org.eclipse.swt.widgets.Composite, int)
Method Detail

createDocumentAdapter

protected org.eclipse.jface.text.IDocumentAdapter createDocumentAdapter()
Factory method to create the document adapter to be used by this viewer.

IDocumentAdapter adapts an IDocument to the StyledTextContent interface. The document adapter is used by TextViewer to translate IDocument changes into its styled text content changes and vice versa. Clients may implement this interface and override this method if they want to intercept the communication between the viewer's text widget and the viewer's document.

Returns:
the document adapter to be used

createControl

protected void createControl(org.eclipse.swt.widgets.Composite parent,
                             int styles)
Creates the viewer's SWT control. The viewer's text widget is either the control, or is a child of the control. The contents of the text widget will be set later, on setDocument().

Here are the steps carried out by this method:

The user must add their own LPEX actions and commands by extending updateProfile(), which is called when we are notified of the completion of the updateProfile command.

Parameters:
parent - the parent of the viewer's control
styles - the SWT style bits for the viewer's control
See Also:
initializeLpexView(com.ibm.lpex.core.LpexView), updateProfile()

getControl

public org.eclipse.swt.widgets.Control getControl()
Return the primary SWT Control (LpexWindow) associated with this viewer.
Overrides:
getControl in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.getControl()

activatePlugins

public void activatePlugins()
Activate the installed TextViewer 'plugins' (hover, etc.). If the plugins are already activated, this call is without effect.

Defined by ITextViewer, as part of its plugins support.

Specified by:
activatePlugins in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.activatePlugins()

resetPlugins

public void resetPlugins()
Resets the installed plug-ins. If plug-ins change their state or behavior over the course of time, this method causes them to be set back to their initial state and behavior.
Specified by:
resetPlugins in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.resetPlugins()

handleDispose

protected void handleDispose()
Frees all resources allocated by this viewer. Internally called when the viewer's control has been disposed.

getTextWidget

public org.eclipse.swt.custom.StyledText getTextWidget()
This method returns null. In TextViewer, this method returns the StyledText control, its underlying text widget.

Note: Do not use this method in LpexTextViewer. LpexTextViewer uses an LPEX text widget, which consists of an LpexWindow (an SWT Composite) and an LpexView, rather than a StyledText widget.

Specified by:
getTextWidget in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getTextWidget(), getLpexWindow(), getLpexView()

setAutoIndentStrategy

public void setAutoIndentStrategy(org.eclipse.jface.text.IAutoIndentStrategy strategy,
                                  java.lang.String contentType)
This method does nothing.

In TextViewer, this method registers an IAutoIndentStrategy for the given content type. LPEX language parsers handle their own autoindent.

Defined by ITextViewer, as part of its plugins support.

Specified by:
setAutoIndentStrategy in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setAutoIndentStrategy(org.eclipse.jface.text.IAutoIndentStrategy, java.lang.String)

setEventConsumer

public void setEventConsumer(org.eclipse.jface.text.IEventConsumer consumer)
This method does nothing.

In TextViewer, implementers can register and receive VerifyEvents before the text viewer touches them. If the IEventConsumer marks an event as processed, the text viewer will ignore it. For example, keys consumed by a content-assist popup should not be again processed by us (this is not quite AWT's e.consume(), but that's the way Eclipse operates).

Specified by:
setEventConsumer in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setEventConsumer(org.eclipse.jface.text.IEventConsumer)

setIndentPrefixes

public void setIndentPrefixes(java.lang.String[] indentPrefixes,
                              java.lang.String contentType)
This method does nothing. LPEX does not currently support the Eclipse shift operations.

In TextViewer, this method sets the strings that are used as prefixes when lines of the given content type are shifted using the shift operations. Defined by ITextViewer, as part of its plugins support.

Specified by:
setIndentPrefixes in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setIndentPrefixes(java.lang.String[], java.lang.String)

getTopInset

public int getTopInset()
Return the top, in pixels, of the text-widget screen.
Specified by:
getTopInset in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getTopInset()

isEditable

public boolean isEditable()
Query whether the shown text can be manipulated. Preferred method: use the LPEX readonly parameter.
Specified by:
isEditable in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.isEditable()

isPrintable

protected boolean isPrintable()
Query whether the shown text can be printed.
Returns:
the viewer's printable mode

setEditable

public void setEditable(boolean editable)
Set the editable mode. This method is called when an IFile input's desired editable mode is different from the file's read/write attribute, or when the input is IStorage.
Specified by:
setEditable in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setEditable(boolean), isEditable()

setDefaultPrefix

public void setDefaultPrefix(java.lang.String defaultPrefix,
                             java.lang.String contentType)
This method does nothing in LpexTextViewer. LPEX does not currently support the prefix and strip-prefix operations.

Defined by ITextViewer, as part of its plugins support.

Specified by:
setDefaultPrefix in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setDefaultPrefix(java.lang.String, java.lang.String)

setUndoManager

public void setUndoManager(org.eclipse.jface.text.IUndoManager undoManager)
This method does nothing in LpexTextViewer. LPEX uses its own built-in undo manager (with unlimited undo/redo capabilitites), therefore it does not support IUndoManager.

Defined by ITextViewer, as part of its plugins support.

Specified by:
setUndoManager in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setUndoManager(org.eclipse.jface.text.IUndoManager)

setTextHover

public void setTextHover(org.eclipse.jface.text.ITextHover hover,
                         java.lang.String contentType)
Defined by ITextViewer, as part of its plugins support.
Specified by:
setTextHover in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setTextHover(org.eclipse.jface.text.ITextHover, java.lang.String)

getSelectedRange

public org.eclipse.swt.graphics.Point getSelectedRange()
Return the range of the current selection in coordinates of this viewer's document. Returns the start and length of the selection: x is the offset of the first selected character relative to the first character of the widget content, y is the length of the selection.

In LPEX, this stream-oriented method is inefficient, and should be avoided.

Specified by:
getSelectedRange in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getSelectedRange()

setSelectedRange

public void setSelectedRange(int offset,
                             int length)
Sets the selection to the specified range.

In LPEX, this stream-oriented method is inefficient, and should be avoided. To set selections, use the block command. To reposition the cursor, use the locate command and the position parameter.

Specified by:
setSelectedRange in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setSelectedRange(int, int)

setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection selection,
                         boolean reveal)
Overrides:
setSelection in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.setSelection(ISelection)

getSelection

public org.eclipse.jface.viewers.ISelection getSelection()
Return the current selection.

In LPEX, this stream-oriented method is inefficient, and should be avoided.

Overrides:
getSelection in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.getSelection()

getSelectionProvider

public org.eclipse.jface.viewers.ISelectionProvider getSelectionProvider()
Specified by:
getSelectionProvider in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getSelectionProvider()

selectionChanged

protected void selectionChanged(int offset,
                                int len)
Sends out a selection-changed event to all registered listeners.
Parameters:
offset - the offset of the newly selected range
len - the length of the newly selected range

addTextListener

public void addTextListener(org.eclipse.jface.text.ITextListener listener)
The implementation of this method does nothing.

In TextViewer, this method adds a text listener to the text widget. A listener is registered only once, subsequent calls are without effect.

Specified by:
addTextListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.addTextListener(org.eclipse.jface.text.ITextListener)

removeTextListener

public void removeTextListener(org.eclipse.jface.text.ITextListener listener)
The implementation of this method does nothing.

In TextViewer, this method removes the text listener from the text widget. If the listener is not registered with the widget, the call is without effect.

Specified by:
removeTextListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.removeTextListener(org.eclipse.jface.text.ITextListener)

addTextInputListener

public void addTextInputListener(org.eclipse.jface.text.ITextInputListener listener)
Add a text input listener to the ITextViewer. A listener is registered only once, subsequent calls are without effect.

Text input listeners registered with a text viewer are informed when the document serving as the text viewer's model is replaced.

Specified by:
addTextInputListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.addTextInputListener(org.eclipse.jface.text.ITextInputListener)

removeTextInputListener

public void removeTextInputListener(org.eclipse.jface.text.ITextInputListener listener)
Remove the text input listener from the ITextViewer. If the listener is not registered with the viewer, the call is without effect.
Specified by:
removeTextInputListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.removeTextInputListener(org.eclipse.jface.text.ITextInputListener)

fireInputDocumentAboutToBeChanged

protected void fireInputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument oldInput,
                                                 org.eclipse.jface.text.IDocument newInput)
Informs all registered text input listeners about the forthcoming input change.
Parameters:
oldInput - the old input document
newInput - the new input document

fireInputDocumentChanged

protected void fireInputDocumentChanged(org.eclipse.jface.text.IDocument oldInput,
                                        org.eclipse.jface.text.IDocument newInput)
Informs all registered text input listeners about the sucessful input change.
Parameters:
oldInput - the old input document
newInput - the new input document

getInput

public java.lang.Object getInput()
Return the input (IDocument) of this viewer. Note that LPEX does not maintain this IDocument in sync with the contents of its text widget during the edit session.
Overrides:
getInput in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.getInput()

getDocument

public org.eclipse.jface.text.IDocument getDocument()
Return this text viewer's stream-oriented IDocument. Note that LPEX does not maintain this IDocument in sync with the contents of its text widget during the edit session.

Defined by ITextViewer, as part of its model-manipulation support.

Specified by:
getDocument in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getDocument()

setInput

public void setInput(java.lang.Object input)
Set or clear the input (IDocument) for this viewer.
Overrides:
setInput in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.setInput(java.lang.Object)

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document)
Set the given IDocument as the text viewer's model, and update the presentation accordingly. An approriate TextEvent is issued. The text event does not carry a related document event, though.

Defined by ITextViewer, as part of its model-manipulation support.

Specified by:
setDocument in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setDocument(IDocument)

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document,
                        int visibleRegionOffset,
                        int visibleRegionLength)
The implementation of this method calls setDocument(document). In LpexTextViewer, the visible document (or currently-loaded document section) is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attributes. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this is a convenience method for

   setDocument(document);
   setVisibleRegion(offset, length) 
It is defined by ITextViewer as part of its visible-region support.
Specified by:
setDocument in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setDocument(IDocument,int,int), setDocument(IDocument)

addViewportListener

public void addViewportListener(org.eclipse.jface.text.IViewportListener listener)
Specified by:
addViewportListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.addViewportListener(org.eclipse.jface.text.IViewportListener)

removeViewportListener

public void removeViewportListener(org.eclipse.jface.text.IViewportListener listener)
Specified by:
removeViewportListener in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.removeViewportListener(org.eclipse.jface.text.IViewportListener)

updateViewportListeners

protected void updateViewportListeners(int origin)
Checks whether the viewport changed and if so informs all registered listeners about the change.
Parameters:
origin - describes under which circumstances this method has been called.
See Also:
IViewportListener

getTopIndex

public int getTopIndex()
Return the ZERO-based index of the visible document-section line with the smallest line number.
Specified by:
getTopIndex in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getTopIndex()

getTopIndexStartOffset

public int getTopIndexStartOffset()
Return the character position which is at the upper-left corner of the widget's viewport.
Specified by:
getTopIndexStartOffset in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getTopIndexStartOffset()

setTopIndex

public void setTopIndex(int index)
Scrolls the edit window so that ZERO-based index is the smallest document-section line number of all visible lines.

Preferred method: in LPEX you may consider various options, depending on the intended usage. For example, to set the cursor in the edit window on a certain line in the document:

   LpexView lpexView = getLpexView();
   lpexView.doCommand("locate emphasis line " +
                      (index + 1 + lpexView.linesBeforeStart()));
   lpexView.triggerAction(lpexView.actionId("textWindow"));
To position the line that contains the cursor on a certain screen row:
   LpexView lpexView = getLpexView();
   lpexView.doCommand("set cursorRow " + row);
   lpexView.doDefaultCommand("screenShow");

You must consider certain characteristics of the LPEX edit window, such as:

Specified by:
setTopIndex in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setTopIndex(int)

getVisibleLinesInViewport

protected int getVisibleLinesInViewport()
Return the number of rows displayable in the viewport. The actual document lines displayed in the edit window may be fewer, when the document is shorter or some lines are not visible.

Preferred method: use getLpexView().queryInt("rows").

Returns:
the viewport height in lines

getBottomIndex

public int getBottomIndex()
Return the ZERO-based index of the visible document-section line with the highest line number.
Specified by:
getBottomIndex in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getBottomIndex()

getBottomIndexEndOffset

public int getBottomIndexEndOffset()
Return the character position which is at the lower-right corner of the widget's viewport, i.e., the visible character with the highest character position. If the content of the widget is shorter, the last character of the content is returned.
Specified by:
getBottomIndexEndOffset in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getBottomIndexEndOffset()

revealRange

public void revealRange(int start,
                        int end)
Ensure that the given character range is visible.
Specified by:
revealRange in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.revealRange(int, int)

refresh

public void refresh()
Refresh this viewer completely with information freshly obtained from this viewer's model (its IDocument). The implementation of this method does a setDocument(getDocument());
Overrides:
refresh in class org.eclipse.jface.viewers.Viewer
See Also:
Viewer.refresh(), setDocument(IDocument)

getVisibleDocument

public org.eclipse.jface.text.IDocument getVisibleDocument()
Returns the viewer's visible document. The visible document represents the visible region of the viewer's input document. In LPEX, the visible document (or currently-loaded document section) is always the viewer's entire input document.
Returns:
the viewer's visible document

getVisibleRegionOffset

protected int getVisibleRegionOffset()
This method always returns 0. In LpexTextViewer, the visible document (or document section) is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attributes. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method returns the offset of the visible region.


getVisibleRegion

public org.eclipse.jface.text.IRegion getVisibleRegion()
This method always returns a 0,0 region. In LpexTextViewer, the visible document (or document section) is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attributes. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method returns the current visible region of this viewer's document. Defined by ITextViewer as part of its visible-region support.

Specified by:
getVisibleRegion in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getVisibleRegion()

setVisibleRegion

public void setVisibleRegion(int start,
                             int len)
This method does nothing. In LpexTextViewer, the visible document (or document section) is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attributes. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method sets the region of this viewer's document which will be visible in the presentation. It does this by defining a child document for this region, and setting it as the visible document for the text widget (i.e., reloading the text widgets with the contents of this child document). It is defined by ITextViewer as part of its visible-region support.

Specified by:
setVisibleRegion in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setVisibleRegion(int, int)

resetVisibleRegion

public void resetVisibleRegion()
This method does nothing. In LpexTextViewer, the visible document (or document section) is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attributes. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method resets the region of this viewer's document which is visible in the presentation, so that the whole document is presented again. It is defined by ITextViewer, as part of its visible-region support.

Specified by:
resetVisibleRegion in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.resetVisibleRegion()

overlapsWithVisibleRegion

public boolean overlapsWithVisibleRegion(int start,
                                         int length)
This method always returns true. In LpexTextViewer, the visible document is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attribute. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method returns whether a given range overlaps with the visible region of this viewer's document. It is defined by ITextViewer, as part of its visible-region support.

Specified by:
overlapsWithVisibleRegion in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.overlapsWithVisibleRegion(int, int)

setTextDoubleClickStrategy

public void setTextDoubleClickStrategy(org.eclipse.jface.text.ITextDoubleClickStrategy strategy,
                                       java.lang.String contentType)
This method does nothing in LpexTextViewer. LPEX has its own double-click actions, therefore it doesn't support ITextDoubleClickStrategy. Token/word selection and bracket matching can be customized via new LpexActions.

Defined by ITextViewer, as part of its plugins support.

Specified by:
setTextDoubleClickStrategy in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setTextDoubleClickStrategy(org.eclipse.jface.text.ITextDoubleClickStrategy, java.lang.String)

selectContentTypePlugin

protected java.lang.Object selectContentTypePlugin(int offset,
                                                   java.util.Map plugins)
Selects from the given map the one which is registered under the content type of the partition in which the given offset is located.
Parameters:
offset - the offset for which to find the plugin
plugins - the map from which to choose
Returns:
the plugin registered under the offset's content type

canDoOperation

public boolean canDoOperation(int operation)
Check whether the action specified by the operation id can be performed.

Note that most LPEX actions (as defined in e.g., LpexAbstractTextEditor) call the editor directly for querying availability.

Specified by:
canDoOperation in interface org.eclipse.jface.text.ITextOperationTarget
Parameters:
operation - LPEX-defined operation id (including the equivalents of ITextOperationTarget.UNDO, .REDO, etc.)
See Also:
ITextOperationTarget.canDoOperation(int)

doOperation

public void doOperation(int operation)
Performs the action specified by the operation id. This method may be called when canDoOperation() returns true.

Note that most LPEX actions (as defined in e.g., LpexAbstractTextEditor) call the editor directly.

Specified by:
doOperation in interface org.eclipse.jface.text.ITextOperationTarget
Parameters:
operation - LPEX-defined operation id (including the equivalents of ITextOperationTarget.UNDO, .REDO, etc.)
See Also:
ITextOperationTarget.doOperation(int)

setTextColor

public void setTextColor(org.eclipse.swt.graphics.Color color)
This method does nothing. LPEX parsers set display attributes to text in the parsed document. Also, LPEX marks can be set with certain style, visibility, and protection attributes. See the mark and related parameters.

Defined by ITextViewer, as part of its presentation-manipulation support.

Specified by:
setTextColor in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setTextColor(Color)

setTextColor

public void setTextColor(org.eclipse.swt.graphics.Color color,
                         int start,
                         int length,
                         boolean controlRedraw)
This method does nothing. LPEX parsers set display attributes to text in the parsed document. Also, LPEX marks can be set with certain style, visibility, and protection attributes. See the mark and related parameters.

Defined by ITextViewer, as part of its presentation-manipulation support.

Specified by:
setTextColor in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.setTextColor(Color,int,int,boolean)

internalGetVisibleRegion

protected org.eclipse.jface.text.IRegion internalGetVisibleRegion()
This method always return null. In LpexTextViewer, the visible document is always the viewer's (entire) input document. To display only certain region(s) of the document in the viewer, set marks for these regions, and set their included or excluded attribute. See the mark, markIncluded, and markExcluded parameters.

In TextViewer, this method returns the visible region if it is not equal to the whole document, or null if it is.


changeTextPresentation

public void changeTextPresentation(org.eclipse.jface.text.TextPresentation presentation,
                                   boolean controlRedraw)
This method does nothing. LPEX parsers set display attributes to text in the parsed document. Also, LPEX marks can be set with certain style, visibility, and protection attributes. See the mark and related parameters.

In TextViewer, this method applies in the text widget the color information of the specified text presentation.

Defined by ITextViewer, as part of its presentation-manipulation support.

Specified by:
changeTextPresentation in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.changeTextPresentation(org.eclipse.jface.text.TextPresentation, boolean)

getFindReplaceTarget

public org.eclipse.jface.text.IFindReplaceTarget getFindReplaceTarget()
This method returns null. LPEX implements its own findAndReplace action.

Defined by ITextViewer, as part of its target-handling support.

Specified by:
getFindReplaceTarget in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getFindReplaceTarget()

getTextOperationTarget

public org.eclipse.jface.text.ITextOperationTarget getTextOperationTarget()
Return the text-operations target of this viewer.

Defined by ITextViewer, as part of its target-handling support.

Specified by:
getTextOperationTarget in interface org.eclipse.jface.text.ITextViewer
See Also:
ITextViewer.getTextOperationTarget()

initializeLpexView

protected void initializeLpexView(LpexView lpexView)
Hook to initialize a newly instantiated LpexView. Called from createControl().

Extend this method to set any file/view-specific parameters for this LpexView. Here you may set any "File Open" preferences page settings for your solution's plugin, such as sequenceNumbers, sourceEncoding, save.textLimit, and save.trim. The updateProfile command will be called later.

See Also:
createControl(org.eclipse.swt.widgets.Composite, int)

updateProfile

protected void updateProfile()
Hook for post-updateProfile command processing. Extend this method to define your own LPEX actions (and assign them to keys), and your own LPEX commands. Ensure you also call super.updateProfile().

Called when a new LpexTextViewer is created (an LPEX document is opened), and whenever the updateProfile command is issued afterwards.


setEditorInput

protected void setEditorInput(org.eclipse.ui.IEditorInput editorInput)
Indicate which is the editor-input resource for this text viewer. LPEX uses this to set its document name. The LPEX document name determines the document parser activated on this document, and is used by the load and save commands for IFiles.

This method should be called prior to the setDocument() for this text viewer, and whenever the input changes for this text viewer.


getLpexWindow

public LpexWindow getLpexWindow()
Retrieve the underlying LPEX text widget window (an SWT Composite).
Returns:
null if the text widget was not yet created, or was disposed

getLpexView

public LpexView getLpexView()
Retrieve the underlying LPEX text widget view on the document.
Returns:
null if the text widget was not yet created, or was disposed

getEOL

public java.lang.String getEOL()
Return the line delimiter used by the document currently handled by this text viewer. This method assumes that a consistent line separator is used throughout the document (i.e., throughout the original underlying file resource).