Eclipse Platform
2.1

org.eclipse.jface.text
Class TextViewer

java.lang.Object
  |
  +--org.eclipse.jface.viewers.Viewer
        |
        +--org.eclipse.jface.text.TextViewer
All Implemented Interfaces:
IInputProvider, IInputSelectionProvider, ISelectionProvider, ITextOperationTarget, ITextOperationTargetExtension, ITextViewer, ITextViewerExtension, ITextViewerExtension2, IWidgetTokenOwner
Direct Known Subclasses:
SourceViewer

public class TextViewer
extends Viewer
implements ITextViewer, ITextViewerExtension, ITextViewerExtension2, ITextOperationTarget, ITextOperationTargetExtension, IWidgetTokenOwner

SWT based implementation of ITextViewer. 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.

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

See Also:
ITextViewer

Inner Class Summary
protected  class TextViewer.TextHoverKey
          Value object used as key in the text hover configuration table.
protected  class TextViewer.WidgetCommand
          Represents a replace command that brings the text viewer's text widget back in sync with text viewer's document after the document has been changed.
 
Field Summary
protected  Map fAutoIndentStrategies
          The text viewer's auto indent strategies
protected  Map fDefaultPrefixChars
          The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX
protected  Map fDoubleClickStrategies
          The text viewer's text double click strategies
protected  IEventConsumer fEventConsumer
          The text viewer's event consumer
protected  IInformationControlCreator fHoverControlCreator
          The creator of the text hover control
protected  boolean fIgnoreAutoIndent
          Should the auto indent strategies ignore the next edit operation
protected  Map fIndentChars
          The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT
protected  IDocumentInformationMapping fInformationMapping
          The mapping between model and visible document.
protected  int fLastTopPixel
          The last visible vertical position of the top line
protected  PaintManager fPaintManager
          The viewer's paint manager;
protected  boolean fReplaceTextPresentation
          Indicates whether the viewer's text presentation should be replaced are modified.
protected  Map fTextHovers
          The text viewer's text hovers
protected  List fTextInputListeners
          All registered text input listeners
protected  List fTextListeners
          All registered text listeners
protected  IUndoManager fUndoManager
          The text viewer's undo manager
protected  List fViewportListeners
          All registered viewport listeners>
protected static int INTERNAL
          Identifies internal reasons as originators of a view port change.
protected static int KEY
          Identifies key strokes as originators of a view port change.
protected static int MOUSE
          Identifies mouse moves as originators of a view port change.
protected static int MOUSE_END
          Identifies mouse button up as originator of a view port change.
protected static int RESIZE
          Identifies window resizing as originator of a view port change.
protected static int SCROLLER
          Identifies the scrollbars as originators of a view port change.
protected static String SHIFTING
          Internal name of the position category used selection preservation during shift
static boolean TRACE_ERRORS
          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.ITextViewerExtension2
DEFAULT_HOVER_STATE_MASK
 
Fields inherited from interface org.eclipse.jface.text.ITextOperationTarget
COPY, CUT, DELETE, PASTE, PREFIX, PRINT, REDO, SELECT_ALL, SHIFT_LEFT, SHIFT_RIGHT, STRIP_PREFIX, UNDO
 
Constructor Summary
protected TextViewer()
          Internal use only
  TextViewer(Composite parent, int styles)
          Create a new text viewer with the given SWT style bits.
 
Method Summary
protected  int _getVisibleRegionOffset()
          Returns the offset of the visible region.
protected  IRegion _internalGetVisibleRegion()
          Returns the visible region if it is not equal to the whole document.
 void activatePlugins()
          Activates the installed plug-ins.
 void addPainter(IPainter painter)
          Adds the given painter to this viewer.
 void addTextInputListener(ITextInputListener listener)
          Adds a text input listener to this viewer.
 void addTextListener(ITextListener listener)
          Adds a text listener to this viewer.
 void addViewportListener(IViewportListener listener)
          Adds the given viewport listener to this viewer.
 void appendVerifyKeyListener(VerifyKeyListener listener)
          Appends a verify key listener to the viewer's list of verify key listeners.
protected  boolean areMultipleLinesSelected()
          Returns true 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 canPerformFind()
           
 void changeTextPresentation(TextPresentation presentation, boolean controlRedraw)
          Applies the color information encoded in the given text presentation.
protected  void createControl(Composite parent, int styles)
          Creates the viewer's SWT control.
protected  IDocumentAdapter createDocumentAdapter()
          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 createSlaveDocumentManager()
          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 a VerifyEvent.
