|
LPEX 3.6.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectViewer
com.ibm.lpex.alef.LpexTextViewer
com.ibm.lpex.alef.LpexSourceViewer
public class LpexSourceViewer
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. A source viewer uses an IOverviewRuler
as its presentation area for the annotation overview. The overview ruler is
a small strip shown right of the viewer's text widget.
Clients are supposed to instantiate a source viewer and subsequently
communicate with it exclusively using the ISourceViewer
and
its extension interfaces.
Clients may extend this class but should expect some breakage in future releases.
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.
method's
documentation
Always use LpexView to set the text of the edited document. For example:
IEditorPart editor = IWorkbenchPage.getActiveEditor(); // (a) Using LPEX if (editor instanceof LpexTextEditor) { LpexTextEditor lpexEditor = (LpexTextEditor)editor; LpexView lpexView = lpexEditor.getLpexView(); if (lpexView != null) { lpexView.doDefaultCommand("insertText " + text); // insert text at cursor LpexView.doGlobalCommand("screenShow"); // refresh display } } // (b) Using an Eclipse editor else { // . . . get DocumentProvider, get IDocument, do replace() } |
LpexTextViewer
Nested Class Summary | |
---|---|
protected class |
LpexSourceViewer.RulerLayout
Layout of this source viewer. |
Nested classes/interfaces inherited from class com.ibm.lpex.alef.LpexTextViewer |
---|
LpexTextViewer.TextHoverKey |
Field Summary | |
---|---|
protected static String |
_SELECTION_POSITION_CATEGORY
Partial name of the position category to manage remembered selections. |
protected IAnnotationHover |
fAnnotationHover
The viewer's annotation hover. |
protected IContentAssistant |
fContentAssistant
The viewer's content assistant. |
protected boolean |
fContentAssistantInstalled
Flag indicating whether the viewer's content assistant is installed (enabled). |
protected IContentFormatter |
fContentFormatter
The viewer's content formatter. |
protected IInformationPresenter |
fInformationPresenter
The viewer's information presenter. |
protected IAnnotationHover |
fOverviewRulerAnnotationHover
The viewer's overview ruler annotation hover. |
protected IPresentationReconciler |
fPresentationReconciler
The viewer's presentation reconciler. |
protected IReconciler |
fReconciler
The viewer's model reconciler. |
protected String |
fSelectionCategory
Position category used by the selection updater. |
protected Stack<Position> |
fSelections
Stack of saved selections in the underlying document. |
protected IPositionUpdater |
fSelectionUpdater
Position updater for saved selections. |
protected static int |
GAP_SIZE_1
The size of the gap between the vertical ruler and the text widget (value 1 ). |
protected static Object |
MODEL_ANNOTATION_MODEL
Key of the model annotation model inside the visual annotation model. |
Fields inherited from class com.ibm.lpex.alef.LpexTextViewer |
---|
fHoverControlCreator, fHyperlinkDetectors, fHyperlinkManager, fHyperlinkPresenter, fHyperlinkStateMask, fInformationMapping, fLastTopPixel, fPartitioning, fReplaceTextPresentation, fTextHovers, fTextInputListeners, INTERNAL, KEY, MOUSE, MOUSE_END, RESIZE, SCROLLER, TRACE_ERRORS |
Constructor Summary | |
---|---|
LpexSourceViewer(Composite parent,
ITextEditor textEditor,
IVerticalRuler ruler,
int styles)
Constructs a new LPEX source viewer. |
|
LpexSourceViewer(Composite parent,
ITextEditor textEditor,
IVerticalRuler verticalRuler,
IOverviewRuler overviewRuler,
boolean showAnnotationsOverview,
int styles)
Constructs a new LPEX source viewer. |
Method Summary | |
---|---|
void |
activatePlugins()
Extends LpexTextViewer's to install the annotation hover. |
boolean |
canDoOperation(int operation)
Returns whether the action specified by the operation id can be performed. |
protected void |
clearRememberedSelection()
|
void |
configure(SourceViewerConfiguration configuration)
Configure the source viewer as described in the configuration. |
protected void |
createControl(Composite parent,
int styles)
Creates this source viewer's controls. |
protected Layout |
createLayout()
Creates the layout used for this viewer. |
protected void |
createViewPreferenceNodes(LpexSourceViewer lpexSourceViewer)
Hook to allow the solution plug-in create custom preference node(s) for view-scoped preference page(s) for this source viewer. |
protected IPreferencePage |
createViewPreferencePage(LpexView lpexView,
int nodeType)
Factory method to create the preference page for a view-scoped preference node used by this source viewer. |
protected IAnnotationModel |
createVisualAnnotationModel(IAnnotationModel annotationModel)
Creates the visual annotation model on top of the given annotation model. |
protected void |
disposeVisualAnnotationModel()
Disposes the visual annotation model. |
void |
doOperation(int operation)
Performs the action specified by the operation id. |
void |
enableOperation(int operation,
boolean enable)
|
protected void |
ensureAnnotationHoverManagerInstalled()
Ensure the annotation hover manager is installed. |
protected void |
ensureOverviewHoverManagerInstalled()
After this method has been executed the caller knows that any installed overview hover has been installed. |
IAnnotationModel |
getAnnotationModel()
Return this viewer's annotation model. |
Control |
getControl()
Returns the primary control of this source viewer. |
IAnnotationHover |
getCurrentAnnotationHover()
|
Composite |
getPromptWindow()
Optionally create and return the prompt window. |
IRegion |
getRangeIndication()
|
LpexAbstractTextEditor |
getTextEditor()
|
protected IVerticalRuler |
getVerticalRuler()
Returns the vertical ruler of this viewer. |
IAnnotationModel |
getVisualAnnotationModel()
Returns the visual annotation model of this viewer. |
protected void |
handleDispose()
Free all resources allocated by this viewer. |
protected Point |
rememberSelection()
Remembers and returns the current selection. |
void |
removeRangeIndication()
Removes the viewer's range indication. |
protected void |
restoreSelection()
Restores a previously saved selection in the document. |
void |
setAnnotationHover(IAnnotationHover annotationHover)
|
void |
setDocument(IDocument document)
Set the viewer's IDocument. |
void |
setDocument(IDocument document,
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(IDocument document,
IAnnotationModel annotationModel,
int modelRangeOffset,
int modelRangeLength)
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(IDocument document,
int visibleRegionOffset,
int visibleRegionLength)
This method just sets the viewer's IDocument. |
protected void |
setLanguageHelp(LpexLanguageHelp lsh)
Sets the provider for this source viewer's LPEX document parser language-sensitive help (LSH). |
void |
setOverviewRulerAnnotationHover(IAnnotationHover annotationHover)
Sets the overview ruler's annotation hover of this source viewer. |
void |
setRangeIndication(int start,
int len,
boolean moveCursor)
Sets this viewer's range indication (in the vertical ruler to its left) to the specified range. |
void |
setRangeIndicator(Annotation rangeIndicator)
Sets the annotation used as range indicator for the viewer's vertical ruler. |
void |
showAnnotations(boolean show)
Controls the visibility of annotations and, in the case of separate presentation areas of text and annotations, the visibility of the annotation's presentation area. |
void |
showAnnotationsOverview(boolean show)
|
void |
unconfigure()
Unconfigures this source viewer. |
protected void |
updateProfile(LpexView lpexView)
Hook for post-updateProfile command processing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int GAP_SIZE_1
1
).
protected static final String _SELECTION_POSITION_CATEGORY
protected static final Object MODEL_ANNOTATION_MODEL
protected IContentAssistant fContentAssistant
protected boolean fContentAssistantInstalled
protected IContentFormatter fContentFormatter
protected IReconciler fReconciler
protected IPresentationReconciler fPresentationReconciler
protected IAnnotationHover fAnnotationHover
protected final Stack<Position> fSelections
protected IPositionUpdater fSelectionUpdater
protected String fSelectionCategory
protected IAnnotationHover fOverviewRulerAnnotationHover
protected IInformationPresenter fInformationPresenter
Constructor Detail |
---|
public LpexSourceViewer(Composite parent, ITextEditor textEditor, IVerticalRuler ruler, int styles)
parent
- the parent of the viewer's controltextEditor
- the LpexAbstractTextEditor instantiating this source viewerruler
- the vertical ruler used by this source viewerstyles
- the SWT style bitspublic LpexSourceViewer(Composite parent, ITextEditor textEditor, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles)
showAnnotationsOverview
. The viewer has not yet been
initialized with a source viewer configuration.
parent
- the parent of the viewer's controltextEditor
- the LpexAbstractTextEditor instantiating this source viewerverticalRuler
- the vertical ruler used by this source vieweroverviewRuler
- the overview rulershowAnnotationsOverview
- true
if the overview ruler should be visible, false
otherwisestyles
- the SWT style bitsMethod Detail |
---|
public LpexAbstractTextEditor getTextEditor()
getTextEditor
in class LpexTextViewer
protected void createControl(Composite parent, int styles)
createControl
in class LpexTextViewer
parent
- the parent of the viewer's controlstyles
- the SWT style bits for the viewer's controlLpexTextViewer.createControl(Composite, int)
,
getPromptWindow()
protected Layout createLayout()
public Control getControl()
getControl
in class LpexTextViewer
Viewer
public Composite getPromptWindow()
null
if the prompt window could not be createdpublic void setAnnotationHover(IAnnotationHover annotationHover)
ISourceViewer
public void setOverviewRulerAnnotationHover(IAnnotationHover annotationHover)
annotationHover
- the hover to be used; null
is a valid argumentpublic void configure(SourceViewerConfiguration configuration)
You should use an LpexSourceViewerConfiguration-based class to configure an LpexSourceViewer.
LpexSourceViewer does not use/implement certain (Lpex)SourceViewerConfiguration features.
configuration
- an LpexSourceViewerConfigurationLpexSourceViewerConfiguration
,
ISourceViewer
,
LpexCommonParser
protected void ensureAnnotationHoverManagerInstalled()
protected void ensureOverviewHoverManagerInstalled()
public void activatePlugins()
activatePlugins
in class LpexTextViewer
ITextViewer
public void setDocument(IDocument document)
setDocument
in class LpexTextViewer
ITextViewer
public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength)
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.
setDocument
in class LpexTextViewer
ITextViewer
,
LpexTextViewer.setDocument(IDocument)
public void setDocument(IDocument document, IAnnotationModel annotationModel)
TextEvent
is issued. This text event does not carry
a related document event.
document
- the viewer's new input documentannotationModel
- the model for the viewer's visual annotations
(the document provider's annotation model)ISourceViewer
protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel)
annotationModel
- the wrapped annotation model
protected void disposeVisualAnnotationModel()
public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength)
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)
document
- the new input documentannotationModel
- the model of the viewer's visual annotations
(our IDocument provider's annotation model)ISourceViewer
public IAnnotationModel getAnnotationModel()
ISourceViewer
public IAnnotationModel getVisualAnnotationModel()
ISourceViewerExtension2
public void unconfigure()
ISourceViewerExtension2
protected void handleDispose()
handleDispose
in class LpexTextViewer
LpexTextViewer.handleDispose()
public boolean canDoOperation(int operation)
LpexTextViewer
Note that most LPEX actions (as defined in, for example, LpexAbstractTextEditor) call the editor directly for querying their availability.
canDoOperation
in class LpexTextViewer
operation
- LPEX-defined operation id (including the equivalents of
ITextOperationTarget.UNDO, .REDO, etc.)ITextOperationTarget
protected Point rememberSelection()
restoreSelection()
.
ITextViewer
protected void restoreSelection()
protected void clearRememberedSelection()
public void doOperation(int operation)
LpexTextViewer
canDoOperation()
returns true
.
Note that most LPEX actions (as defined in, for example, LpexAbstractTextEditor) call the editor directly.
doOperation
in class LpexTextViewer
operation
- LPEX-defined operation id (including the equivalents of
ITextOperationTarget.UNDO, .REDO, etc.)ITextOperationTarget
public void enableOperation(int operation, boolean enable)
enableOperation
in class LpexTextViewer
public void setRangeIndicator(Annotation rangeIndicator)
ISourceViewer
public void setRangeIndication(int start, int len, boolean moveCursor)
start
- the offset of the rangelen
- the length of the rangemoveCursor
- indicates whether the cursor should be moved to the given
offsetISourceViewer
public IRegion getRangeIndication()
ISourceViewer
public void removeRangeIndication()
ISourceViewer
public void showAnnotations(boolean show)
ISourceViewer
protected final IVerticalRuler getVerticalRuler()
public void showAnnotationsOverview(boolean show)
public IAnnotationHover getCurrentAnnotationHover()
protected void updateProfile(LpexView lpexView)
Called when a new document view is created (a new document is opened in this viewer, and is, at this point, already loaded in the editor), and whenever the updateProfile command is issued afterwards.
updateProfile
in class LpexTextViewer
lpexView
- the primary or secondary document view whose profile
has been updatedprotected void setLanguageHelp(LpexLanguageHelp lsh)
protected void createViewPreferenceNodes(LpexSourceViewer lpexSourceViewer)
A custom preference node is a subclass of LpexViewPreferenceNode. Custom nodes are added after the LPEX view-scoped preference nodes, in the order in which they are created.
LpexAbstractTextEditor.createViewPreferenceNodes(com.ibm.lpex.alef.LpexSourceViewer)
,
LpexViewPreferenceNode
protected IPreferencePage createViewPreferencePage(LpexView lpexView, int nodeType)
If you extend this method, ensure you call super.createViewPreferencePage() for the node types you don't support or customize.
nodeType
- preference node type, one of LpexViewPreferenceNode.VIEW_BASE_PREFERENCE_NODE
,
LpexViewPreferenceNode.VIEW_PARSER_PREFERENCE_NODE
,
LpexViewPreferenceNode.VIEW_SEQUENCE_NUMBERS_PREFERENCE_NODE
,
LpexViewPreferenceNode.VIEW_SOURCE_ENCODING_PREFERENCE_NODE
LpexAbstractTextEditor.createViewPreferencePage(com.ibm.lpex.core.LpexView, int)
|
LPEX 3.6.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |