com.ibm.lpex.alef
Class LpexSourceViewer

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

public class LpexSourceViewer
extends LpexTextViewer
implements org.eclipse.jface.text.source.ISourceViewer

A line-oriented, LPEX-based partial implementation of org.eclipse.jface.text.source.ISourceViewer. A source viewer uses an IVerticalRuler as its annotation presentation area. The vertical ruler is a small strip shown left of the viewer's text widget.

Clients should not subclass this class, as it is quite likely that subclasses will be broken by future releases.

One major difference from SourceViewer, this viewer's stream-oriented IDocument is not kept up-to-date with the text changes in the underlying LPEX text widget.

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

See Also:
LpexTextViewer

Field Summary
protected  org.eclipse.jface.text.source.IAnnotationHover fAnnotationHover
          The viewer's annotation hover.
protected  IContentAssistant fContentAssistant
          The viewer's content assistant.
protected  org.eclipse.jface.text.formatter.IContentFormatter fContentFormatter
          The viewer's content formatter.
protected  org.eclipse.jface.text.presentation.IPresentationReconciler fPresentationReconciler
          The viewer's presentation reconciler.
protected  org.eclipse.jface.text.reconciler.IReconciler fReconciler
          The viewer's model reconciler.
protected static int GAP_SIZE
          The size of the gap between the vertical ruler and the text widget.
 
Fields inherited from class com.ibm.lpex.alef.LpexTextViewer
fLastTopPixel, fReplaceTextPresentation, fTextHovers, fTextInputListeners, fViewportListeners, INTERNAL, KEY, MOUSE, MOUSE_END, RESIZE, SCROLLER, TRACE_ERRORS
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Fields inherited from interface org.eclipse.jface.text.source.ISourceViewer
CONTENTASSIST_CONTEXT_INFORMATION, CONTENTASSIST_PROPOSALS, FORMAT
 
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
LpexSourceViewer(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.texteditor.ITextEditor textEditor, org.eclipse.jface.text.source.IVerticalRuler ruler, int styles)
          Constructs a new LPEX source viewer.
 
Method Summary
 void activatePlugins()
          Activate the installed TextViewer 'plugins' (hover, etc.).
 boolean canDoOperation(int operation)
          Check whether the action specified by the operation id can be performed.
 void configure(org.eclipse.jface.text.source.SourceViewerConfiguration configuration)
          Configure the source viewer as described in the configuration.
protected  void createControl(org.eclipse.swt.widgets.Composite parent, int styles)
          Creates the viewer's SWT control.
 void doOperation(int operation)
          Performs the action specified by the operation id.
 org.eclipse.jface.text.source.IAnnotationModel getAnnotationModel()
          Return this viewer's annotation model.
 org.eclipse.swt.widgets.Control getControl()
          Return the primary SWT Control (LpexWindow) associated with this viewer.
 org.eclipse.jface.text.IRegion getRangeIndication()
           
protected  void handleDispose()
          Free all resources allocated by this viewer.
protected  void initializeLpexView(LpexView lpexView)
          Hook to initialize a newly instantiated LpexView during the construction of this SourceViewer.
 void removeRangeIndication()
          Remove the viewer's range indication.
 void setAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover annotationHover)
           
 void setDocument(org.eclipse.jface.text.IDocument document)
          Set the viewer's IDocument.
 void setDocument(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.source.IAnnotationModel annotationModel)
          Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations.
 void setDocument(org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.source.IAnnotationModel annotationModel, int visibleRegionOffset, int visibleRegionLength)
          Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations.
 void setDocument(org.eclipse.jface.text.IDocument document, int visibleRegionOffset, int visibleRegionLength)
          This method just sets the viewer's IDocument.
 void setRangeIndication(int start, int len, boolean moveCursor)
          Set the viewers's range indication to the specified range.
 void setRangeIndicator(org.eclipse.jface.text.source.Annotation rangeIndicator)
          Set the annotation used as range indicator for the viewer's vertical ruler.
 void showAnnotations(boolean show)
          Control the visibility of annotations and, in the case of separate presentation areas of text and annotations, the visibility of the annotation's presentation area.
protected  void updateProfile()
          Hook for post-updateProfile command processing.
 