protected  void deleteText()
          Deprecated. use StyledText.invokeAction instead
protected  void disableRedrawing()
          Disables the redrawing of this text viewer.
 void doOperation(int operation)
          Performs the operation specified by the operation code on the target.
protected  void enabledRedrawing()
          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)
           
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 sucessful input change, This method does not use a robust iterator.
protected  int getAverageCharWidth()
          Returns the average character width of this viewer's widget.
 int getBottomIndex()
          Returns the visible line with the highest line number.
 int getBottomIndexEndOffset()
          Returns the document offset of the lower right corner of this viewer's viewport.
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.
 Control getControl()
          Returns the control of this viewer.
 ITextHover getCurrentTextHover()
          Returns the currently displayed text hover if any, null otherwise.
 IDocument getDocument()
          Returns the text viewer's input document.
protected  IRegion getExtent(int start, int end)
          Returns the region covered by the given start and end offset.
 IFindReplaceTarget getFindReplaceTarget()
          Returns the find/replace operation target of this viewer.
 Point getHoverEventLocation()
          Returns the location at which the most recent mouse hover event has been issued.
 Object getInput()
          Returns the input.
 int getMark()
          Returns the mark position, -1 if mark is not set.
 IRegion getModelCoverage()
           
protected  PaintManager getPaintManager()
          Returns the paint manager of this viewer.
 IRewriteTarget getRewriteTarget()
          Returns the viewer's rewrite target.
 Point getSelectedRange()
          Returns the range of the current selection in coordinates of this viewer's document.
 ISelection getSelection()
          Returns the current selection for this provider.
 ISelectionProvider getSelectionProvider()
          Returns a selection provider dedicated to this viewer.
protected  ISlaveDocumentManager getSlaveDocumentManager()
          Returns the slave document manager
protected  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 getTextHoveringController()
          Returns the text hovering controller of this viewer.
 ITextOperationTarget getTextOperationTarget()
          Returns the text operation target of this viewer.
 StyledText getTextWidget()
          Returns viewer's text widget.
 int getTopIndex()
          Returns the visible line with the smallest line number.
 int getTopIndexStartOffset()
          Returns the document offset of the upper left corner of this viewer's viewport.
 int getTopInset()
          Returns the vertical offset of the first visible line.
protected  IDocument getVisibleDocument()
          Returns the viewer's visible document.
protected  int getVisibleLinesInViewport()
          Returns the viewport height in lines.
 IRegion getVisibleRegion()
          Returns the current visible region of this viewer's document.
protected  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  int getWidthInPixels(String text)
          Deprecated. use getWidthInPixels(int, int) instead
protected  void handleDispose()
          Frees all resources allocated by this viewer.
protected  void handleVerifyEvent(VerifyEvent e)
           
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.
 void invalidateTextPresentation()
          Marks the currently applied text presentation as invalid.
 void invalidateTextPresentation(int offset, int length)
          Invalidates the given range of the text presentation.
protected  boolean isBlockSelected()
          A block is selected if the character preceding the start of the selection is a new line character.
 boolean isEditable()
          Returns whether the shown text can be manipulated.
protected  boolean isIgnoringAutoEditStrategies()
          Returns whether this viewer ignores the registered auto edit strategies.
protected  boolean isPrintable()
          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)
           
 int modelOffset2WidgetOffset(int modelOffset)
           
 IRegion modelRange2WidgetRange(IRegion modelRange)
           
protected  IRegion modelRange2WidgetRange(Position modelPosition)
           
protected  Point modelSelection2WidgetSelection(Point modelSelection)
          Translates the given selection range of the viewer's document into the corresponding widget range.
protected  StyleRange modelStyleRange2WidgetStyleRange(StyleRange range)
          Translates a style range given relative to the viewer's document into style ranges relative to the viewer's widget.
 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 calls printContents(Printer) which performs the actual print.
