Interface ISourceViewer

  • All Superinterfaces:
    ITextViewer
    All Known Implementing Classes:
    ProjectionViewer, SourceViewer, TextConsoleViewer

    public interface ISourceViewer
    extends ITextViewer
    In addition to the text viewer functionality a source viewer supports:
    • visual annotations based on an annotation model
    • visual range indication
    • management of text viewer add-ons
    • explicit configuration
    It is assumed that range indication and visual annotations are shown inside the same presentation area. There are no assumptions about whether this area is different from the viewer's text widget.

    As the visibility of visual annotations can dynamically be changed, it is assumed that the annotation presentation area can dynamically be hidden if it is different from the text widget.

    In order to provide backward compatibility for clients of ISourceViewer, extension interfaces are used as a means of evolution. The following extension interfaces exist:

    • ISourceViewerExtension since version 2.1 introducing the concept of an annotation overview.
    • ISourceViewerExtension2 since version 3.0 allowing source viewers to roll back a previously performed configuration and allows access to the viewer's visual annotation model.
    • ISourceViewerExtension3 since version 3.2 introducing the concept of a quick assist assistant and providing access to the quick assist invocation context as well as the current annotation hover.
    • ISourceViewerExtension4 since version 3.4 introducing API to access a minimal set of content assistant APIs.
    • ISourceViewerExtension5 since version 3.13 introducing API to access minimal set of code mining APIs.

    Clients may implement this interface and its extension interfaces or use the default implementation provided by SourceViewer.

    See Also:
    ISourceViewerExtension, ISourceViewerExtension2, ISourceViewerExtension3, ISourceViewerExtension4
    • Field Detail

      • CONTENTASSIST_PROPOSALS

        static final int CONTENTASSIST_PROPOSALS
        Text operation code for requesting content assist to show completion proposals for the current insert position.
        See Also:
        Constant Field Values
      • CONTENTASSIST_CONTEXT_INFORMATION

        static final int CONTENTASSIST_CONTEXT_INFORMATION
        Text operation code for requesting content assist to show the content information for the current insert position.
        See Also:
        Constant Field Values
      • FORMAT

        static final int FORMAT
        Text operation code for formatting the selected text or complete document of this viewer if the selection is empty.
        See Also:
        Constant Field Values
      • INFORMATION

        static final int INFORMATION
        Text operation code for requesting information at the current insertion position.
        Since:
        2.0
        See Also:
        Constant Field Values
      • QUICK_ASSIST

        static final int QUICK_ASSIST
        Text operation code for requesting quick assist. This will normally show quick assist and quick fix proposals for the current position.
        Since:
        3.2
        See Also:
        Constant Field Values
    • Method Detail

      • configure

        void configure​(SourceViewerConfiguration configuration)
        Configures the source viewer using the given configuration. Prior to 3.0 this method can only be called once. Since 3.0 this method can be called again after a call to ISourceViewerExtension2.unconfigure().
        Parameters:
        configuration - the source viewer configuration to be used
      • setAnnotationHover

        void setAnnotationHover​(IAnnotationHover annotationHover)
        Sets the annotation hover of this source viewer. The annotation hover provides the information to be displayed in a hover popup window if requested over the annotation presentation area. The annotation hover is assumed to be line oriented.
        Parameters:
        annotationHover - the hover to be used, null is a valid argument
      • setDocument

        void setDocument​(IDocument document,
                         IAnnotationModel annotationModel)
        Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations. The presentation is accordingly updated. An appropriate TextEvent is issued. This text event does not carry a related document event.
        Parameters:
        document - the viewer's new input document
        annotationModel - the model for the viewer's visual annotations
        See Also:
        ITextViewer.setDocument(IDocument)
      • setDocument

        void setDocument​(IDocument document,
                         IAnnotationModel annotationModel,
                         int modelRangeOffset,
                         int modelRangeLength)
        Sets the given document as this viewer's text model and the given annotation model as the model for this viewer's visual annotations. The presentation is accordingly updated whereby only the specified region is exposed. An appropriate TextEvent is issued. The text event does not carry a related document event. This method is a convenience method for setDocument(document, annotationModel);setVisibleRegion(offset, length).
        Parameters:
        document - the new input document
        annotationModel - the model of the viewer's visual annotations
        modelRangeOffset - the offset of the model range
        modelRangeLength - the length of the model range
        See Also:
        ITextViewer.setDocument(IDocument, int, int)
      • setRangeIndicator

        void setRangeIndicator​(Annotation rangeIndicator)
        Sets the annotation used by this viewer as range indicator. The range covered by this annotation is referred to as range indication.
        Parameters:
        rangeIndicator - the annotation to be used as this viewer's range indicator
      • setRangeIndication

        void setRangeIndication​(int offset,
                                int length,
                                boolean moveCursor)
        Sets the viewers's range indication to the specified range. It is indicated whether the cursor should also be moved to the beginning of the specified range.
        Parameters:
        offset - the offset of the range
        length - the length of the range
        moveCursor - indicates whether the cursor should be moved to the given offset
      • getRangeIndication

        IRegion getRangeIndication()
        Returns the viewer's range indication.
        Returns:
        the viewer's range indication.
      • removeRangeIndication

        void removeRangeIndication()
        Removes the viewer's range indication. There is no visible range indication after this method completed.
      • showAnnotations

        void showAnnotations​(boolean show)
        Controls the visibility of annotations and in the case of separate presentation areas of text and annotations, the visibility of the annotation's presentation area.

        By default, annotations and their presentation area are visible.

        Parameters:
        show - indicates the visibility of annotations