Methods inherited from class com.ibm.lpex.alef.LpexTextViewer
addTextInputListener, addTextListener, addViewportListener, changeTextPresentation, createDocumentAdapter, fireInputDocumentAboutToBeChanged, fireInputDocumentChanged, getBottomIndex, getBottomIndexEndOffset, getDocument, getEOL, getFindReplaceTarget, getInput, getLpexView, getLpexWindow, getSelectedRange, getSelection, getSelectionProvider, getTextOperationTarget, getTextWidget, getTopIndex, getTopIndexStartOffset, getTopInset, getVisibleDocument, getVisibleLinesInViewport, getVisibleRegion, getVisibleRegionOffset, internalGetVisibleRegion, isEditable, isPrintable, overlapsWithVisibleRegion, refresh, removeTextInputListener, removeTextListener, removeViewportListener, resetPlugins, resetVisibleRegion, revealRange, selectContentTypePlugin, selectionChanged, setAutoIndentStrategy, setDefaultPrefix, setEditable, setEditorInput, setEventConsumer, setIndentPrefixes, setInput, setSelectedRange, setSelection, setTextColor, setTextColor, setTextDoubleClickStrategy, setTextHover, setTopIndex, setUndoManager, setVisibleRegion, updateViewportListeners
 
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
 
Methods inherited from interface org.eclipse.jface.text.ITextViewer
addTextInputListener, addTextListener, addViewportListener, changeTextPresentation, getBottomIndex, getBottomIndexEndOffset, getDocument, getFindReplaceTarget, getSelectedRange, getSelectionProvider, getTextOperationTarget, getTextWidget, getTopIndex, getTopIndexStartOffset, getTopInset, getVisibleRegion, isEditable, overlapsWithVisibleRegion, removeTextInputListener, removeTextListener, removeViewportListener, resetPlugins, resetVisibleRegion, revealRange, setAutoIndentStrategy, setDefaultPrefix, setEditable, setEventConsumer, setIndentPrefixes, setSelectedRange, setTextColor, setTextColor, setTextDoubleClickStrategy, setTextHover, setTopIndex, setUndoManager, setVisibleRegion
 

Field Detail

fContentAssistant

protected IContentAssistant fContentAssistant
The viewer's content assistant.

fContentFormatter

protected org.eclipse.jface.text.formatter.IContentFormatter fContentFormatter
The viewer's content formatter.

fReconciler

protected org.eclipse.jface.text.reconciler.IReconciler fReconciler
The viewer's model reconciler.

fPresentationReconciler

protected org.eclipse.jface.text.presentation.IPresentationReconciler fPresentationReconciler
The viewer's presentation reconciler.

fAnnotationHover

protected org.eclipse.jface.text.source.IAnnotationHover fAnnotationHover
The viewer's annotation hover.

GAP_SIZE

protected static final int GAP_SIZE
The size of the gap between the vertical ruler and the text widget.
Constructor Detail

LpexSourceViewer

public LpexSourceViewer(org.eclipse.swt.widgets.Composite parent,
                        org.eclipse.ui.texteditor.ITextEditor textEditor,
                        org.eclipse.jface.text.source.IVerticalRuler ruler,
                        int styles)
Constructs a new LPEX source viewer. The vertical ruler is initially visible. The viewer has not yet been initialized with a source viewer configuration.
Parameters:
parent - the parent of the viewer's control
textEditor - the LpexAbstractTextEditor instantiating this source viewer
ruler - the vertical ruler used by this source viewer
Method Detail

createControl

protected void createControl(org.eclipse.swt.widgets.Composite parent,
                             int styles)
Description copied from class: LpexTextViewer
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.

Overrides:
createControl in class LpexTextViewer
See Also:
LpexTextViewer.createControl(org.eclipse.swt.widgets.Composite, int)

setAnnotationHover

public void setAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover annotationHover)
Specified by:
setAnnotationHover in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.setAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover)

configure

public void configure(org.eclipse.jface.text.source.SourceViewerConfiguration configuration)
Configure the source viewer as described in the configuration.

You should use an LpexSourceViewerConfiguration-based class to configure an LpexSourceViewer.

LpexSourceViewer does not use/implement certain (Lpex)SourceViewerConfiguration features.

Specified by:
configure in interface org.eclipse.jface.text.source.ISourceViewer
Parameters:
configuration - an LpexSourceViewerConfiguration
See Also:
LpexSourceViewerConfiguration, ISourceViewer.configure(org.eclipse.jface.text.source.SourceViewerConfiguration), LpexCommonParser

activatePlugins

public void activatePlugins()
Description copied from class: LpexTextViewer
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
Overrides:
activatePlugins in class LpexTextViewer
See Also:
LpexTextViewer.activatePlugins()

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document)
Set the viewer's IDocument.
Specified by:
setDocument in interface org.eclipse.jface.text.ITextViewer
Overrides:
setDocument in class LpexTextViewer
Following copied from class: com.ibm.lpex.alef.LpexTextViewer
See Also:
ITextViewer.setDocument(IDocument)

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document,
                        int visibleRegionOffset,
                        int visibleRegionLength)
This method just sets the viewer's IDocument.

In LpexSourceViewer, 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 SourceViewer, this method sets the viewer's document and the visible region.

Specified by:
setDocument in interface org.eclipse.jface.text.ITextViewer
Overrides:
setDocument in class LpexTextViewer
Following copied from class: com.ibm.lpex.alef.LpexTextViewer
See Also:
ITextViewer.setDocument(IDocument,int,int), LpexTextViewer.setDocument(IDocument)

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document,
                        org.eclipse.jface.text.source.IAnnotationModel annotationModel)
Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations. The presentation is accordingly updated. An appropriate TextEvent is issued. This text event does not carry a related document event.
Specified by:
setDocument in interface org.eclipse.jface.text.source.ISourceViewer
Parameters:
document - the viewer's new input document
annotationModel - the model for the viewer's visual annotations
See Also:
ISourceViewer.setDocument(IDocument, IAnnotationModel)

setDocument

public void setDocument(org.eclipse.jface.text.IDocument document,
                        org.eclipse.jface.text.source.IAnnotationModel annotationModel,
                        int visibleRegionOffset,
                        int visibleRegionLength)
Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations. In LpexSourceViewer, 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 SourceViewer, the presentation is also updated, whereby only the specified region is made visible. In SourceViewer, this is a convenience method for

   setDocument(document, annotationModel);
   setVisibleRegion(offset, length) 
Specified by:
setDocument in interface org.eclipse.jface.text.source.ISourceViewer
Parameters:
document - the new input document
annotationModel - the model of the viewer's visual annotations
See Also:
ISourceViewer.setDocument(IDocument,IAnnotationModel,int,int)

getAnnotationModel

public org.eclipse.jface.text.source.IAnnotationModel getAnnotationModel()
Return this viewer's annotation model.
Specified by:
getAnnotationModel in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.getAnnotationModel()

handleDispose

protected void handleDispose()
Free all resources allocated by this viewer. Extends LpexTextViewer's.
Overrides:
handleDispose in class LpexTextViewer
See Also:
LpexTextViewer.handleDispose()

canDoOperation

public boolean canDoOperation(int operation)
Description copied from class: LpexTextViewer
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.

Overrides:
canDoOperation in class LpexTextViewer
See Also:
ITextOperationTarget.canDoOperation(int)

doOperation

public void doOperation(int operation)
Description copied from class: LpexTextViewer
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.

Overrides:
doOperation in class LpexTextViewer
See Also:
ITextOperationTarget.doOperation(int)

setRangeIndicator

public void setRangeIndicator(org.eclipse.jface.text.source.Annotation rangeIndicator)
Set the annotation used as range indicator for the viewer's vertical ruler.
Specified by:
setRangeIndicator in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.setRangeIndicator(org.eclipse.jface.text.source.Annotation)

setRangeIndication

public void setRangeIndication(int start,
                               int len,
                               boolean moveCursor)
Set the viewers's range indication to the specified range.
Specified by:
setRangeIndication in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.setRangeIndication(int, int, boolean)

getControl

public org.eclipse.swt.widgets.Control getControl()
Description copied from class: LpexTextViewer
Return the primary SWT Control (LpexWindow) associated with this viewer.
Overrides:
getControl in class LpexTextViewer
See Also:
LpexTextViewer.getControl()

getRangeIndication

public org.eclipse.jface.text.IRegion getRangeIndication()
Specified by:
getRangeIndication in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.getRangeIndication()

removeRangeIndication

public void removeRangeIndication()
Remove the viewer's range indication.
Specified by:
removeRangeIndication in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.removeRangeIndication()

showAnnotations

public void showAnnotations(boolean show)
Control the visibility of annotations and, in the case of separate presentation areas of text and annotations, the visibility of the annotation's presentation area.
Specified by:
showAnnotations in interface org.eclipse.jface.text.source.ISourceViewer
See Also:
ISourceViewer.showAnnotations(boolean)

initializeLpexView

protected void initializeLpexView(LpexView lpexView)
Hook to initialize a newly instantiated LpexView during the construction of this SourceViewer.

Extend this method to set any file/view-specific parameters for this LpexView. Ensure you also call super.initializeLpexView(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.

Overrides:
initializeLpexView in class LpexTextViewer
Following copied from class: com.ibm.lpex.alef.LpexTextViewer
See Also:
LpexTextViewer.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.

Overrides:
updateProfile in class LpexTextViewer