protected  boolean redraws()
          Returns whether this viewer redraws itself.
 void refresh()
          Refreshes this viewer completely with information freshly obtained from this viewer's model.
 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 removeTextHovers(String contentType)
          Removes all text hovers for the given content type.
 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 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 viewport listeners.
 boolean requestWidgetToken(IWidgetTokenKeeper requester)
          Requests the widget token from this token owner.
 void resetPlugins()
          Resets the installed plug-ins.
 void resetVisibleRegion()
          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 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.
 void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType)
          Sets this viewer's auto indent strategy for the given content type.
 void setDefaultPrefixes(String[] defaultPrefixes, String contentType)
          Sets the string that is used as prefix when lines of the given content type are prefixed by 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 visibleRegionOffset, int visibleRegionLength)
          Sets the given document as this viewer's model and makes the specified region visible in the presentation.
 void setEditable(boolean editable)
          Sets the editable mode.
 void setEventConsumer(IEventConsumer consumer)
          Registers an event consumer with this viewer.
 void setHoverControlCreator(IInformationControlCreator creator)
          Sets the creator for the hover controls.
 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 setInput(Object input)
          Sets or clears the input for this viewer.
 void setMark(int offset)
          Sets or clears the mark.
 void setRedraw(boolean redraw)
          Enables/disables the redrawing of this text viewer.
 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 setTextColor(Color color)
          Applies the given color to this viewer's selection.
 void setTextColor(Color color, int start, int length, boolean controlRedraw)
          Applies the given 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 the 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)
          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) instead
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.
protected  void startSequentialRewriteMode(boolean normalized)
          Starts the sequential rewrite mode of the viewer's document.
protected  void stopSequentialRewriteMode()
          Sets the sequential rewrite mode of the viewer's document.
protected  void updateTextListeners(TextViewer.WidgetCommand cmd)
          Informs all registered text listeners about the change specified by the widget command.
protected  void updateViewportListeners(int origin)
          Checks whether the viewport changed and if so informs all registered listeners about the change.
protected  boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength)
          Sets the given slave document to the specified range of its master document.
protected  void validateSelectionRange(int[] selectionRange)
          Validates and adapts the given selection range if it is not a valid widget selection.
 int widgetLineOfWidgetOffset(int widgetOffset)
           
 int widgetlLine2ModelLine(int widgetLine)
           
 int widgetOffset2ModelOffset(int widgetOffset)
           
 IRegion widgetRange2ModelRange(IRegion widgetRange)
           
protected  Point widgetSelection2ModelSelection(Point widgetSelection)
          Translates the given widget selection into the corresponding region of the viewer's document.
 
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
 

Field Detail

TRACE_ERRORS

public static boolean TRACE_ERRORS
Internal flag to indicate the debug state.

SCROLLER

protected static final int SCROLLER
Identifies the scrollbars as originators of a view port change.

MOUSE

protected static final int MOUSE
Identifies mouse moves as originators of a view port change.

MOUSE_END

protected static final int MOUSE_END
Identifies mouse button up as originator of a view port change.

KEY

protected static final int KEY
Identifies key strokes as originators of a view port change.

RESIZE

protected static final int RESIZE
Identifies window resizing as originator of a view port change.

INTERNAL

protected static final int INTERNAL
Identifies internal reasons as originators of a view port change.

SHIFTING

protected static final String SHIFTING
Internal name of the position category used selection preservation during shift

fIgnoreAutoIndent

protected boolean fIgnoreAutoIndent
Should the auto indent strategies ignore the next edit operation

fIndentChars

protected Map fIndentChars
The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT

fDefaultPrefixChars

protected Map fDefaultPrefixChars
The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX

fDoubleClickStrategies

protected Map fDoubleClickStrategies
The text viewer's text double click strategies

fUndoManager

protected IUndoManager fUndoManager
The text viewer's undo manager

fAutoIndentStrategies

protected Map fAutoIndentStrategies
The text viewer's auto indent strategies

fTextHovers

protected Map fTextHovers
The text viewer's text hovers

fHoverControlCreator

protected IInformationControlCreator fHoverControlCreator
The creator of the text hover control
Since:
2.0

fViewportListeners

protected List fViewportListeners
All registered viewport listeners>

fLastTopPixel

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

fTextListeners

protected List fTextListeners
All registered text listeners

fTextInputListeners

protected List fTextInputListeners
All registered text input listeners

fEventConsumer

protected IEventConsumer fEventConsumer
The text viewer's event consumer

fReplaceTextPresentation

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

fInformationMapping

protected IDocumentInformationMapping fInformationMapping
The mapping between model and visible document.
Since:
2.1

fPaintManager

protected PaintManager fPaintManager
The viewer's paint manager;
Since:
2.1
Constructor Detail

TextViewer

protected TextViewer()
Internal use only

TextViewer

public TextViewer(Composite parent,
                  int styles)
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 control
styles - the SWT style bits for the viewer's control
Method Detail

createTextWidget

protected StyledText createTextWidget(Composite parent,
                                      int styles)
