|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A text viewer connects a text widget with an IDocument. The document is used as the widget's text model.
It supports the following kinds of listeners:
A text viewer supports a set of configuration options and plug-ins defining its behavior:
Installed plug-ins are not automatically activated. Plug-ins must be activated with the activatePlugins call. Most plug-ins can be defined per content type. Content types are derived from a partitioning of the text viewer's input document. In case of documents that support multiple partitionings, the implementer is responsible for determining the partitioning to use.
A text viewer also provides the concept of event consumption. Events handled by the viewer can be filtered and processed by a dynamic event consumer. With ITextViewerExtensionthis mechanism has been replaced with the support for VerifyKeyListener.
A text viewer provides several text editing functions, some of them are configurable, through a text operation target interface. It also supports a presentation mode in which it only shows a specified section of its document. By calling setVisibleRegion clients define which section is visible. Clients can get access to this section by calling getVisibleRegion. The viewer's presentation mode does not affect any client of the viewer other than text listeners. With ITextViewerExtension5the visible region support has been reworked. With that extension interface, text viewers are allowed to show fractions of their input document. I.e. a widget selection of two visually neighboring characters is no longer guaranteed to be two neighboring characters in the viewer's input document. Thus, viewers implementing ITextViewerExtension5are potentially forced to change the fractions of the input document that are shown when clients ask for the visible region.
In order to provide backward compatibility for clients of ITextViewer, extension interfaces are used as a means of evolution. The following extension interfaces exist:
Clients may implement this interface and its extension interfaces or use the standard implementation TextViewer.
Method Summary | |
void | activatePlugins()
Activates the installed plug-ins. |
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 view port listener to this viewer. |
void | changeTextPresentation(TextPresentation presentation,
boolean controlRedraw)
Applies the color information encoded in the given text presentation. |
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 view port. |
IDocument | getDocument()
Returns the text viewer's input document. |
IFindReplaceTarget | getFindReplaceTarget()
Returns the find/replace operation target of this viewer. |
Point | getSelectedRange()
Returns the range of the current selection in coordinates of this viewer's document. |
ISelectionProvider | getSelectionProvider()
Returns a selection provider dedicated to this viewer. |
ITextOperationTarget | getTextOperationTarget()
Returns the text operation target of this viewer. |
StyledText | getTextWidget()
Returns this viewer's SWT control, null if the control is disposed. |
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 view port. |
int | getTopInset()
Returns the vertical offset of the first visible line. |
IRegion | getVisibleRegion()
Returns the current visible region of this viewer's document. |
void | invalidateTextPresentation()
Marks the currently applied text presentation as invalid. |
boolean | isEditable()
Returns whether the shown text can be manipulated. |
boolean | overlapsWithVisibleRegion(int offset,
int length)
Returns whether a given range overlaps with the visible region of this viewer's document. |
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 | removeViewportListener(IViewportListener listener)
Removes the given listener from this viewer's set of view port listeners. |
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 offset,
int length)
Ensures that the given range is visible. |
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 modelRangeOffset,
int modelRangeLength)
Sets the given document as this viewer's model and exposes the specified region. |
void | setEditable(boolean editable)
Sets the editable state. |
void | setEventConsumer(IEventConsumer consumer)
Registers an event consumer with this viewer. |
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 | setSelectedRange(int offset,
int length)
Sets the selection to the specified range. |
void | setTextColor(Color color)
Applies the given color as text foreground color to this viewer's selection. |
void | setTextColor(Color color,
int offset,
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 textViewerHover,
String contentType)
Sets this viewer's text hover for the given content type. |
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. |
void | setVisibleRegion(int offset,
int length)
Defines and sets the region of this viewer's document which will be visible in the presentation. |
Method Detail |
public StyledText getTextWidget()
public void setUndoManager(IUndoManager undoManager)
public void setTextDoubleClickStrategy(ITextDoubleClickStrategy strategy, String contentType)
public void setAutoIndentStrategy(IAutoIndentStrategy strategy, String contentType)
ITextViewerExtension2 extension= (ITextViewerExtension2) viewer; extension.removeAutoEditStrategy(oldStrategy, contentType); extension.prependAutoEditStrategy(strategy, contentType);
public void setTextHover(ITextHover textViewerHover, String contentType)
This method has been replaced by ITextViewerExtension2.setTextHover(ITextHover, String, int). It is now equivalent to
ITextViewerExtension2 extension= (ITextViewerExtension2) document; extension.setTextHover(textViewerHover, contentType, ITextViewerExtension2#DEFAULT_HOVER_STATE_MASK);
public void activatePlugins()
public void resetPlugins()
public void addViewportListener(IViewportListener listener)
public void removeViewportListener(IViewportListener listener)
public void addTextListener(ITextListener listener)
public void removeTextListener(ITextListener listener)
public void addTextInputListener(ITextInputListener listener)
public void removeTextInputListener(ITextInputListener listener)
public void setDocument(IDocument document)
public IDocument getDocument()
public void setEventConsumer(IEventConsumer consumer)
public void setEditable(boolean editable)
public boolean isEditable()
public void setDocument(IDocument document, int modelRangeOffset, int modelRangeLength)
public void setVisibleRegion(int offset, int length)
public void resetVisibleRegion()
public IRegion getVisibleRegion()
Viewers implementing ITextViewerExtension5 may be forced to change the fractions of the input document that are shown, in order to fulfill this contract.
public boolean overlapsWithVisibleRegion(int offset, int length)
Viewers implementing ITextViewerExtension5may 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.
public void changeTextPresentation(TextPresentation presentation, boolean controlRedraw)
public void invalidateTextPresentation()
See ITextViewerExtension2.invalidateTextPresentation(int, int) for a way to invalidate specific regions rather than the presentation as a whole.
public void setTextColor(Color color)
public void setTextColor(Color color, int offset, int length, boolean controlRedraw)
public ITextOperationTarget getTextOperationTarget()
public IFindReplaceTarget getFindReplaceTarget()
public void setDefaultPrefixes(String[] defaultPrefixes, String contentType)
public void setIndentPrefixes(String[] indentPrefixes, String contentType)
public void setSelectedRange(int offset, int length)
public Point getSelectedRange()
public ISelectionProvider getSelectionProvider()
public void revealRange(int offset, int length)
public void setTopIndex(int index)
public int getTopIndex()
public int getTopIndexStartOffset()
public int getBottomIndex()
public int getBottomIndexEndOffset()
public int getTopInset()
|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.