Class TextViewer
- All Implemented Interfaces:
IEditingSupportRegistry
,ITextOperationTarget
,ITextOperationTargetExtension
,ITextViewer
,ITextViewerExtension
,ITextViewerExtension2
,ITextViewerExtension4
,ITextViewerExtension6
,ITextViewerExtension7
,ITextViewerExtension8
,ITextViewerExtension9
,IWidgetTokenOwner
,IWidgetTokenOwnerExtension
,IInputProvider
,IInputSelectionProvider
,IPostSelectionProvider
,ISelectionProvider
- Direct Known Subclasses:
SourceViewer
ITextViewer
and its extension interfaces.
Once the viewer and its SWT control have been created the viewer can only
indirectly be disposed by disposing its SWT control.
Clients are supposed to instantiate a text viewer and subsequently to
communicate with it exclusively using the
ITextViewer
interface or any of the
implemented extension interfaces.
A text viewer serves as text operation target. It only partially supports the
external control of the enable state of its text operations. A text viewer is
also a widget token owner. Anything that wants to display an overlay window
on top of a text viewer should implement the
IWidgetTokenKeeper
interface and participate
in the widget token negotiation between the text viewer and all its potential
widget token keepers.
This class is not intended to be subclassed outside the JFace Text component.
- Restriction:
- This class is not intended to be subclassed by clients.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Value object used as key in the text hover configuration table.protected class
Represents a replace command that brings the text viewer's text widget back in synchronization with text viewer's document after the document has been changed.Nested classes/interfaces inherited from interface org.eclipse.jface.text.ITextViewerExtension8
ITextViewerExtension8.EnrichMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map<String,
List<IAutoEditStrategy>> The text viewer's auto indent strategiesThe string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIXprotected Map<String,
ITextDoubleClickStrategy> The text viewer's text double click strategiesprotected IEventConsumer
The text viewer's event consumerprotected FindReplaceDocumentAdapter
The find/replace document adapter.protected IInformationControlCreator
The creator of the text hover controlprotected IHyperlinkDetector[]
The text viewer's hyperlink detectors.protected HyperlinkManager
The text viewer's hyperlink manager.protected IHyperlinkPresenter
The text viewer's hyperlink presenter.protected int
The SWT key modifier mask which in combination with the left mouse button triggers the hyperlink mode.protected boolean
Should the auto indent strategies ignore the next edit operationThe strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFTprotected IDocumentInformationMapping
The mapping between model and visible document.protected int
The last visible vertical position of the top lineprotected Position
The mark position.protected PaintManager
The viewer's paint manager.protected String
The viewers partitioning.protected boolean
Indicates whether the viewer's text presentation should be replaced are modified.protected Map<TextViewer.TextHoverKey,
ITextHover> The text viewer's text hoversprotected List<ITextInputListener>
All registered text input listenersprotected List<ITextListener>
All registered text listenersprotected List<ITextPresentationListener>
All registered text presentation listeners.protected IUndoManager
The text viewer's undo managerprotected List<IViewportListener>
All registered view port listenersprotected static final int
Identifies internal reasons as originators of a view port change.protected static final int
Identifies key strokes as originators of a view port change.protected static final int
Identifies mouse moves as originators of a view port change.protected static final int
Identifies mouse button up as originator of a view port change.protected static final int
Identifies window resizing as originator of a view port change.protected static final int
Identifies the scrollbars as originators of a view port change.protected static final String
Internal name of the position category used selection preservation during shift.static final boolean
Internal flag to indicate the debug state.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
Fields inherited from interface org.eclipse.jface.text.ITextViewerExtension2
DEFAULT_HOVER_STATE_MASK
-
Constructor Summary
ModifierConstructorDescriptionprotected
Internal use onlyTextViewer
(Composite parent, int styles) Create a new text viewer with the given SWT style bits. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Returns the offset of the visible region.protected IRegion
Returns the visible region if it is not equal to the whole document.void
Activates the installed plug-ins.void
addPainter
(IPainter painter) Adds the given painter to this viewer.void
Adds a listener for post selection changes in this selection provider.void
addTextInputListener
(ITextInputListener listener) Adds a text input listener to this viewer.void
addTextListener
(ITextListener listener) Adds a text listener to this viewer.void
Adds the given text presentation listener to this text viewer.void
addViewportListener
(IViewportListener listener) Adds the given view port listener to this viewer.void
appendVerifyKeyListener
(VerifyKeyListener listener) Appends a verify key listener to the viewer's list of verify key listeners.protected boolean
Returnstrue
if one line is completely selected or if multiple lines are selected.boolean
canDoOperation
(int operation) Returns whether the operation specified by the given operation code can be performed.protected boolean
Adheres to the contract ofIFindReplaceTarget.canPerformFind()
.void
changeTextPresentation
(TextPresentation presentation, boolean controlRedraw) Applies the color information encoded in the given text presentation.protected void
copyMarkedRegion
(boolean delete) Copies/cuts the marked region.protected void
createControl
(Composite parent, int styles) Creates the viewer's SWT control.protected IDocumentAdapter
Factory method to create the document adapter to be used by this viewer.protected IDocument
createSlaveDocument
(IDocument document) Creates a slave document for the given document if there is a slave document manager associated with this viewer.protected ISlaveDocumentManager
Creates a new slave document manager.protected StyledText
createTextWidget
(Composite parent, int styles) Factory method to create the text widget to be used as the viewer's text widget.protected void
customizeDocumentCommand
(DocumentCommand command) Hook called on receipt of aVerifyEvent
.protected void
Deprecated.protected void
Disables the redrawing of this text viewer.void
doOperation
(int operation) Performs the operation specified by the operation code on the target.protected void
Enables the redrawing of this text viewer.protected void
enabledRedrawing
(int topIndex) Enables the redrawing of this text viewer.void
enableOperation
(int operation, boolean enable) Enables/disabled the given text operation.protected IRegion
event2ModelRange
(VerifyEvent event) Translates the widget region of the given verify event into the corresponding region of the viewer's document.protected int
findAndSelect
(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) Deprecated.protected int
findAndSelect
(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) Adheres to the contract ofIFindReplaceTargetExtension3.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 ofIFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean)
.protected void
fireInputDocumentAboutToBeChanged
(IDocument oldInput, IDocument newInput) Informs all registered text input listeners about the forthcoming input change, This method does not use a robust iterator.protected void
fireInputDocumentChanged
(IDocument oldInput, IDocument newInput) Informs all registered text input listeners about the successful input change, This method does not use a robust iterator.protected void
firePostSelectionChanged
(int offset, int length) Sends out a text selection changed event to all registered post selection changed listeners.protected void
fireSelectionChanged
(int offset, int length) Sends out a text selection changed event to all registered listeners.protected void
freeSlaveDocument
(IDocument slave) Frees the given document if it is a slave document.protected final int
Returns the average character width of this viewer's widget.int
Returns the visible line with the highest line number.int
Returns the document offset of the lower right corner of this viewer's view port.protected int
getClosestWidgetLineForModelLine
(int modelLine) Returns the line of the widget whose corresponding line in the viewer's document is closest to the given line in the viewer's document or-1
.Returns the primary control associated with this viewer.Returns the currently displayed text hover if any,null
otherwise.Returns the text viewer's input document.protected String
Returns the document partitioning for this viewer.protected int
The delay in milliseconds before an empty selection changed event is sent by the cursor listener.protected final IRegion
getExtent
(int start, int end) Returns the region covered by the given start and end offset.protected FindReplaceDocumentAdapter
Returns the find/replace document adapter.Returns the find/replace operation target of this viewer.Returns the location at which the most recent mouse hover event has occurred.getInput()
Returns the input.Returns the last known selection from a cache, without polling widget.int
getMark()
Returns the position of the mark,-1
if the mark is not set.Implements the contract ofITextViewerExtension5.getModelCoverage()
.protected PaintManager
Returns the paint manager of this viewer.Returns the current editor helpers.Returns the viewer's rewrite target.Returns the range of the current selection in coordinates of this viewer's document.Returns the current selection for this provider.Returns a selection provider dedicated to this viewer.protected ISlaveDocumentManager
Returns the slave document managerprotected ITextHover
getTextHover
(int offset) Returns the text hover for a given offset.protected ITextHover
getTextHover
(int offset, int stateMask) Returns the text hover for a given offset and a given state mask.protected AbstractInformationControlManager
Returns the text hovering controller of this viewer.Returns the text operation target of this viewer.Returns this viewer's SWT control,null
if the control is disposed.int
Returns the visible line with the smallest line number.int
Returns the document offset of the upper left corner of this viewer's view port.int
Returns the vertical offset of the first visible line.Returns this viewer's undo manager.protected IDocument
Returns the viewer's visible document.protected int
Deprecated.as of 3.2Returns the current visible region of this viewer's document.protected final int
getWidthInPixels
(int offset, int length) Returns the width of the representation of a text range in the visible region of the viewer's document as drawn in this viewer's widget.protected final int
getWidthInPixels
(String text) Deprecated.usegetWidthInPixels(int, int)
insteadprotected void
Frees all resources allocated by this viewer.protected void
Handles the verify event issued by the viewer's text widget.protected void
Hook method called when the visible document is about to be changed.protected void
Hook method called when the visible document has been changed.protected void
ignoreAutoEditStrategies
(boolean ignore) Tells this viewer whether the registered auto edit strategies should be ignored.protected void
initializeDocumentInformationMapping
(IDocument visibleDocument) Initializes the document information mapping between the given slave document and its master document.protected void
inputChanged
(Object newInput, Object oldInput) Internal hook method called when the input to this viewer is initially set or subsequently changed.protected void
internalRevealRange
(int start, int end) Reveals the given range of the visible document.final void
Marks the currently applied text presentation as invalid.final void
invalidateTextPresentation
(int offset, int length) Invalidates the given range of the text presentation.protected boolean
A block is selected if the character preceding the start of the selection is a new line character.boolean
Returns whether the shown text can be manipulated.protected boolean
Returns whether this viewer ignores the registered auto edit strategies.protected boolean
Returns whether the shown text can be printed.protected void
markChanged
(int offset, int length) Sends out a mark selection changed event to all registered listeners.int
modelLine2WidgetLine
(int modelLine) Implements the contract ofITextViewerExtension5.modelLine2WidgetLine(int)
.int
modelOffset2WidgetOffset
(int modelOffset) Implements the contract ofITextViewerExtension5.modelOffset2WidgetOffset(int)
.protected IRegion
modelRange2ClosestWidgetRange
(IRegion modelRange) Similar tomodelRange2WidgetRange(IRegion)
, but more forgiving: ifmodelRange
describes a region entirely hidden in the image, then this method returns the zero-length region at the offset of the folded region.modelRange2WidgetRange
(IRegion modelRange) Implements the contract ofITextViewerExtension5.modelRange2WidgetRange(IRegion)
.protected IRegion
modelRange2WidgetRange
(Position modelPosition) Same asmodelRange2WidgetRange(IRegion)
just for aPosition
.protected Point
modelSelection2WidgetSelection
(Point modelSelection) Translates the given selection range of the viewer's document into the corresponding widget range or returnsnull
of this fails.protected StyleRange
Translates a style range given relative to the viewer's document into style ranges relative to the viewer's widget ornull
.boolean
Instructs the receiver to request theIWidgetTokenKeeper
currently holding the widget token to take the keyboard focus.boolean
overlapsWithVisibleRegion
(int start, int length) Returns whether a given range overlaps with the visible region of this viewer's document.void
prependAutoEditStrategy
(IAutoEditStrategy strategy, String contentType) Prepends the given auto edit strategy to the existing list of strategies for the specified content type.void
prependVerifyKeyListener
(VerifyKeyListener listener) Inserts the verify key listener at the beginning of the viewer's list of verify key listeners.protected void
print()
Brings up a print dialog and callsprintContents(Printer)
which performs the actual print.void
print
(StyledTextPrintOptions options) Print the text viewer contents using the given options.protected final boolean
redraws()
Returns whether this viewer redraws itself.void
refresh()
Refreshes this viewer completely with information freshly obtained from this viewer's model.void
register
(IEditingSupport helper) Register a support with the registry.void
releaseWidgetToken
(IWidgetTokenKeeper tokenKeeper) The given token keeper releases the token to this token owner.void
removeAutoEditStrategy
(IAutoEditStrategy strategy, String contentType) Removes the first occurrence of the given auto edit strategy in the list of strategies registered under the specified content type.void
removePainter
(IPainter painter) Removes the given painter from this viewer.void
Removes the given listener for post selection changes from this selection provider.void
removeTextHovers
(String contentType) Removes all text hovers for the given content type independent from their state mask.void
removeTextInputListener
(ITextInputListener listener) Removes the given listener from this viewer's set of text input listeners.void
removeTextListener
(ITextListener listener) Removes the given listener from this viewer's set of text listeners.void
Removes the given text presentation listener from this text viewer.void
removeVerifyKeyListener
(VerifyKeyListener listener) Removes the verify key listener from the viewer's list of verify key listeners.void
removeViewportListener
(IViewportListener listener) Removes the given listener from this viewer's set of view port listeners.boolean
requestWidgetToken
(IWidgetTokenKeeper requester) Requests the widget token from this token owner.boolean
requestWidgetToken
(IWidgetTokenKeeper requester, int priority) Requests the widget token from this token owner.void
Resets the installed plug-ins.void
Resets the region of this viewer's document which is visible in the presentation.void
revealRange
(int start, int length) Ensures that the given range is visible.protected Object
selectContentTypePlugin
(int offset, Map<String, ?> 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 length) Sends out a text selection changed event to all registered listeners and registers the selection changed event to be sent out to all post selection listeners.protected final void
setAutoEditStrategies
(IAutoEditStrategy[] strategies, String contentType) Sets the given edit strategy as the only strategy for the given content type.void
setAutoIndentStrategy
(IAutoIndentStrategy strategy, String contentType) Deprecated.void
setDefaultPrefixes
(String[] defaultPrefixes, String contentType) Sets the strings that are used as prefixes when lines of the given content type are prefixed using the prefix text operation.void
setDocument
(IDocument document) Sets the given document as the text viewer's model and updates the presentation accordingly.void
setDocument
(IDocument document, int modelRangeOffset, int modelRangeLength) Sets the given document as this viewer's model and exposes the specified region.void
setDocumentPartitioning
(String partitioning) Sets the document partitioning of this viewer.void
setEditable
(boolean editable) Sets the editable state.void
setEventConsumer
(IEventConsumer consumer) Registers an event consumer with this viewer.void
Sets the creator for the hover controls.void
Sets the hover enrich mode.void
setHyperlinkDetectors
(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) Sets this viewer's hyperlink detectors for the given state mask.void
setHyperlinkPresenter
(IHyperlinkPresenter hyperlinkPresenter) Sets the hyperlink presenter.void
setIndentPrefixes
(String[] indentPrefixes, String contentType) Sets the strings that are used as prefixes when lines of the given content type are shifted using the shift text operation.void
Sets or clears the input for this viewer.void
setMark
(int offset) Sets a mark at the given offset or clears the mark if the specified offset is-1
.final void
setRedraw
(boolean redraw) Enables/disables the redrawing of this text viewer.protected final void
setRedraw
(boolean redraw, int topIndex) Basically same functionality asITextViewerExtension.setRedraw(boolean)
.void
setSelectedRange
(int selectionOffset, int selectionLength) Sets the selection to the specified range.void
setSelection
(ISelection selection, boolean reveal) Sets a new selection for this viewer and optionally makes it visible.void
setTabsToSpacesConverter
(IAutoEditStrategy converter) Sets an auto edit strategy can converts tabs to spaces.void
setTextColor
(Color color) Applies the given color as text foreground color to this viewer's selection.void
setTextColor
(Color color, int start, int length, boolean controlRedraw) Applies the given color as text foreground color to the specified section of this viewer.void
setTextDoubleClickStrategy
(ITextDoubleClickStrategy strategy, String contentType) Sets this viewer's text double click strategy for the given content type.void
setTextHover
(ITextHover hover, String contentType) Sets this viewer's text hover for the given content type.void
setTextHover
(ITextHover hover, String contentType, int stateMask) Sets this viewer's text hover for the given content type and the given state mask.void
setTopIndex
(int index) Scrolls the widget so that the given index is the line with the smallest line number of all visible lines.void
setUndoManager
(IUndoManager undoManager) Sets this viewer's undo manager.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 void
shift
(boolean useDefaultPrefixes, boolean right) Deprecated.use shift(boolean, boolean, boolean) insteadprotected void
shift
(boolean useDefaultPrefixes, boolean right, boolean ignoreWhitespace) Shifts a text block to the right or left using the specified set of prefix characters.protected final void
startSequentialRewriteMode
(boolean normalized) Deprecated.since 3.1 useIDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)
insteadprotected final void
Deprecated.since 3.1 useIDocumentExtension4.stopRewriteSession(DocumentRewriteSession)
insteadvoid
unregister
(IEditingSupport helper) Deregister a support with the registry.protected boolean
updateSlaveDocument
(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) Updates the given slave document to show the specified range of its master document.protected void
Informs all registered text listeners about the change specified by the widget command.protected void
updateViewportListeners
(int origin) Checks whether the view port changed and if so informs all registered listeners about the change.protected boolean
updateVisibleDocument
(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) Deprecated.useupdateSlaveDocument
insteadprotected void
validateSelectionRange
(int[] selectionRange) Validates and adapts the given selection range if it is not a valid widget selection.int
widgetLine2ModelLine
(int widgetLine) Implements the contract ofITextViewerExtension5.widgetLine2ModelLine(int)
.int
widgetLineOfWidgetOffset
(int widgetOffset) Implements the contract ofITextViewerExtension5.widgetLineOfWidgetOffset(int)
.int
widgetlLine2ModelLine
(int widgetLine) Implements the contract ofITextViewerExtension5.widgetLine2ModelLine(int)
.int
widgetOffset2ModelOffset
(int widgetOffset) Implements the contract ofITextViewerExtension5.widgetOffset2ModelOffset(int)
.widgetRange2ModelRange
(IRegion widgetRange) Implements the contract ofITextViewerExtension5.widgetRange2ModelRange(IRegion)
.protected Point
widgetSelection2ModelSelection
(Point widgetSelection) Translates the given widget selection into the corresponding region of the viewer's document or returnsnull
if this fails.Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, 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.viewers.ISelectionProvider
addSelectionChangedListener, removeSelectionChangedListener, setSelection
-
Field Details
-
TRACE_ERRORS
public static final boolean TRACE_ERRORSInternal flag to indicate the debug state.- See Also:
-
SCROLLER
protected static final int SCROLLERIdentifies the scrollbars as originators of a view port change.- See Also:
-
MOUSE
protected static final int MOUSEIdentifies mouse moves as originators of a view port change.- See Also:
-
MOUSE_END
protected static final int MOUSE_ENDIdentifies mouse button up as originator of a view port change.- See Also:
-
KEY
protected static final int KEYIdentifies key strokes as originators of a view port change.- See Also:
-
RESIZE
protected static final int RESIZEIdentifies window resizing as originator of a view port change.- See Also:
-
INTERNAL
protected static final int INTERNALIdentifies internal reasons as originators of a view port change.- See Also:
-
SHIFTING
Internal name of the position category used selection preservation during shift.- See Also:
-
fMarkPosition
The mark position.- Since:
- 2.0
-
fIgnoreAutoIndent
protected boolean fIgnoreAutoIndentShould the auto indent strategies ignore the next edit operation -
fIndentChars
The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT -
fDefaultPrefixChars
The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX -
fDoubleClickStrategies
The text viewer's text double click strategies -
fUndoManager
The text viewer's undo manager -
fAutoIndentStrategies
The text viewer's auto indent strategies -
fTextHovers
The text viewer's text hovers -
fViewportListeners
All registered view port listeners -
fLastTopPixel
protected int fLastTopPixelThe last visible vertical position of the top line -
fTextListeners
All registered text listeners -
fTextInputListeners
All registered text input listeners -
fEventConsumer
The text viewer's event consumer -
fReplaceTextPresentation
protected boolean fReplaceTextPresentationIndicates whether the viewer's text presentation should be replaced are modified. -
fHoverControlCreator
The creator of the text hover control- Since:
- 2.0
-
fInformationMapping
The mapping between model and visible document.- Since:
- 2.1
-
fPaintManager
The viewer's paint manager.- Since:
- 2.1
-
fPartitioning
The viewers partitioning. I.e. the partitioning name the viewer uses to access partitioning information of its input document.- Since:
- 3.0
-
fTextPresentationListeners
All registered text presentation listeners. since 3.0 -
fFindReplaceDocumentAdapter
The find/replace document adapter.- Since:
- 3.0
-
fHyperlinkDetectors
The text viewer's hyperlink detectors.- Since:
- 3.1
-
fHyperlinkPresenter
The text viewer's hyperlink presenter.- Since:
- 3.1
-
fHyperlinkManager
The text viewer's hyperlink manager.- Since:
- 3.1
-
fHyperlinkStateMask
protected int fHyperlinkStateMaskThe SWT key modifier mask which in combination with the left mouse button triggers the hyperlink mode.- Since:
- 3.1
-
-
Constructor Details
-
TextViewer
protected TextViewer()Internal use only -
TextViewer
Create a new text viewer with the given SWT style bits. The viewer is ready to use but does not have any plug-in installed.- Parameters:
parent
- the parent of the viewer's controlstyles
- the SWT style bits for the viewer's control, ifSWT.WRAP
is set then a custom document adapter needs to be provided, seecreateDocumentAdapter()
-
-
Method Details
-
createTextWidget
Factory method to create the text widget to be used as the viewer's text widget.- Parameters:
parent
- the parent of the styled textstyles
- the styles for the styled text- Returns:
- the text widget to be used
-
createDocumentAdapter
Factory method to create the document adapter to be used by this viewer.- Returns:
- the document adapter to be used
-
createControl
Creates the viewer's SWT control. The viewer's text widget either is the control or is a child of the control.- Parameters:
parent
- the parent of the viewer's controlstyles
- the SWT style bits for the viewer's control
-
getControl
Description copied from class:Viewer
Returns the primary control associated with this viewer.- Specified by:
getControl
in interfaceITextViewerExtension
- Specified by:
getControl
in classViewer
- Returns:
- the SWT control which displays this viewer's content
-
activatePlugins
public void activatePlugins()Description copied from interface:ITextViewer
Activates the installed plug-ins. If the plug-ins are already activated this call has no effect.- Specified by:
activatePlugins
in interfaceITextViewer
-
resetPlugins
public void resetPlugins()Description copied from interface:ITextViewer
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. E.g., if anIUndoManager
has been installed on this text viewer, the manager's list of remembered text editing operations is removed.- Specified by:
resetPlugins
in interfaceITextViewer
-
handleDispose
protected void handleDispose()Frees all resources allocated by this viewer. Internally called when the viewer's control has been disposed. -
getTextWidget
Description copied from interface:ITextViewer
Returns this viewer's SWT control,null
if the control is disposed.Calling API directly on the widget can interfere with features provided by a text viewer. Clients who call API directly on the widget are responsible to resolve such conflicts on their side.
- Specified by:
getTextWidget
in interfaceITextViewer
- Returns:
- the SWT control or
null
-
getEmptySelectionChangedEventDelay
protected int getEmptySelectionChangedEventDelay()The delay in milliseconds before an empty selection changed event is sent by the cursor listener.Note: The return value is used to initialize the cursor listener. To return a non-constant value has no effect.
This implementation returns
OpenStrategy.getPostSelectionDelay()
.- Returns:
- delay in milliseconds
- Since:
- 3.0
- See Also:
-
setAutoIndentStrategy
Deprecated.Sets this viewer's auto indent strategy for the given content type. If the given strategy isnull
any installed strategy for the content type is removed. This method has been replaced byITextViewerExtension2.prependAutoEditStrategy(IAutoEditStrategy, String)
andITextViewerExtension2.removeAutoEditStrategy(IAutoEditStrategy, String)
. It is now equivalent toITextViewerExtension2 extension= (ITextViewerExtension2) viewer; extension.removeAutoEditStrategy(oldStrategy, contentType); extension.prependAutoEditStrategy(strategy, contentType);
- Specified by:
setAutoIndentStrategy
in interfaceITextViewer
- Parameters:
strategy
- the new auto indent strategy.null
is a valid argument.contentType
- the type for which the strategy is registered
-
setAutoEditStrategies
Sets the given edit strategy as the only strategy for the given content type.- Parameters:
strategies
- the auto edit strategiescontentType
- the content type- Since:
- 3.1
-
prependAutoEditStrategy
Description copied from interface:ITextViewerExtension2
Prepends the given auto edit strategy to the existing list of strategies for the specified content type. The strategies are called in the order in which they appear in the list of strategies.- Specified by:
prependAutoEditStrategy
in interfaceITextViewerExtension2
- Parameters:
strategy
- the auto edit strategycontentType
- the content type
-
removeAutoEditStrategy
Description copied from interface:ITextViewerExtension2
Removes the first occurrence of the given auto edit strategy in the list of strategies registered under the specified content type.- Specified by:
removeAutoEditStrategy
in interfaceITextViewerExtension2
- Parameters:
strategy
- the auto edit strategycontentType
- the content type
-
setEventConsumer
Description copied from interface:ITextViewer
Registers an event consumer with this viewer. This method has been replaces with theVerifyKeyListener
management methods inITextViewerExtension
.- Specified by:
setEventConsumer
in interfaceITextViewer
- Parameters:
consumer
- the viewer's event consumer.null
is a valid argument.
-
setIndentPrefixes
Description copied from interface:ITextViewer
Sets the strings that are used as prefixes when lines of the given content type are shifted using the shift text operation. The prefixes are considered equivalent. Thus "\t" and " " can both be used as prefix characters. Shift right always inserts the indentPrefixes[0]. Shift left removes all of the specified prefixes.- Specified by:
setIndentPrefixes
in interfaceITextViewer
- Parameters:
indentPrefixes
- the prefixes to be usedcontentType
- the content type for which the prefixes are specified
-
getTopInset
public int getTopInset()Description copied from interface:ITextViewer
Returns the vertical offset of the first visible line.- Specified by:
getTopInset
in interfaceITextViewer
- Returns:
- the vertical offset of the first visible line
-
isEditable
public boolean isEditable()Description copied from interface:ITextViewer
Returns whether the shown text can be manipulated.- Specified by:
isEditable
in interfaceITextViewer
- Returns:
- the viewer's editable state
-
setEditable
public void setEditable(boolean editable) Description copied from interface:ITextViewer
Sets the editable state.- Specified by:
setEditable
in interfaceITextViewer
- Parameters:
editable
- the editable state
-
setDefaultPrefixes
Description copied from interface:ITextViewer
Sets the strings that are used as prefixes when lines of the given content type are prefixed using the prefix text operation. The prefixes are considered equivalent. Inserting a prefix always inserts the defaultPrefixes[0]. Removing a prefix removes all of the specified prefixes.- Specified by:
setDefaultPrefixes
in interfaceITextViewer
- Parameters:
defaultPrefixes
- the prefixes to be usedcontentType
- the content type for which the prefixes are specified
-
setUndoManager
Description copied from interface:ITextViewer
Sets this viewer's undo manager.- Specified by:
setUndoManager
in interfaceITextViewer
- Parameters:
undoManager
- the new undo manager.null
is a valid argument.
-
getUndoManager
Description copied from interface:ITextViewerExtension6
Returns this viewer's undo manager.- Specified by:
getUndoManager
in interfaceITextViewerExtension6
- Returns:
- the undo manager or
null
if it has not been plugged-in
-
setTextHover
Description copied from interface:ITextViewer
Sets this viewer's text hover for the given content type.This method has been replaced by
ITextViewerExtension2.setTextHover(ITextHover, String, int)
. It is now equivalent toITextViewerExtension2 extension= (ITextViewerExtension2) document; extension.setTextHover(textViewerHover, contentType, ITextViewerExtension2#DEFAULT_HOVER_STATE_MASK);
- Specified by:
setTextHover
in interfaceITextViewer
- Parameters:
hover
- the new hover.null
is a valid argument.contentType
- the type for which the hover is registered
-
setTextHover
Description copied from interface:ITextViewerExtension2
Sets this viewer's text hover for the given content type and the given state mask. If the given text hover isnull
, any hover installed for the given content type and state mask is removed.- Specified by:
setTextHover
in interfaceITextViewerExtension2
- Parameters:
hover
- the new hover ornull
contentType
- the type for which the hover is to be registered or unregisteredstateMask
- the SWT event state mask;DEFAULT_HOVER_STATE_MASK
indicates that the hover is installed as the default hover.
-
removeTextHovers
Description copied from interface:ITextViewerExtension2
Removes all text hovers for the given content type independent from their state mask.Note: To remove a hover for a given content type and state mask use
ITextViewerExtension2.setTextHover(ITextHover, String, int)
withnull
as parameter for the text hover.- Specified by:
removeTextHovers
in interfaceITextViewerExtension2
- Parameters:
contentType
- the type for which all text hovers are to be unregistered
-
getTextHover
Returns the text hover for a given offset.- Parameters:
offset
- the offset for which to return the text hover- Returns:
- the text hover for the given offset
-
getTextHover
Returns the text hover for a given offset and a given state mask.- Parameters:
offset
- the offset for which to return the text hoverstateMask
- the SWT event state mask- Returns:
- the text hover for the given offset and state mask
- Since:
- 2.1
-
getTextHoveringController
Returns the text hovering controller of this viewer.- Returns:
- the text hovering controller of this viewer
- Since:
- 2.0
-
setHoverControlCreator
Sets the creator for the hover controls.- Parameters:
creator
- the hover control creator- Since:
- 2.0
-
setHoverEnrichMode
Sets the hover enrich mode. A non-null
mode
defines when hovers should be enriched once the mouse is moved into them. Ifmode
isnull
, hovers are automatically closed when the mouse is moved out of thehover region
.Note that a hover can only be enriched if its
IInformationControlExtension5.getInformationPresenterControlCreator()
is notnull
.- Specified by:
setHoverEnrichMode
in interfaceITextViewerExtension8
- Parameters:
mode
- the enrich mode, ornull
- Since:
- 3.4
-
requestWidgetToken
Description copied from interface:IWidgetTokenOwner
Requests the widget token from this token owner. Returnstrue
if the token has been acquired or is already owned by the requester. This method is non-blocking.Replaced by
IWidgetTokenOwnerExtension.requestWidgetToken(IWidgetTokenKeeper, int)
.- Specified by:
requestWidgetToken
in interfaceIWidgetTokenOwner
- Parameters:
requester
- the token requester- Returns:
true
if requester acquires the token,false
otherwise
-
requestWidgetToken
Description copied from interface:IWidgetTokenOwnerExtension
Requests the widget token from this token owner. Returnstrue
if the token has been acquired or is already owned by the requester. This method is non-blocking.priority
is forwarded to any existing token keeper to give it an estimate on whether the request has higher priority than the current keeper's. There is, however, no guarantee that another keeper will release the token even if it has a high priority.- Specified by:
requestWidgetToken
in interfaceIWidgetTokenOwnerExtension
- Parameters:
requester
- the token requesterpriority
- the priority of the request- Returns:
true
if requester acquires the token,false
otherwise
-
releaseWidgetToken
Description copied from interface:IWidgetTokenOwner
The given token keeper releases the token to this token owner. If the token has previously not been held by the given token keeper, nothing happens. This method is non-blocking.- Specified by:
releaseWidgetToken
in interfaceIWidgetTokenOwner
- Parameters:
tokenKeeper
- the token keeper
-
getLastKnownSelection
Description copied from interface:ITextViewerExtension9
Returns the last known selection from a cache, without polling widget.This may not be the current selection. Indeed, operations that change the selection without sending related events may not refresh the returned value.
As opposed to
ISelectionProvider.getSelection()
that usually requires UI Thread, this method can run from any thread.- Specified by:
getLastKnownSelection
in interfaceITextViewerExtension9
- Returns:
- the last known selection.
-
getSelectedRange
Description copied from interface:ITextViewer
Returns the range of the current selection in coordinates of this viewer's document.- Specified by:
getSelectedRange
in interfaceITextViewer
- Returns:
- a
Point
with x as the offset and y as the length of the current selection
-
setSelectedRange
public void setSelectedRange(int selectionOffset, int selectionLength) Description copied from interface:ITextViewer
Sets the selection to the specified range.- Specified by:
setSelectedRange
in interfaceITextViewer
- Parameters:
selectionOffset
- the offset of the selection rangeselectionLength
- the length of the selection range. A negative length places the caret at the visual start of the selection.
-
validateSelectionRange
protected void validateSelectionRange(int[] selectionRange) Validates and adapts the given selection range if it is not a valid widget selection. The widget selection is invalid if it starts or ends inside a multi-character line delimiter. If so, the selection is adapted to start after the divided line delimiter and to end before the divided line delimiter. The parameter passed in is changed in-place when being adapted. An adaptation to[-1, -1]
indicates that the selection range could not be validated. Subclasses may reimplement this method.- Parameters:
selectionRange
- selectionRange[0] is the offset, selectionRange[1] the length of the selection to validate.- Since:
- 2.0
-
setSelection
Description copied from class:Viewer
Sets a new selection for this viewer and optionally makes it visible.Subclasses must implement this method.
- Specified by:
setSelection
in classViewer
- Parameters:
selection
- the new selectionreveal
-true
if the selection is to be made visible, andfalse
otherwise
-
getSelection
Description copied from interface:ISelectionProvider
Returns the current selection for this provider.- Specified by:
getSelection
in interfaceISelectionProvider
- Specified by:
getSelection
in classViewer
- Returns:
- the current selection
-
getSelectionProvider
Description copied from interface:ITextViewer
Returns a selection provider dedicated to this viewer. Subsequent calls to this method return always the same selection provider.- Specified by:
getSelectionProvider
in interfaceITextViewer
- Returns:
- this viewer's selection provider
-
addPostSelectionChangedListener
Description copied from interface:IPostSelectionProvider
Adds a listener for post selection changes in this selection provider. Has no effect if an identical listener is already registered.- Specified by:
addPostSelectionChangedListener
in interfaceIPostSelectionProvider
- Parameters:
listener
- a selection changed listener
-
removePostSelectionChangedListener
Description copied from interface:IPostSelectionProvider
Removes the given listener for post selection changes from this selection provider. Has no effect if an identical listener is not registered.- Specified by:
removePostSelectionChangedListener
in interfaceIPostSelectionProvider
- Parameters:
listener
- a selection changed listener
-
firePostSelectionChanged
protected void firePostSelectionChanged(int offset, int length) Sends out a text selection changed event to all registered post selection changed listeners.- Parameters:
offset
- the offset of the newly selected range in the visible documentlength
- the length of the newly selected range in the visible document- Since:
- 3.0
-
selectionChanged
protected void selectionChanged(int offset, int length) Sends out a text selection changed event to all registered listeners and registers the selection changed event to be sent out to all post selection listeners.- Parameters:
offset
- the offset of the newly selected range in the visible documentlength
- the length of the newly selected range in the visible document
-
fireSelectionChanged
protected void fireSelectionChanged(int offset, int length) Sends out a text selection changed event to all registered listeners.- Parameters:
offset
- the offset of the newly selected range in the visible documentlength
- the length of the newly selected range in the visible document- Since:
- 3.0
-
markChanged
protected void markChanged(int offset, int length) Sends out a mark selection changed event to all registered listeners.- Parameters:
offset
- the offset of the mark selection in the visible document, the offset is-1
if the mark was clearedlength
- the length of the mark selection, may be negative if the caret is before the mark.- Since:
- 2.0
-
addTextListener
Description copied from interface:ITextViewer
Adds a text listener to this viewer. If the listener is already registered with this viewer, this call has no effect.- Specified by:
addTextListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be added
-
removeTextListener
Description copied from interface:ITextViewer
Removes the given listener from this viewer's set of text listeners. If the listener is not registered with this viewer, this call has no effect.- Specified by:
removeTextListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be removed
-
updateTextListeners
Informs all registered text listeners about the change specified by the widget command. This method does not use a robust iterator.- Parameters:
cmd
- the widget command translated into a text event sent to all text listeners
-
addTextInputListener
Description copied from interface:ITextViewer
Adds a text input listener to this viewer. If the listener is already registered with this viewer, this call has no effect.- Specified by:
addTextInputListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be added
-
removeTextInputListener
Description copied from interface:ITextViewer
Removes the given listener from this viewer's set of text input listeners. If the listener is not registered with this viewer, this call has no effect.- Specified by:
removeTextInputListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be removed
-
fireInputDocumentAboutToBeChanged
Informs all registered text input listeners about the forthcoming input change, This method does not use a robust iterator.- Parameters:
oldInput
- the old input documentnewInput
- the new input document
-
fireInputDocumentChanged
Informs all registered text input listeners about the successful input change, This method does not use a robust iterator.- Parameters:
oldInput
- the old input documentnewInput
- the new input document
-
getInput
Description copied from interface:IInputProvider
Returns the input.- Specified by:
getInput
in interfaceIInputProvider
- Specified by:
getInput
in classViewer
- Returns:
- the input object
-
getDocument
Description copied from interface:ITextViewer
Returns the text viewer's input document.- Specified by:
getDocument
in interfaceITextViewer
- Returns:
- the viewer's input document or
null
if none
-
setInput
Description copied from class:Viewer
Sets or clears the input for this viewer. -
setDocument
Description copied from interface:ITextViewer
Sets the given document as the text viewer's model and updates the presentation accordingly. An appropriateTextEvent
is issued. This text event does not carry a related document event.- Specified by:
setDocument
in interfaceITextViewer
- Parameters:
document
- the viewer's new input documentnull
if none
-
setDocument
Description copied from interface:ITextViewer
Sets the given document as this viewer's model and exposes the specified region. An appropriateTextEvent
is issued. The text event does not carry a related document event. This method is a convenience method forsetDocument(document);setVisibleRegion(offset, length)
.- Specified by:
setDocument
in interfaceITextViewer
- Parameters:
document
- the new input document ornull
if nonemodelRangeOffset
- the offset of the model rangemodelRangeLength
- the length of the model range
-
createSlaveDocument
Creates a slave document for the given document if there is a slave document manager associated with this viewer.- Parameters:
document
- the master document- Returns:
- the newly created slave document
- Since:
- 2.1
-
updateVisibleDocument
@Deprecated protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException Deprecated.useupdateSlaveDocument
insteadSets the given slave document to the specified range of its master document.- Parameters:
visibleDocument
- the slave documentvisibleRegionOffset
- the offset of the master document rangevisibleRegionLength
- the length of the master document range- Returns:
true
if the slave has been adapted successfully- Throws:
BadLocationException
- in case the specified range is not valid in the master document- Since:
- 2.1
-
updateSlaveDocument
protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException Updates the given slave document to show the specified range of its master document.- Parameters:
slaveDocument
- the slave documentmodelRangeOffset
- the offset of the master document rangemodelRangeLength
- the length of the master document range- Returns:
true
if the slave has been adapted successfully- Throws:
BadLocationException
- in case the specified range is not valid in the master document- Since:
- 3.0
-
addViewportListener
Description copied from interface:ITextViewer
Adds the given view port listener to this viewer. If the listener is already registered with this viewer, this call has no effect.- Specified by:
addViewportListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be added
-
removeViewportListener
Description copied from interface:ITextViewer
Removes the given listener from this viewer's set of view port listeners. If the listener is not registered with this viewer, this call has no effect.- Specified by:
removeViewportListener
in interfaceITextViewer
- Parameters:
listener
- the listener to be removed
-
updateViewportListeners
protected void updateViewportListeners(int origin) Checks whether the view port changed and if so informs all registered listeners about the change.- Parameters:
origin
- describes under which circumstances this method has been called.- See Also:
-
getTopIndex
public int getTopIndex()Description copied from interface:ITextViewer
Returns the visible line with the smallest line number.- Specified by:
getTopIndex
in interfaceITextViewer
- Returns:
- the number of the top most visible line
-
setTopIndex
public void setTopIndex(int index) Description copied from interface:ITextViewer
Scrolls the widget so that the given index is the line with the smallest line number of all visible lines.- Specified by:
setTopIndex
in interfaceITextViewer
- Parameters:
index
- the line which should become the top most line
-
getVisibleLinesInViewport
Deprecated.as of 3.2Returns the number of lines that can fully fit into the viewport. This is computed by dividing the widget's client area height by the widget's line height. The result is only accurate if the widget does not use variable line heights - for that reason, clients should not use this method any longer and use the client area height of the text widget to find out how much content fits into it.- Returns:
- the view port height in lines
-
getBottomIndex
public int getBottomIndex()Description copied from interface:ITextViewer
Returns the visible line with the highest line number.- Specified by:
getBottomIndex
in interfaceITextViewer
- Returns:
- the number of the bottom most line
-
getTopIndexStartOffset
public int getTopIndexStartOffset()Description copied from interface:ITextViewer
Returns the document offset of the upper left corner of this viewer's view port.- Specified by:
getTopIndexStartOffset
in interfaceITextViewer
- Returns:
- the upper left corner offset
-
getBottomIndexEndOffset
public int getBottomIndexEndOffset()Description copied from interface:ITextViewer
Returns the document offset of the lower right corner of this viewer's view port. This is the visible character with the highest character position. If the content of this viewer is shorter, the position of the last character of the content is returned.- Specified by:
getBottomIndexEndOffset
in interfaceITextViewer
- Returns:
- the lower right corner offset
-
revealRange
public void revealRange(int start, int length) Description copied from interface:ITextViewer
Ensures that the given range is visible.- Specified by:
revealRange
in interfaceITextViewer
- Parameters:
start
- the offset of the range to be revealedlength
- the length of the range to be revealed
-
internalRevealRange
protected void internalRevealRange(int start, int end) Reveals the given range of the visible document.- Parameters:
start
- the start offset of the rangeend
- the end offset of the range
-
getWidthInPixels
Deprecated.usegetWidthInPixels(int, int)
insteadReturns the width of the text when being drawn into this viewer's widget.- Parameters:
text
- the string to measure- Returns:
- the width of the presentation of the given string
-
getExtent
Returns the region covered by the given start and end offset. The result is relative to the upper left corner of the widget client area.- Parameters:
start
- offset relative to the start of this viewer's view port 0 <= offset <= getCharCount()end
- offset relative to the start of this viewer's view port 0 <= offset <= getCharCount()- Returns:
- the region covered by start and end offset
-
getWidthInPixels
protected final int getWidthInPixels(int offset, int length) Returns the width of the representation of a text range in the visible region of the viewer's document as drawn in this viewer's widget.- Parameters:
offset
- the offset of the text range in the visible regionlength
- the length of the text range in the visible region- Returns:
- the width of the presentation of the specified text range
- Since:
- 2.0
-
getAverageCharWidth
protected final int getAverageCharWidth()Returns the average character width of this viewer's widget.- Returns:
- the average character width of this viewer's widget
-
refresh
public void refresh()Description copied from class:Viewer
Refreshes this viewer completely with information freshly obtained from this viewer's model. -
getSlaveDocumentManager
Returns the slave document manager- Returns:
- the slave document manager
- Since:
- 2.1
-
createSlaveDocumentManager
Creates a new slave document manager. This implementation always returns aChildDocumentManager
.- Returns:
- ISlaveDocumentManager
- Since:
- 2.1
-
invalidateTextPresentation
public final void invalidateTextPresentation()Description copied from interface:ITextViewer
Marks the currently applied text presentation as invalid. It is the viewer's responsibility to take any action it can to repair the text presentation.See
ITextViewerExtension2.invalidateTextPresentation(int, int)
for a way to invalidate specific regions rather than the presentation as a whole.- Specified by:
invalidateTextPresentation
in interfaceITextViewer
-
invalidateTextPresentation
public final void invalidateTextPresentation(int offset, int length) Invalidates the given range of the text presentation.- Specified by:
invalidateTextPresentation
in interfaceITextViewerExtension2
- Parameters:
offset
- the offset of the range to be invalidatedlength
- the length of the range to be invalidated- Since:
- 2.1
-
freeSlaveDocument
Frees the given document if it is a slave document.- Parameters:
slave
- the potential slave document- Since:
- 3.0
-
setVisibleDocument
Sets this viewer's visible document. The visible document represents the visible region of the viewer's input document.- Parameters:
document
- the visible document
-
handleVisibleDocumentAboutToBeChanged
Hook method called when the visible document is about to be changed.Subclasses may override.
- Parameters:
event
- the document event- Since:
- 3.0
-
handleVisibleDocumentChanged
Hook method called when the visible document has been changed.Subclasses may override.
- Parameters:
event
- the document event- Since:
- 3.0
-
initializeDocumentInformationMapping
Initializes the document information mapping between the given slave document and its master document.- Parameters:
visibleDocument
- the slave document- Since:
- 2.1
-
getVisibleDocument
Returns the viewer's visible document.- Returns:
- the viewer's visible document
-
_getVisibleRegionOffset
protected int _getVisibleRegionOffset()Returns the offset of the visible region.- Returns:
- the offset of the visible region
-
getVisibleRegion
Description copied from interface:ITextViewer
Returns the current visible region of this viewer's document. The result may differ from the argument passed tosetVisibleRegion
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.- Specified by:
getVisibleRegion
in interfaceITextViewer
- Returns:
- this viewer's current visible region
-
overlapsWithVisibleRegion
public boolean overlapsWithVisibleRegion(int start, int length) Description copied from interface:ITextViewer
Returns whether a given range overlaps with the visible region of this viewer's document.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.- Specified by:
overlapsWithVisibleRegion
in interfaceITextViewer
- Parameters:
start
- the offsetlength
- the length- Returns:
true
if the specified range overlaps with the visible region
-
setVisibleRegion
public void setVisibleRegion(int start, int length) Description copied from interface:ITextViewer
Defines and sets the region of this viewer's document which will be visible in the presentation. Every character inside the specified region is supposed to be visible in the viewer's widget after that call.- Specified by:
setVisibleRegion
in interfaceITextViewer
- Parameters:
start
- the offset of the visible regionlength
- the length of the visible region
-
resetVisibleRegion
public void resetVisibleRegion()Description copied from interface:ITextViewer
Resets the region of this viewer's document which is visible in the presentation. Afterwards, the whole input document is visible.- Specified by:
resetVisibleRegion
in interfaceITextViewer
-
setTextDoubleClickStrategy
Description copied from interface:ITextViewer
Sets this viewer's text double click strategy for the given content type.- Specified by:
setTextDoubleClickStrategy
in interfaceITextViewer
- Parameters:
strategy
- the new double click strategy.null
is a valid argument.contentType
- the type for which the strategy is registered
-
selectContentTypePlugin
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 plug-inplugins
- the map from which to choose- Returns:
- the plug-in registered under the offset's content type or
null
if none
-
customizeDocumentCommand
Hook called on receipt of aVerifyEvent
. The event has been translated into aDocumentCommand
which can now be manipulated by interested parties. By default, the hook forwards the command to the installed instances ofIAutoEditStrategy
.- Parameters:
command
- the document command representing the verify event
-
handleVerifyEvent
Handles the verify event issued by the viewer's text widget.- Parameters:
e
- the verify event- See Also:
-
canDoOperation
public boolean canDoOperation(int operation) Description copied from interface:ITextOperationTarget
Returns whether the operation specified by the given operation code can be performed.- Specified by:
canDoOperation
in interfaceITextOperationTarget
- Parameters:
operation
- the operation code- Returns:
true
if the specified operation can be performed
-
doOperation
public void doOperation(int operation) Description copied from interface:ITextOperationTarget
Performs the operation specified by the operation code on the target.doOperation
must only be called ifcanDoOperation
returnstrue
.- Specified by:
doOperation
in interfaceITextOperationTarget
- Parameters:
operation
- the operation code
-
ignoreAutoEditStrategies
protected void ignoreAutoEditStrategies(boolean ignore) Tells this viewer whether the registered auto edit strategies should be ignored.- Parameters:
ignore
-true
if the strategies should be ignored.- Since:
- 2.1
-
isIgnoringAutoEditStrategies
protected boolean isIgnoringAutoEditStrategies()Returns whether this viewer ignores the registered auto edit strategies.- Returns:
true
if the strategies are ignored- Since:
- 2.1
-
enableOperation
public void enableOperation(int operation, boolean enable) Description copied from interface:ITextOperationTargetExtension
Enables/disabled the given text operation.- Specified by:
enableOperation
in interfaceITextOperationTargetExtension
- Parameters:
operation
- the operation to enable/disableenable
-true
to enable the operation otherwisefalse
-
copyMarkedRegion
protected void copyMarkedRegion(boolean delete) Copies/cuts the marked region.- Parameters:
delete
-true
if the region should be deleted rather than copied.- Since:
- 2.0
-
deleteText
Deprecated.useStyledText.invokeAction
insteadDeletes the current selection. If the selection has the length 0 the selection is automatically extended to the right - either by 1 or by the length of line delimiter if at the end of a line. -
isBlockSelected
protected boolean isBlockSelected()A block is selected if the character preceding the start of the selection is a new line character.- Returns:
true
if a block is selected
-
areMultipleLinesSelected
protected boolean areMultipleLinesSelected()Returnstrue
if one line is completely selected or if multiple lines are selected. Being completely selected means that all characters except the new line characters are selected.- Returns:
true
if one or multiple lines are selected- Since:
- 2.0
-
shift
Deprecated.use shift(boolean, boolean, boolean) insteadShifts a text block to the right or left using the specified set of prefix characters. The prefixes must start at the beginning of the line.- Parameters:
useDefaultPrefixes
- says whether the configured default or indent prefixes should be usedright
- says whether to shift to the right or the left
-
shift
protected void shift(boolean useDefaultPrefixes, boolean right, boolean ignoreWhitespace) Shifts a text block to the right or left using the specified set of prefix characters. If white space should be ignored the prefix characters must not be at the beginning of the line when shifting to the left. There may be whitespace in front of the prefixes.- Parameters:
useDefaultPrefixes
- says whether the configured default or indent prefixes should be usedright
- says whether to shift to the right or the leftignoreWhitespace
- says whether whitespace in front of prefixes is allowed- Since:
- 2.0
-
isPrintable
protected boolean isPrintable()Returns whether the shown text can be printed.- Returns:
- the viewer's printable mode
-
print
Print the text viewer contents using the given options.- Specified by:
print
in interfaceITextViewerExtension8
- Parameters:
options
- the print options- Since:
- 3.4
-
print
protected void print()Brings up a print dialog and callsprintContents(Printer)
which performs the actual print. -
canPerformFind
protected boolean canPerformFind()Adheres to the contract ofIFindReplaceTarget.canPerformFind()
.- Returns:
true
if find can be performed,false
otherwise
-
findAndSelect
@Deprecated protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) Deprecated.Adheres to the contract ofIFindReplaceTarget.findAndSelect(int, String, boolean, boolean, boolean)
.- Parameters:
startPosition
- the start positionfindString
- the find string specificationforwardSearch
- the search directioncaseSensitive
-true
if case sensitive,false
otherwisewholeWord
-true
if match must be whole words,false
otherwise- Returns:
- the model offset of the first match
-
findAndSelect
protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) Adheres to the contract ofIFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean)
.- Parameters:
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
iffindString
is a regular expression,false
otherwise- Returns:
- the model offset of the first match
-
findAndSelectInRange
protected int findAndSelectInRange(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, int rangeOffset, int rangeLength, boolean regExSearch) Adheres to the contract ofIFindReplaceTargetExtension3.findAndSelect(int, String, boolean, boolean, boolean, boolean)
.- Parameters:
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
iffindString
is a regular expression,false
otherwise- Returns:
- the model offset of the first match
- Since:
- 3.0
-
setTextColor
Description copied from interface:ITextViewer
Applies the given color as text foreground color to this viewer's selection.- Specified by:
setTextColor
in interfaceITextViewer
- Parameters:
color
- the color to be applied
-
setTextColor
Description copied from interface:ITextViewer
Applies the given color as text foreground color to the specified section of this viewer.controlRedraw
tells this viewer whether it should take care of redraw management or not.- Specified by:
setTextColor
in interfaceITextViewer
- Parameters:
color
- the color to be appliedstart
- the offset of the range to be changedlength
- the length of the range to be changedcontrolRedraw
- indicates whether this viewer should manage redraws
-
_internalGetVisibleRegion
Returns the visible region if it is not equal to the whole document. Otherwise returnsnull
.- Returns:
- the viewer's visible region if smaller than input document, otherwise
null
-
changeTextPresentation
Description copied from interface:ITextViewer
Applies the color information encoded in the given text presentation.controlRedraw
tells this viewer whether it should take care of redraw management or not. If, e.g., this call is one in a sequence of multiple presentation calls, it is more appropriate to explicitly control redrawing at the beginning and the end of the sequence.- Specified by:
changeTextPresentation
in interfaceITextViewer
- Parameters:
presentation
- the presentation to be applied to this viewercontrolRedraw
- indicates whether this viewer should manage redraws
-
getFindReplaceTarget
Description copied from interface:ITextViewer
Returns the find/replace operation target of this viewer.- Specified by:
getFindReplaceTarget
in interfaceITextViewer
- Returns:
- the find/replace operation target of this viewer
-
getFindReplaceDocumentAdapter
Returns the find/replace document adapter.- Returns:
- the find/replace document adapter.
- Since:
- 3.0
-
getTextOperationTarget
Description copied from interface:ITextViewer
Returns the text operation target of this viewer.- Specified by:
getTextOperationTarget
in interfaceITextViewer
- Returns:
- the text operation target of this viewer
-
appendVerifyKeyListener
Description copied from interface:ITextViewerExtension
Appends a verify key listener to the viewer's list of verify key listeners. If the listener is already registered with the viewer this call moves the listener to the end of the list.- Specified by:
appendVerifyKeyListener
in interfaceITextViewerExtension
- Parameters:
listener
- the listener to be added
-
prependVerifyKeyListener
Description copied from interface:ITextViewerExtension
Inserts the verify key listener at the beginning of the viewer's list of verify key listeners. If the listener is already registered with the viewer this call moves the listener to the beginning of the list.- Specified by:
prependVerifyKeyListener
in interfaceITextViewerExtension
- Parameters:
listener
- the listener to be inserted
-
removeVerifyKeyListener
Description copied from interface:ITextViewerExtension
Removes the verify key listener from the viewer's list of verify key listeners. If the listener is not registered with this viewer, this call has no effect.- Specified by:
removeVerifyKeyListener
in interfaceITextViewerExtension
- Parameters:
listener
- the listener to be removed
-
getMark
public int getMark()Description copied from interface:ITextViewerExtension
Returns the position of the mark,-1
if the mark is not set.- Specified by:
getMark
in interfaceITextViewerExtension
- Returns:
- the position of the mark or
-1
if no mark is set
-
setMark
public void setMark(int offset) Description copied from interface:ITextViewerExtension
Sets a mark at the given offset or clears the mark if the specified offset is-1
. If a mark is set and the selection is empty, cut and copy actions performed on this text viewer work on the region described by the positions of the mark and the cursor.- Specified by:
setMark
in interfaceITextViewerExtension
- Parameters:
offset
- the offset of the mark
-
inputChanged
Description copied from class:Viewer
Internal hook method called when the input to this viewer is initially set or subsequently changed.The default implementation does nothing. Subclassers may override this method to do something when a viewer's input is set. A typical use is populate the viewer.
- Overrides:
inputChanged
in classViewer
- Parameters:
newInput
- the new input of this viewer, ornull
if noneoldInput
- the old input element ornull
if there was previously no input
-
enabledRedrawing
protected void enabledRedrawing()Enables the redrawing of this text viewer.- Since:
- 2.0
-
enabledRedrawing
protected void enabledRedrawing(int topIndex) Enables the redrawing of this text viewer.- Parameters:
topIndex
- the top index to be set or-1
- Since:
- 3.0
-
disableRedrawing
protected void disableRedrawing()Disables the redrawing of this text viewer. Subclasses may extend.- Since:
- 2.0
-
setRedraw
public final void setRedraw(boolean redraw) Description copied from interface:ITextViewerExtension
Enables/disables the redrawing of this text viewer. This temporarily disconnects the viewer from its underlyingStyledText
widget. While being disconnected only the viewer's selection may be changed usingsetSelectedRange
. Any direct manipulation of the widget as well as calls to methods that change the viewer's presentation state (such as enabling the segmented view) are not allowed. When redrawing is disabled the viewer does not send out any selection or view port change notification. When redrawing is enabled again, a selection change notification is sent out for the selected range and this range is revealed causing a view port changed notification.- Specified by:
setRedraw
in interfaceITextViewerExtension
- Parameters:
redraw
-true
to enable redrawing,false
otherwise
-
setRedraw
protected final void setRedraw(boolean redraw, int topIndex) Basically same functionality asITextViewerExtension.setRedraw(boolean)
. Adds a way for subclasses to pass in a desired top index that should be used whenredraw
istrue
. IftopIndex
is -1, this method is identical toITextViewerExtension.setRedraw(boolean)
.- Parameters:
redraw
-true
if redraw is enabledtopIndex
- the top index- Since:
- 3.0
- See Also:
-
redraws
protected final boolean redraws()Returns whether this viewer redraws itself.- Returns:
true
if this viewer redraws itself- Since:
- 2.0
-
startSequentialRewriteMode
Deprecated.since 3.1 useIDocumentExtension4.startRewriteSession(DocumentRewriteSessionType)
insteadStarts the sequential rewrite mode of the viewer's document.- Parameters:
normalized
-true
if the rewrite is performed from the start to the end of the document- Since:
- 2.0
-
stopSequentialRewriteMode
Deprecated.since 3.1 useIDocumentExtension4.stopRewriteSession(DocumentRewriteSession)
insteadSets the sequential rewrite mode of the viewer's document.- Since:
- 2.0
-
getRewriteTarget
Description copied from interface:ITextViewerExtension
Returns the viewer's rewrite target.- Specified by:
getRewriteTarget
in interfaceITextViewerExtension
- Returns:
- the viewer's rewrite target
-
getCurrentTextHover
Description copied from interface:ITextViewerExtension2
Returns the currently displayed text hover if any,null
otherwise.- Specified by:
getCurrentTextHover
in interfaceITextViewerExtension2
- Returns:
- the currently displayed text hover or
null
-
getHoverEventLocation
Description copied from interface:ITextViewerExtension2
Returns the location at which the most recent mouse hover event has occurred.- Specified by:
getHoverEventLocation
in interfaceITextViewerExtension2
- Returns:
- the location of the most recent mouse hover event
-
getPaintManager
Returns the paint manager of this viewer.- Returns:
- the paint manager of this viewer
- Since:
- 2.1
-
addPainter
Adds the given painter to this viewer. If the painter is already registered this method is without effect.- Specified by:
addPainter
in interfaceITextViewerExtension2
- Parameters:
painter
- the painter to be added- Since:
- 2.1
-
removePainter
Removes the given painter from this viewer. If the painter has previously not been added to this viewer this method is without effect.- Specified by:
removePainter
in interfaceITextViewerExtension2
- Parameters:
painter
- the painter to be removed- Since:
- 2.1
-
modelLine2WidgetLine
public int modelLine2WidgetLine(int modelLine) Implements the contract ofITextViewerExtension5.modelLine2WidgetLine(int)
.- Parameters:
modelLine
- the model line- Returns:
- the corresponding widget line or
-1
- Since:
- 2.1
-
modelOffset2WidgetOffset
public int modelOffset2WidgetOffset(int modelOffset) Implements the contract ofITextViewerExtension5.modelOffset2WidgetOffset(int)
.- Parameters:
modelOffset
- the model offset- Returns:
- the corresponding widget offset or
-1
- Since:
- 2.1
-
modelRange2WidgetRange
Implements the contract ofITextViewerExtension5.modelRange2WidgetRange(IRegion)
.- Parameters:
modelRange
- the model range- Returns:
- the corresponding widget range or
null
- Since:
- 2.1
-
modelRange2ClosestWidgetRange
Similar tomodelRange2WidgetRange(IRegion)
, but more forgiving: ifmodelRange
describes a region entirely hidden in the image, then this method returns the zero-length region at the offset of the folded region.- Parameters:
modelRange
- the model range- Returns:
- the corresponding widget range, or
null
- Since:
- 3.1
-
widgetlLine2ModelLine
public int widgetlLine2ModelLine(int widgetLine) Implements the contract ofITextViewerExtension5.widgetLine2ModelLine(int)
.- Parameters:
widgetLine
- the widget line- Returns:
- the corresponding model line
- Since:
- 2.1
-
widgetLine2ModelLine
public int widgetLine2ModelLine(int widgetLine) Implements the contract ofITextViewerExtension5.widgetLine2ModelLine(int)
.- Parameters:
widgetLine
- the widget line- Returns:
- the corresponding model line or
-1
- Since:
- 3.0
-
widgetOffset2ModelOffset
public int widgetOffset2ModelOffset(int widgetOffset) Implements the contract ofITextViewerExtension5.widgetOffset2ModelOffset(int)
.- Parameters:
widgetOffset
- the widget offset- Returns:
- the corresponding model offset or
-1
- Since:
- 2.1
-
widgetRange2ModelRange
Implements the contract ofITextViewerExtension5.widgetRange2ModelRange(IRegion)
.- Parameters:
widgetRange
- the widget range- Returns:
- the corresponding model range or
null
- Since:
- 2.1
-
getModelCoverage
Implements the contract ofITextViewerExtension5.getModelCoverage()
.- Returns:
- the model coverage
- Since:
- 2.1
-
getClosestWidgetLineForModelLine
protected int getClosestWidgetLineForModelLine(int modelLine) Returns the line of the widget whose corresponding line in the viewer's document is closest to the given line in the viewer's document or-1
.- Parameters:
modelLine
- the line in the viewer's document- Returns:
- the line in the widget that corresponds best to the given line in the viewer's document or
-1
- Since:
- 2.1
-
modelStyleRange2WidgetStyleRange
Translates a style range given relative to the viewer's document into style ranges relative to the viewer's widget ornull
.- Parameters:
range
- the style range in the coordinates of the viewer's document- Returns:
- the style range in the coordinates of the viewer's widget or
null
- Since:
- 2.1
-
modelRange2WidgetRange
Same asmodelRange2WidgetRange(IRegion)
just for aPosition
.- Parameters:
modelPosition
- the position describing a range in the viewer's document- Returns:
- a region describing a range in the viewer's widget
- Since:
- 2.1
-
event2ModelRange
Translates the widget region of the given verify event into the corresponding region of the viewer's document.- Parameters:
event
- the verify event- Returns:
- the region of the viewer's document corresponding to the verify event
- Since:
- 2.1
-
widgetSelection2ModelSelection
Translates the given widget selection into the corresponding region of the viewer's document or returnsnull
if this fails.- Parameters:
widgetSelection
- the widget selection- Returns:
- the region of the viewer's document corresponding to the widget selection or
null
- Since:
- 2.1
-
modelSelection2WidgetSelection
Translates the given selection range of the viewer's document into the corresponding widget range or returnsnull
of this fails.- Parameters:
modelSelection
- the selection range of the viewer's document- Returns:
- the widget range corresponding to the selection range or
null
- Since:
- 2.1
-
widgetLineOfWidgetOffset
public int widgetLineOfWidgetOffset(int widgetOffset) Implements the contract ofITextViewerExtension5.widgetLineOfWidgetOffset(int)
.- Parameters:
widgetOffset
- the widget offset- Returns:
- the corresponding widget line or
-1
- Since:
- 2.1
-
moveFocusToWidgetToken
public boolean moveFocusToWidgetToken()Description copied from interface:ITextViewerExtension4
Instructs the receiver to request theIWidgetTokenKeeper
currently holding the widget token to take the keyboard focus.- Specified by:
moveFocusToWidgetToken
in interfaceITextViewerExtension4
- Returns:
true
if there was anyIWidgetTokenKeeper
that was asked to take the focus,false
otherwise
-
setDocumentPartitioning
Sets the document partitioning of this viewer. The partitioning is used by this viewer to access partitioning information of the viewers input document.- Parameters:
partitioning
- the partitioning name- Since:
- 3.0
-
getDocumentPartitioning
Returns the document partitioning for this viewer.- Returns:
- the document partitioning for this viewer
- Since:
- 3.0
-
addTextPresentationListener
Description copied from interface:ITextViewerExtension4
Adds the given text presentation listener to this text viewer. This call has no effect if the listener is already registered with this text viewer.- Specified by:
addTextPresentationListener
in interfaceITextViewerExtension4
- Parameters:
listener
- the text presentation listener
-
removeTextPresentationListener
Description copied from interface:ITextViewerExtension4
Removes the given text presentation listener from this text viewer. This call has no effect if the listener is not registered with this text viewer.- Specified by:
removeTextPresentationListener
in interfaceITextViewerExtension4
- Parameters:
listener
- the text presentation listener
-
register
Description copied from interface:IEditingSupportRegistry
Register a support with the registry. If the support is already registered, nothing happens.- Specified by:
register
in interfaceIEditingSupportRegistry
- Parameters:
helper
- an editor support
-
unregister
Description copied from interface:IEditingSupportRegistry
Deregister a support with the registry. If the support is not registered, orsupport
isnull
, nothing happens.- Specified by:
unregister
in interfaceIEditingSupportRegistry
- Parameters:
helper
- the helper to deregister, ornull
-
getRegisteredSupports
Description copied from interface:IEditingSupportRegistry
Returns the current editor helpers.- Specified by:
getRegisteredSupports
in interfaceIEditingSupportRegistry
- Returns:
- an non-
null
array of currently registered editor helpers
-
setHyperlinkDetectors
Description copied from interface:ITextViewerExtension6
Sets this viewer's hyperlink detectors for the given state mask.- Specified by:
setHyperlinkDetectors
in interfaceITextViewerExtension6
- Parameters:
hyperlinkDetectors
- the new array of hyperlink detectors,null
or an empty array to disable hyperlinkingeventStateMask
- the SWT event state mask to activate hyperlink mode
-
setHyperlinkPresenter
public void setHyperlinkPresenter(IHyperlinkPresenter hyperlinkPresenter) throws IllegalStateException Sets the hyperlink presenter.This is only valid as long as the hyperlink manager hasn't been created yet.
- Parameters:
hyperlinkPresenter
- the hyperlink presenter- Throws:
IllegalStateException
- if the hyperlink manager has already been created- Since:
- 3.1
-
setTabsToSpacesConverter
Description copied from interface:ITextViewerExtension7
Sets an auto edit strategy can converts tabs to spaces.- Specified by:
setTabsToSpacesConverter
in interfaceITextViewerExtension7
- Parameters:
converter
- the converter ornull
if none should be used
-
StyledText.invokeAction
instead