Factory method to create the text widget to be used as the viewer's text widget.
Returns:
the text widget to be used

createDocumentAdapter

protected IDocumentAdapter createDocumentAdapter()
Factory method to create the document adapter to be used by this viewer.
Returns:
the document adapter to be used

createControl

protected void createControl(Composite parent,
                             int styles)
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 control
styles - the SWT style bits for the viewer's control

getControl

public Control getControl()
Description copied from interface: ITextViewerExtension
Returns the control of this viewer.
Specified by:
getControl in interface ITextViewerExtension
Overrides:
getControl in class Viewer
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Returns:
the control of this viewer

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 interface ITextViewer

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 an IUndoManager has been installed on this text viewer, the manager's list of remembered text editing operations is removed.
Specified by:
resetPlugins in interface ITextViewer

handleDispose

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

getTextWidget

public StyledText getTextWidget()
Returns viewer's text widget.
Specified by:
getTextWidget in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the SWT control

setAutoIndentStrategy

public void setAutoIndentStrategy(IAutoIndentStrategy strategy,
                                  String contentType)
Description copied from interface: ITextViewer
Sets this viewer's auto indent strategy for the given content type.
Specified by:
setAutoIndentStrategy in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
strategy - the new auto indent strategy. null is a valid argument.
contentType - the type for which the strategy is registered

prependAutoEditStrategy

public void prependAutoEditStrategy(IAutoEditStrategy strategy,
                                    String contentType)
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 interface ITextViewerExtension2
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension2
Parameters:
strategy - the auto edit strategy
contentType - the content type

removeAutoEditStrategy

public void removeAutoEditStrategy(IAutoEditStrategy strategy,
                                   String contentType)
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 interface ITextViewerExtension2
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension2
Parameters:
strategy - the auto edit strategy
contentType - the content type

setEventConsumer

public void setEventConsumer(IEventConsumer consumer)
Description copied from interface: ITextViewer
Registers an event consumer with this viewer.
Specified by:
setEventConsumer in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
consumer - the viewer's event consumer. null is a valid argument.

setIndentPrefixes

public void setIndentPrefixes(String[] indentPrefixes,
                              String contentType)
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
indentPrefixes - the prefixes to be used
contentType - 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the viewer's editable mode

setEditable

public void setEditable(boolean editable)
Description copied from interface: ITextViewer
Sets the editable mode.
Specified by:
setEditable in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
editable - the editable mode

setDefaultPrefixes

public void setDefaultPrefixes(String[] defaultPrefixes,
                               String contentType)
Description copied from interface: ITextViewer
Sets the string that is used as prefix when lines of the given content type are prefixed by the prefix text operation. 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
defaultPrefixes - the prefixes to be used
contentType - the content type for which the prefixes are specified

setUndoManager

public void setUndoManager(IUndoManager undoManager)
Description copied from interface: ITextViewer
Sets this viewer's undo manager.
Specified by:
setUndoManager in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
undoManager - the new undo manager. null is a valid argument.

setTextHover

public void setTextHover(ITextHover hover,
                         String contentType)
Description copied from interface: ITextViewer
Sets this viewer's text hover for the given content type.
Specified by:
setTextHover in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
textViewerHover - the new hover. null is a valid argument.
contentType - the type for which the hover is registered

setTextHover

public void setTextHover(ITextHover hover,
                         String contentType,
                         int stateMask)
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 hower is null, any hover installed for the given content type and state mask is uninstalled.
Specified by:
setTextHover in interface ITextViewerExtension2
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension2
Parameters:
textViewerHover - the new hover or null
contentType - the type for which the hover is to be registered or unregistered
stateMask - the SWT event state mask; DEFAULT_HOVER_STATE_MASK indicates that the hover is installed as the default hover.

removeTextHovers

public void removeTextHovers(String contentType)
Description copied from interface: ITextViewerExtension2
Removes all text hovers for the given content type.

Note: To remove a hover for a given content type and state mask use ITextViewerExtension2.setTextHover(ITextHover, String, int) with null as parameter for the text hover.

Specified by:
removeTextHovers in interface ITextViewerExtension2
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension2
Parameters:
contentType - the type for which all text hovers are to be unregistered

getTextHover

protected ITextHover getTextHover(int offset)
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

protected ITextHover getTextHover(int offset,
                                  int stateMask)
Returns the text hover for a given offset and a given state mask.
Parameters:
offset - the offset for which to return the text hover
stateMask - the SWT event state mask
Returns:
the text hover for the given offset and state mask
Since:
2.1

