public class ProjectionViewer extends SourceViewer implements ITextViewerExtension5
A projection source viewer uses a ProjectionDocumentManager
for the management of the visible document.
NOTE: The ProjectionViewer
only supports projections that cover full lines.
This class should not be subclassed.
SourceViewer.RulerLayout
TextViewer.TextHoverKey, TextViewer.WidgetCommand
ITextViewerExtension8.EnrichMode
Modifier and Type | Field and Description |
---|---|
static int |
COLLAPSE
Operation constant for the collapse operation.
|
static int |
COLLAPSE_ALL
Operation constant for the collapse all operation.
|
static int |
EXPAND
Operation constant for the expand operation.
|
static int |
EXPAND_ALL
Operation constant for the expand all operation.
|
static int |
TOGGLE
Operation constant for the toggle projection operation.
|
_SELECTION_POSITION_CATEGORY, fAnnotationHover, fContentAssistant, fContentAssistantInstalled, fContentFormatter, fInformationPresenter, fOverviewRulerAnnotationHover, fPresentationReconciler, fQuickAssistAssistant, fQuickAssistAssistantInstalled, fReconciler, fSelectionCategory, fSelections, fSelectionUpdater, GAP_SIZE, GAP_SIZE_1, MODEL_ANNOTATION_MODEL
fAutoIndentStrategies, fDefaultPrefixChars, fDoubleClickStrategies, fEventConsumer, fFindReplaceDocumentAdapter, fHoverControlCreator, fHyperlinkDetectors, fHyperlinkManager, fHyperlinkPresenter, fHyperlinkStateMask, fIgnoreAutoIndent, fIndentChars, fInformationMapping, fLastTopPixel, fMarkPosition, fPaintManager, fPartitioning, fReplaceTextPresentation, fTextHovers, fTextInputListeners, fTextListeners, fTextPresentationListeners, fUndoManager, fViewportListeners, INTERNAL, KEY, MOUSE, MOUSE_END, RESIZE, SCROLLER, SHIFTING, TRACE_ERRORS
WIDGET_DATA_KEY
CONTENTASSIST_CONTEXT_INFORMATION, CONTENTASSIST_PROPOSALS, FORMAT, INFORMATION, QUICK_ASSIST
DEFAULT_HOVER_STATE_MASK
COPY, CUT, DELETE, PASTE, PREFIX, PRINT, REDO, SELECT_ALL, SHIFT_LEFT, SHIFT_RIGHT, STRIP_PREFIX, UNDO
Constructor and Description |
---|
ProjectionViewer(Composite parent,
IVerticalRuler ruler,
IOverviewRuler overviewRuler,
boolean showsAnnotationOverview,
int styles)
Creates a new projection source viewer.
|
Modifier and Type | Method and Description |
---|---|
void |
addProjectionListener(IProjectionListener listener)
Adds a projection annotation listener to this viewer.
|
boolean |
canDoOperation(int operation)
Returns whether the operation specified by the given operation code
can be performed.
|
IRegion |
computeCollapsedRegion(Position position)
Computes the region that must be collapsed when the given position is the
position of an expanded projection annotation.
|
Position |
computeCollapsedRegionAnchor(Position position)
Computes the collapsed region anchor for the given position.
|
protected void |
copyMarkedRegion(boolean delete)
Copies/cuts the marked region.
|
protected ISlaveDocumentManager |
createSlaveDocumentManager()
Creates a new slave document manager.
|
protected IAnnotationModel |
createVisualAnnotationModel(IAnnotationModel annotationModel)
Creates the visual annotation model on top of the given annotation model.
|
void |
disableProjection()
Disables the projection mode.
|
void |
doOperation(int operation)
Performs the operation specified by the operation code on the target.
|
void |
enableProjection()
Enables the projection mode.
|
boolean |
exposeModelRange(IRegion modelRange)
Exposes the given model range.
|
protected int |
findAndSelect(int startPosition,
String findString,
boolean forwardSearch,
boolean caseSensitive,
boolean wholeWord,
boolean regExSearch)
Adheres to the contract of
IFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean) . |
protected int |
findAndSelectInRange(int startPosition,
String findString,
boolean forwardSearch,
boolean caseSensitive,
boolean wholeWord,
int rangeOffset,
int rangeLength,
boolean regExSearch)
Adheres to the contract of
IFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean) . |
protected void |
fireProjectionDisabled()
Notifies all registered projection listeners
that projection mode has been disabled.
|
protected void |
fireProjectionEnabled()
Notifies all registered projection listeners
that projection mode has been enabled.
|
IRegion[] |
getCoveredModelRanges(IRegion modelRange)
Returns the maximal subranges of the given model range thus that there is
no offset inside a subrange for which there is no image offset.
|
protected FindReplaceDocumentAdapter |
getFindReplaceDocumentAdapter()
Returns the find/replace document adapter.
|
ProjectionAnnotationModel |
getProjectionAnnotationModel()
Returns the projection annotation model.
|
IRegion |
getVisibleRegion()
Returns the current visible region of this viewer's document.
|
protected void |
handleDispose()
Frees all resources allocated by this viewer.
|
protected void |
handleVerifyEvent(VerifyEvent e)
Handles the verify event issued by the viewer's text widget.
|
protected void |
handleVisibleDocumentAboutToBeChanged(DocumentEvent event)
Hook method called when the visible document is about to be changed.
|
protected void |
handleVisibleDocumentChanged(DocumentEvent event)
Hook method called when the visible document has been changed.
|
boolean |
isProjectionMode()
Returns whether this viewer is in projection mode.
|
boolean |
overlapsWithVisibleRegion(int offset,
int length)
Returns whether a given range overlaps with the visible region of this
viewer's document.
|
protected void |
postCatchupRequest(AnnotationModelEvent event)
Posts the request for catch up with the annotation model into the UI thread.
|
protected void |
processCatchupRequest(AnnotationModelEvent event)
Processes the request for catch up with the annotation model in the UI thread.
|
void |
reinitializeProjection()
Forces this viewer to throw away any old state and to initialize its content
from its projection annotation model.
|
void |
removeProjectionListener(IProjectionListener listener)
Removes the given listener from this viewer.
|
void |
resetVisibleRegion()
Resets the region of this viewer's document which is visible in the presentation.
|
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 |
setProjectionSummary(org.eclipse.jface.text.source.projection.ProjectionSummary projectionSummary)
Sets the projection summary for this viewer.
|
void |
setRangeIndication(int offset,
int length,
boolean moveCursor)
Sets the viewers's range indication to the specified range.
|
protected void |
setVisibleDocument(IDocument document)
Sets this viewer's visible document.
|
void |
setVisibleRegion(int start,
int length)
Defines and sets the region of this viewer's document which will be
visible in the presentation.
|
protected boolean |
updateSlaveDocument(IDocument slaveDocument,
int modelRangeOffset,
int modelRangeLength)
Updates the given slave document to show the specified range of its master document.
|
protected Point |
widgetSelection2ModelSelection(Point widgetSelection)
Adapts the behavior of the super class to respect line based folding.
|
activatePlugins, addVerticalRulerColumn, clearRememberedSelection, configure, createControl, createFormattingContext, createFormattingContext, createLayout, disposeVisualAnnotationModel, enableOperation, ensureAnnotationHoverManagerInstalled, ensureOverviewHoverManagerInstalled, getAnnotationModel, getContentAssistantFacade, getControl, getCurrentAnnotationHover, getQuickAssistAssistant, getQuickAssistInvocationContext, getRangeIndication, getVerticalRuler, getVisualAnnotationModel, rememberSelection, removeRangeIndication, removeVerticalRulerColumn, restoreSelection, setAnnotationHover, setDocument, setDocument, setDocument, setHoverEnrichMode, setOverviewRulerAnnotationHover, setRangeIndicator, showAnnotations, showAnnotationsOverview, unconfigure, updateSlaveDocuments
_getVisibleRegionOffset, _internalGetVisibleRegion, addPainter, addPostSelectionChangedListener, addTextInputListener, addTextListener, addTextPresentationListener, addViewportListener, appendVerifyKeyListener, areMultipleLinesSelected, canPerformFind, changeTextPresentation, createDocumentAdapter, createSlaveDocument, createTextWidget, customizeDocumentCommand, deleteText, disableRedrawing, enabledRedrawing, enabledRedrawing, event2ModelRange, findAndSelect, fireInputDocumentAboutToBeChanged, fireInputDocumentChanged, firePostSelectionChanged, fireSelectionChanged, freeSlaveDocument, getAverageCharWidth, getBottomIndex, getBottomIndexEndOffset, getClosestWidgetLineForModelLine, getCurrentTextHover, getDocument, getDocumentPartitioning, getEmptySelectionChangedEventDelay, getExtent, getFindReplaceTarget, getHoverEventLocation, getInput, getMark, getModelCoverage, getPaintManager, getRegisteredSupports, getRewriteTarget, getSelectedRange, getSelection, getSelectionProvider, getSlaveDocumentManager, getTextHover, getTextHover, getTextHoveringController, getTextOperationTarget, getTextWidget, getTopIndex, getTopIndexStartOffset, getTopInset, getUndoManager, getVisibleDocument, getVisibleLinesInViewport, getWidthInPixels, getWidthInPixels, ignoreAutoEditStrategies, initializeDocumentInformationMapping, inputChanged, internalRevealRange, invalidateTextPresentation, invalidateTextPresentation, isBlockSelected, isEditable, isIgnoringAutoEditStrategies, isPrintable, markChanged, modelLine2WidgetLine, modelOffset2WidgetOffset, modelRange2ClosestWidgetRange, modelRange2WidgetRange, modelRange2WidgetRange, modelSelection2WidgetSelection, modelStyleRange2WidgetStyleRange, moveFocusToWidgetToken, prependAutoEditStrategy, prependVerifyKeyListener, print, print, redraws, refresh, register, releaseWidgetToken, removeAutoEditStrategy, removePainter, removePostSelectionChangedListener, removeTextHovers, removeTextInputListener, removeTextListener, removeTextPresentationListener, removeVerifyKeyListener, removeViewportListener, requestWidgetToken, requestWidgetToken, resetPlugins, revealRange, selectContentTypePlugin, selectionChanged, setAutoEditStrategies, setAutoIndentStrategy, setDefaultPrefixes, setDocumentPartitioning, setEditable, setEventConsumer, setHoverControlCreator, setHyperlinkDetectors, setHyperlinkPresenter, setIndentPrefixes, setInput, setMark, setRedraw, setRedraw, setSelectedRange, setSelection, setTabsToSpacesConverter, setTextColor, setTextColor, setTextDoubleClickStrategy, setTextHover, setTextHover, setTopIndex, setUndoManager, shift, shift, startSequentialRewriteMode, stopSequentialRewriteMode, unregister, updateTextListeners, updateViewportListeners, updateVisibleDocument, validateSelectionRange, widgetLine2ModelLine, widgetLineOfWidgetOffset, widgetlLine2ModelLine, widgetOffset2ModelOffset, widgetRange2ModelRange
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getModelCoverage, modelLine2WidgetLine, modelOffset2WidgetOffset, modelRange2WidgetRange, widgetLine2ModelLine, widgetLineOfWidgetOffset, widgetOffset2ModelOffset, widgetRange2ModelRange
widgetlLine2ModelLine
addTextInputListener, addTextListener, addViewportListener, changeTextPresentation, getBottomIndex, getBottomIndexEndOffset, getDocument, getFindReplaceTarget, getSelectedRange, getSelectionProvider, getTextOperationTarget, getTextWidget, getTopIndex, getTopIndexStartOffset, getTopInset, invalidateTextPresentation, isEditable, removeTextInputListener, removeTextListener, removeViewportListener, resetPlugins, revealRange, setAutoIndentStrategy, setDefaultPrefixes, setEditable, setEventConsumer, setIndentPrefixes, setSelectedRange, setTextColor, setTextColor, setTextDoubleClickStrategy, setTextHover, setTopIndex, setUndoManager
addSelectionChangedListener, removeSelectionChangedListener, setSelection
public static final int EXPAND
public static final int COLLAPSE
public static final int TOGGLE
public static final int EXPAND_ALL
public static final int COLLAPSE_ALL
public ProjectionViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles)
parent
- the SWT parent controlruler
- the vertical ruleroverviewRuler
- the overview rulershowsAnnotationOverview
- true
if the overview ruler should be shownstyles
- the SWT style bitspublic void setProjectionSummary(org.eclipse.jface.text.source.projection.ProjectionSummary projectionSummary)
projectionSummary
- the projection summary.public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength)
ISourceViewer
TextEvent
is issued. The text event does not carry a
related document event. This method is a convenience method for
setDocument(document, annotationModel);setVisibleRegion(offset, length)
.setDocument
in interface ISourceViewer
setDocument
in class SourceViewer
document
- the new input documentannotationModel
- the model of the viewer's visual annotationsmodelRangeOffset
- the offset of the model rangemodelRangeLength
- the length of the model rangeITextViewer.setDocument(IDocument, int, int)
protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel)
SourceViewer
createVisualAnnotationModel
in class SourceViewer
annotationModel
- the wrapped annotation modelpublic ProjectionAnnotationModel getProjectionAnnotationModel()
protected ISlaveDocumentManager createSlaveDocumentManager()
TextViewer
ChildDocumentManager
.createSlaveDocumentManager
in class TextViewer
protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException
TextViewer
updateSlaveDocument
in class TextViewer
slaveDocument
- the slave documentmodelRangeOffset
- the offset of the master document rangemodelRangeLength
- the length of the master document rangetrue
if the slave has been adapted successfullyBadLocationException
- in case the specified range is not valid in the master documentpublic void addProjectionListener(IProjectionListener listener)
null
. If the listener is already registered, this method
does not have any effect.listener
- the listener to addpublic void removeProjectionListener(IProjectionListener listener)
null
. If the listener is not registered with this viewer,
this method is without effect.listener
- the listener to removeprotected void fireProjectionEnabled()
protected void fireProjectionDisabled()
public final boolean isProjectionMode()
true
if this viewer is in projection mode,
false
otherwisepublic final void disableProjection()
public final void enableProjection()
public void setVisibleRegion(int start, int length)
ITextViewer
setVisibleRegion
in interface ITextViewer
setVisibleRegion
in class TextViewer
start
- the offset of the visible regionlength
- the length of the visible regionprotected void setVisibleDocument(IDocument document)
TextViewer
setVisibleDocument
in class TextViewer
document
- the visible documentpublic void resetVisibleRegion()
ITextViewer
resetVisibleRegion
in interface ITextViewer
resetVisibleRegion
in class TextViewer
public IRegion getVisibleRegion()
ITextViewer
setVisibleRegion
if
the document has been modified since then. The visible region is supposed
to be a consecutive region in viewer's input document and every character
inside that region is supposed to visible in the viewer's widget.
Viewers implementing ITextViewerExtension5
may be forced to
change the fractions of the input document that are shown, in order to
fulfill this contract.
getVisibleRegion
in interface ITextViewer
getVisibleRegion
in class TextViewer
public boolean overlapsWithVisibleRegion(int offset, int length)
ITextViewer
Viewers implementing ITextViewerExtension5
may be forced to
change the fractions of the input document that are shown in order to
fulfill this request. This is because the overlap is supposed to be
without gaps.
overlapsWithVisibleRegion
in interface ITextViewer
overlapsWithVisibleRegion
in class TextViewer
offset
- the offsetlength
- the lengthtrue
if the specified range overlaps with the
visible regionprotected final void processCatchupRequest(AnnotationModelEvent event)
event
- the annotation model eventprotected final void postCatchupRequest(AnnotationModelEvent event)
event
- the annotation model eventpublic IRegion computeCollapsedRegion(Position position)
position
- the positionpublic Position computeCollapsedRegionAnchor(Position position)
position
- the positionpublic final void reinitializeProjection() throws BadLocationException
BadLocationException
- in case something goes wrong during initializationprotected void handleVerifyEvent(VerifyEvent e)
TextViewer
handleVerifyEvent
in class TextViewer
e
- the verify eventVerifyListener.verifyText(VerifyEvent)
public boolean exposeModelRange(IRegion modelRange)
ITextViewerExtension5
exposeModelRange
in interface ITextViewerExtension5
modelRange
- the model range to be exposedtrue
if the set of exposed model ranges changed,
false
otherwisepublic void setRangeIndication(int offset, int length, boolean moveCursor)
ISourceViewer
setRangeIndication
in interface ISourceViewer
setRangeIndication
in class SourceViewer
offset
- the offset of the rangelength
- the length of the rangemoveCursor
- indicates whether the cursor should be moved to the given offsetprotected void handleDispose()
TextViewer
handleDispose
in class SourceViewer
protected void handleVisibleDocumentChanged(DocumentEvent event)
TextViewer
Subclasses may override.
handleVisibleDocumentChanged
in class TextViewer
event
- the document eventprotected void handleVisibleDocumentAboutToBeChanged(DocumentEvent event)
TextViewer
Subclasses may override.
handleVisibleDocumentAboutToBeChanged
in class TextViewer
event
- the document eventpublic IRegion[] getCoveredModelRanges(IRegion modelRange)
ITextViewerExtension5
getCoveredModelRanges
in interface ITextViewerExtension5
modelRange
- the model rangepublic void doOperation(int operation)
ITextOperationTarget
doOperation
must only be called if canDoOperation
returns true
.doOperation
in interface ITextOperationTarget
doOperation
in class SourceViewer
operation
- the operation codepublic boolean canDoOperation(int operation)
ITextOperationTarget
canDoOperation
in interface ITextOperationTarget
canDoOperation
in class SourceViewer
operation
- the operation codetrue
if the specified operation can be performedprotected void copyMarkedRegion(boolean delete)
TextViewer
copyMarkedRegion
in class TextViewer
delete
- true
if the region should be deleted rather than copied.protected Point widgetSelection2ModelSelection(Point widgetSelection)
widgetSelection2ModelSelection
in class TextViewer
widgetSelection
- the widget selectionprotected FindReplaceDocumentAdapter getFindReplaceDocumentAdapter()
TextViewer
getFindReplaceDocumentAdapter
in class TextViewer
protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch)
TextViewer
IFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean)
.findAndSelect
in class TextViewer
startPosition
- the start positionfindString
- the find string specificationforwardSearch
- the search directioncaseSensitive
- true
if case sensitive, false
otherwisewholeWord
- true
if matches must be whole words, false
otherwiseregExSearch
- true
if findString
is a regular expression, false
otherwiseprotected int findAndSelectInRange(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, int rangeOffset, int rangeLength, boolean regExSearch)
TextViewer
IFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean)
.findAndSelectInRange
in class TextViewer
startPosition
- the start positionfindString
- the find string specificationforwardSearch
- the search directioncaseSensitive
- true
if case sensitive, false
otherwisewholeWord
- true
if matches must be whole words, false
otherwiserangeOffset
- the search scope offsetrangeLength
- the search scope lengthregExSearch
- true
if findString
is a regular expression, false
otherwise
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.