getTextHoveringController

protected AbstractInformationControlManager getTextHoveringController()
Returns the text hovering controller of this viewer.
Returns:
the text hovering controller of this viewer
Since:
2.0

setHoverControlCreator

public void setHoverControlCreator(IInformationControlCreator creator)
Sets the creator for the hover controls.
Parameters:
creator - the hover control creator
Since:
2.0

requestWidgetToken

public boolean requestWidgetToken(IWidgetTokenKeeper requester)
Description copied from interface: IWidgetTokenOwner
Requests the widget token from this token owner. Returns true if the token has been aquired or is already owned by the requester. This method is non-blocking.
Specified by:
requestWidgetToken in interface IWidgetTokenOwner
Following copied from interface: org.eclipse.jface.text.IWidgetTokenOwner
Parameters:
requester - the token requester
Returns:
true if requester aquires the token, false otherwise

releaseWidgetToken

public void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper)
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 interface IWidgetTokenOwner
Following copied from interface: org.eclipse.jface.text.IWidgetTokenOwner
Parameters:
tokenKeeper - the token keeper

getSelectedRange

public Point getSelectedRange()
Description copied from interface: ITextViewer
Returns the range of the current selection in coordinates of this viewer's document.
Specified by:
getSelectedRange in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
offset - the offset of the selection range
length - the length of the selection range

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

public void setSelection(ISelection selection,
                         boolean reveal)
Description copied from class: Viewer
Sets a new selection for this viewer and optionally makes it visible.

Subclasses must implement this method.

Overrides:
setSelection in class Viewer
Following copied from class: org.eclipse.jface.viewers.Viewer
Parameters:
selection - the new selection
reveal - true if the selection is to be made visible, and false otherwise

getSelection

public ISelection getSelection()
Description copied from interface: ISelectionProvider
Returns the current selection for this provider.
Overrides:
getSelection in class Viewer
Following copied from interface: org.eclipse.jface.viewers.ISelectionProvider
Returns:
the current selection

getSelectionProvider

public ISelectionProvider 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
this viewer's selection provider

selectionChanged

protected void selectionChanged(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 document
length - the length of the newly selected range in the visible document

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 cleared
length - the length of the mark selection, may be negative if the caret is before the mark.
Since:
2.0

addTextListener

public void addTextListener(ITextListener listener)
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be added

removeTextListener

public void removeTextListener(ITextListener listener)
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be removed

updateTextListeners

protected void updateTextListeners(TextViewer.WidgetCommand cmd)
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

public void addTextInputListener(ITextInputListener listener)
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be added

removeTextInputListener

public void removeTextInputListener(ITextInputListener listener)
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be removed

fireInputDocumentAboutToBeChanged

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.
Parameters:
oldInput - the old input document
newInput - the new input document

fireInputDocumentChanged

protected void fireInputDocumentChanged(IDocument oldInput,
                                        IDocument newInput)
Informs all registered text input listeners about the sucessful input change, This method does not use a robust iterator.
Parameters:
oldInput - the old input document
newInput - the new input document

getInput

public Object getInput()
Description copied from interface: IInputProvider
Returns the input.
Overrides:
getInput in class Viewer
Following copied from interface: org.eclipse.jface.viewers.IInputProvider
Returns:
the input object

getDocument

public IDocument getDocument()
Description copied from interface: ITextViewer
Returns the text viewer's input document.
Specified by:
getDocument in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the viewer's input document

setInput

public void setInput(Object input)
Description copied from class: Viewer
Sets or clears the input for this viewer.
Overrides:
setInput in class Viewer
Following copied from class: org.eclipse.jface.viewers.Viewer
Parameters:
input - the input of this viewer, or null if none

setDocument

public void setDocument(IDocument document)
Description copied from interface: ITextViewer
Sets the given document as the text viewer's model and updates the presentation accordingly. An approriate TextEvent is issued. This text event does not carry a related document event.
Specified by:
setDocument in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
document - the viewer's new input document

setDocument

public void setDocument(IDocument document,
                        int visibleRegionOffset,
                        int visibleRegionLength)
Description copied from interface: ITextViewer
Sets the given document as this viewer's model and makes the specified region visible in the presentation. An approriate TextEvent is issued. The text event does not carry a related document event. This method is a convenience method for setDocument(document);setVisibleRegion(offset, length).
Specified by:
setDocument in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
document - the new input document
visibleRegionOffset - the offset of the visible region
visibleRegionLength - the length of the visible region

createSlaveDocument

protected IDocument createSlaveDocument(IDocument document)
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

protected boolean updateVisibleDocument(IDocument visibleDocument,
                                        int visibleRegionOffset,
                                        int visibleRegionLength)
                                 throws BadLocationException
Sets the given slave document to the specified range of its master document.
Parameters:
visibleDocument - the slave document
visibleRegionOffset - the offset of the master document range
visibleRegionLength - 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

addViewportListener

public void addViewportListener(IViewportListener listener)
Description copied from interface: ITextViewer
Adds the given viewport listener to this viewer. The listener is informed about all changes to the visible area of this viewer. If the listener is already registered with this viewer, this call has no effect.
Specified by:
addViewportListener in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be added

removeViewportListener

public void removeViewportListener(IViewportListener listener)
Description copied from interface: ITextViewer
Removes the given listener from this viewer's set of viewport listeners. If the listener is not registered with this viewer, this call has no effect.
Specified by:
removeViewportListener in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
listener - the listener to be removed

updateViewportListeners

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

getTopIndex

public int getTopIndex()
Description copied from interface: ITextViewer
Returns the visible line with the smallest line number.
Specified by:
getTopIndex in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the number of the top most visible line

setTopIndex

public void setTopIndex(int index)
Description copied from interface: ITextViewer
Scrolls the widget so the the given index is the line with the smallest line number of all visible lines.
Specified by:
setTopIndex in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
index - the line which should become the top most line

getVisibleLinesInViewport

protected int getVisibleLinesInViewport()
Returns the viewport height in lines. The actual visible lines can be fewer if the document is shorter than the viewport.
Returns:
the viewport 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
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 viewport.
Specified by:
getTopIndexStartOffset in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
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 viewport. 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
offset - the offset of the range to be revealed
length - 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 range
end - the end offset of the range

getWidthInPixels

protected final int getWidthInPixels(String text)
Deprecated. use getWidthInPixels(int, int) instead

Returns the width of the text when being drawed into this viewer's widget.
Parameters:
the - string to messure
Returns:
the width of the presentation of the given string

getExtent

protected final IRegion getExtent(int start,
                                  int end)
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 viewport 0 <= offset <= getCharCount()
end - offset relative to the start of this viewer's viewport 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 region
length - 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.
Overrides:
refresh in class Viewer

getSlaveDocumentManager

protected ISlaveDocumentManager getSlaveDocumentManager()
Returns the slave document manager
Returns:
the slave document manager
Since:
2.1

createSlaveDocumentManager

protected ISlaveDocumentManager createSlaveDocumentManager()
Creates a new slave document manager. This implementation always returns a ChildDocumentManager.
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.
Specified by:
invalidateTextPresentation in interface ITextViewer

invalidateTextPresentation

public final void invalidateTextPresentation(int offset,
                                             int length)
Invalidates the given range of the text presentation.
Specified by:
invalidateTextPresentation in interface ITextViewerExtension2
Parameters:
offset - the offset of the range to be invalidated
length - the length of the range to be invalidated
Since:
2.1

setVisibleDocument

protected void setVisibleDocument(IDocument document)
Sets this viewer's visible document. The visible document represents the visible region of the viewer's input document.
Parameters:
document - the visible document

initializeDocumentInformationMapping

protected void initializeDocumentInformationMapping(IDocument visibleDocument)
Initializes the document information mapping between the given slave document and its master document.
Parameters:
visibleDocument - the slave document
Since:
2.1

getVisibleDocument

protected IDocument 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

public IRegion getVisibleRegion()
Description copied from interface: ITextViewer
Returns the current visible region of this viewer's document. The result may differ from the argument passed to setVisibleRegion if the document has been modified since then.
Specified by:
getVisibleRegion in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
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.
Specified by:
overlapsWithVisibleRegion in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
true if the specified range overlaps with the visible region

setVisibleRegion

public void setVisibleRegion(int start,
                             int length)
Description copied from interface: ITextViewer
Sets the region of this viewer's document which will be visible in the presentation.
Specified by:
setVisibleRegion in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
offset - the offset of the visible region
length - 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 document is presented again.
Specified by:
resetVisibleRegion in interface ITextViewer

setTextDoubleClickStrategy

public void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy,
                                       String contentType)
Description copied from interface: ITextViewer
Sets this viewer's text double click strategy for the given content type.
Specified by:
setTextDoubleClickStrategy in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
strategy - the new double click strategy. null is a valid argument.
contentType - the type for which the strategy is registered

selectContentTypePlugin

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

customizeDocumentCommand

protected void customizeDocumentCommand(DocumentCommand command)
Hook called on receipt of a VerifyEvent. The event has been translated into a DocumentCommand which can now be manipulated by interested parties. By default, the hook forwards the command to the installed instances of IAutoEditStrategy.
Parameters:
command - the document command representing the verify event

handleVerifyEvent

protected void handleVerifyEvent(VerifyEvent e)
See Also:
VerifyListener.verifyText(VerifyEvent)

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 interface ITextOperationTarget
Following copied from interface: org.eclipse.jface.text.ITextOperationTarget
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 if canDoOperation returns true.
Specified by:
doOperation in interface ITextOperationTarget
Following copied from interface: org.eclipse.jface.text.ITextOperationTarget
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 interface ITextOperationTargetExtension
Following copied from interface: org.eclipse.jface.text.ITextOperationTargetExtension
Parameters:
operation - the operation to enable/disable
enable - true to enable the operation otherwise false

deleteText

protected void deleteText()
Deprecated. use StyledText.invokeAction instead

Deletes 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()
Returns true 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

protected void shift(boolean useDefaultPrefixes,
                     boolean right)
Deprecated. use shift(boolean, boolean, boolean) instead

Shifts a text block to the right or left using the specified set of prefix characters. The prefixes must start at the beginnig of the line.
Parameters:
useDefaultPrefixes - says whether the configured default or indent prefixes should be used
right - 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 used
right - says whether to shift to the right or the left
ignoreWhitespace - says whether whitepsace 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

protected void print()
Brings up a print dialog and calls printContents(Printer) which performs the actual print.

canPerformFind

protected boolean canPerformFind()
See Also:
IFindReplaceTarget.canPerformFind()

findAndSelect

protected int findAndSelect(int startPosition,
                            String findString,
                            boolean forwardSearch,
                            boolean caseSensitive,
                            boolean wholeWord)
See Also:
IFindReplaceTarget.findAndSelect(int, String, boolean, boolean, boolean)

setTextColor

public void setTextColor(Color color)
Description copied from interface: ITextViewer
Applies the given color to this viewer's selection.
Specified by:
setTextColor in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
color - the color to be applied

setTextColor

public void setTextColor(Color color,
                         int start,
                         int length,
                         boolean controlRedraw)
Description copied from interface: ITextViewer
Applies the given 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 interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
color - the color to be applied
offset - the offset of the range to be colored
length - the length of the range to be colored
controlRedraw - indicates whether this viewer should manage redraws

_internalGetVisibleRegion

protected IRegion _internalGetVisibleRegion()
Returns the visible region if it is not equal to the whole document. Otherwise returns null.
Returns:
the viewer's visible region if smaller than input document, otherwise null

changeTextPresentation

public void changeTextPresentation(TextPresentation presentation,
                                   boolean controlRedraw)
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 coloring calls, it is more appropriate to explicitly control redrawing at the beginning and the end of the sequence.
Specified by:
changeTextPresentation in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Parameters:
presentation - the presentation to be applied to this viewer
controlRedraw - indicates whether this viewer should manage redraws

getFindReplaceTarget

public IFindReplaceTarget getFindReplaceTarget()
Description copied from interface: ITextViewer
Returns the find/replace operation target of this viewer.
Specified by:
getFindReplaceTarget in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the find/replace operation target of this viewer

getTextOperationTarget

public ITextOperationTarget getTextOperationTarget()
Description copied from interface: ITextViewer
Returns the text operation target of this viewer.
Specified by:
getTextOperationTarget in interface ITextViewer
Following copied from interface: org.eclipse.jface.text.ITextViewer
Returns:
the text operation target of this viewer

appendVerifyKeyListener

public void appendVerifyKeyListener(VerifyKeyListener listener)
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 interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Parameters:
listener - the listener to be added

prependVerifyKeyListener

public void prependVerifyKeyListener(VerifyKeyListener listener)
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 beginnng of the list.
Specified by:
prependVerifyKeyListener in interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Parameters:
listener - the listener to be inserted

removeVerifyKeyListener

public void removeVerifyKeyListener(VerifyKeyListener listener)
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 interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Parameters:
listener - the listener to be removed

getMark

public int getMark()
Description copied from interface: ITextViewerExtension
Returns the mark position, -1 if mark is not set.
Specified by:
getMark in interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Returns:
the mark position or -1 if no mark is set

setMark

public void setMark(int offset)
Description copied from interface: ITextViewerExtension
Sets or clears the mark. If offset is -1, the mark is cleared. If a mark is set and the selection is empty, cut and copy actions performed on this text viewer peform on the region limited by the positions of the mark and the cursor.
Specified by:
setMark in interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Parameters:
offset - the offset of the mark

inputChanged

protected void inputChanged(Object newInput,
                            Object oldInput)
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 class Viewer
Following copied from class: org.eclipse.jface.viewers.Viewer
Parameters:
input - the new input of this viewer, or null if none
oldInput - the old input element or null if there was previously no input

enabledRedrawing

protected void enabledRedrawing()
Enables the redrawing of this text viewer.
Since:
2.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 underlying StyledText widget. While being disconnected only the viewer's selection may be changed using setSelectedRange. 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.
Specified by:
setRedraw in interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Parameters:
redraw - true to enable redrawing, false otherwise

redraws

protected final boolean redraws()
Returns whether this viewer redraws itself.
Returns:
true if this viewer redraws itself
Since:
2.0

startSequentialRewriteMode

protected final void startSequentialRewriteMode(boolean normalized)
Starts 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

protected final void stopSequentialRewriteMode()
Sets the sequential rewrite mode of the viewer's document.
Since:
2.0

getRewriteTarget

public IRewriteTarget getRewriteTarget()
Description copied from interface: ITextViewerExtension
Returns the viewer's rewrite target.
Specified by:
getRewriteTarget in interface ITextViewerExtension
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension
Returns:
the viewer's rewrite target

getCurrentTextHover

public ITextHover getCurrentTextHover()
Description copied from interface: ITextViewerExtension2
Returns the currently displayed text hover if any, null otherwise.
Specified by:
getCurrentTextHover in interface ITextViewerExtension2

getHoverEventLocation

public Point getHoverEventLocation()
Description copied from interface: ITextViewerExtension2
Returns the location at which the most recent mouse hover event has been issued.
Specified by:
getHoverEventLocation in interface ITextViewerExtension2
Following copied from interface: org.eclipse.jface.text.ITextViewerExtension2
Returns:
the location of the most recent mouse hover event

getPaintManager

protected PaintManager getPaintManager()
Returns the paint manager of this viewer.
Returns:
the paint manager of this viewer
Since:
2.1

addPainter

public void addPainter(IPainter painter)
Adds the given painter to this viewer. If the painter is already registered this method is without effect.
Specified by:
addPainter in interface ITextViewerExtension2
Parameters:
painter - the painter to be added
Since:
2.1

removePainter

public void removePainter(IPainter painter)
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 interface ITextViewerExtension2
Parameters:
painter - the painter to be removed
Since:
2.1

modelLine2WidgetLine

public int modelLine2WidgetLine(int modelLine)

modelOffset2WidgetOffset

public int modelOffset2WidgetOffset(int modelOffset)

modelRange2WidgetRange

public IRegion modelRange2WidgetRange(IRegion modelRange)

widgetlLine2ModelLine

public int widgetlLine2ModelLine(int widgetLine)

widgetOffset2ModelOffset

public int widgetOffset2ModelOffset(int widgetOffset)

widgetRange2ModelRange

public IRegion widgetRange2ModelRange(IRegion widgetRange)

getModelCoverage

public IRegion getModelCoverage()

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.
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
Since:
2.1

modelStyleRange2WidgetStyleRange

protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range)
Translates a style range given relative to the viewer's document into style ranges relative to the viewer's widget.
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
Since:
2.1

modelRange2WidgetRange

protected IRegion modelRange2WidgetRange(Position modelPosition)
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
See Also:
modelRange2WidgetRange(IRegion)

event2ModelRange

protected IRegion event2ModelRange(VerifyEvent event)
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

protected Point widgetSelection2ModelSelection(Point widgetSelection)
Translates the given widget selection into the corresponding region of the viewer's document.
Parameters:
widgetSelection - the widget selection
Returns:
the region of the viewer's document corresponding to the widget selection
Since:
2.1

modelSelection2WidgetSelection

protected Point modelSelection2WidgetSelection(Point modelSelection)
Translates the given selection range of the viewer's document into the corresponding widget range.
Parameters:
modelSelection - the selection range of the viewer's document
Returns:
the widget range corresponding to the selection range
Since:
2.1

widgetLineOfWidgetOffset

public int widgetLineOfWidgetOffset(int widgetOffset)

Eclipse Platform
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.