KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > source > ISourceViewer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jface.text.source;
13
14
15 import org.eclipse.jface.text.IDocument;
16 import org.eclipse.jface.text.IRegion;
17 import org.eclipse.jface.text.ITextOperationTarget;
18 import org.eclipse.jface.text.ITextViewer;
19
20
21 /**
22  * In addition to the text viewer functionality a source viewer supports:
23  * <ul>
24  * <li>visual annotations based on an annotation model
25  * <li>visual range indication
26  * <li>management of text viewer add-ons
27  * <li>explicit configuration
28  * </ul>
29  * It is assumed that range indication and visual annotations are shown inside
30  * the same presentation area. There are no assumptions about whether this area
31  * is different from the viewer's text widget.
32  * <p>
33  * As the visibility of visual annotations can dynamically be changed, it is
34  * assumed that the annotation presentation area can dynamically be hidden if it
35  * is different from the text widget.
36  * <p>
37  * In order to provide backward compatibility for clients of
38  * <code>ISourceViewer</code>, extension interfaces are used as a means of
39  * evolution. The following extension interfaces exist:
40  * <ul>
41  * <li>{@link org.eclipse.jface.text.source.ISourceViewerExtension} since version 2.1
42  * introducing the concept of an annotation overview.</li>
43  * <li>{@link org.eclipse.jface.text.source.ISourceViewerExtension2} since version 3.0
44  * allowing source viewers to roll back a previously performed configuration and
45  * allows access to the viewer's visual annotation model.</li>
46  * <li>{@link org.eclipse.jface.text.source.ISourceViewerExtension3} since version 3.2
47  * introducing the concept of a quick assist assistant and providing access
48  * to the quick assist invocation context as well as the current annotation hover.</li>
49  * </ul></p>
50  * <p>
51  * Clients may implement this interface and its extension interfaces or use the
52  * default implementation provided by
53  * {@link org.eclipse.jface.text.source.SourceViewer}.</p>
54  *
55  * @see org.eclipse.jface.text.source.ISourceViewerExtension
56  * @see org.eclipse.jface.text.source.ISourceViewerExtension2
57  * @see org.eclipse.jface.text.source.ISourceViewerExtension3
58  */

59 public interface ISourceViewer extends ITextViewer {
60
61     /**
62      * Text operation code for requesting content assist to show completion
63      * proposals for the current insert position.
64      */

65     int CONTENTASSIST_PROPOSALS= ITextOperationTarget.STRIP_PREFIX + 1;
66
67     /**
68      * Text operation code for requesting content assist to show
69      * the content information for the current insert position.
70      */

71     int CONTENTASSIST_CONTEXT_INFORMATION= ITextOperationTarget.STRIP_PREFIX + 2;
72
73     /**
74      * Text operation code for formatting the selected text or complete document
75      * of this viewer if the selection is empty.
76      */

77     int FORMAT= ITextOperationTarget.STRIP_PREFIX + 3;
78
79     /**
80      * Text operation code for requesting information at the current insertion position.
81      * @since 2.0
82      */

83     int INFORMATION= ITextOperationTarget.STRIP_PREFIX + 4;
84
85     /*
86      * XXX: Cannot continue numbering due to operation codes used in ProjectionViewer
87      */

88
89     /**
90      * Text operation code for requesting quick assist. This will normally
91      * show quick assist and quick fix proposals for the current position.
92      * @since 3.2
93      */

94     int QUICK_ASSIST= ITextOperationTarget.STRIP_PREFIX + 10;
95
96     /**
97      * Configures the source viewer using the given configuration. Prior to 3.0 this
98      * method can only be called once. Since 3.0 this method can be called again
99      * after a call to {@link ISourceViewerExtension2#unconfigure()}.
100      *
101      * @param configuration the source viewer configuration to be used
102      */

103     void configure(SourceViewerConfiguration configuration);
104
105     /**
106      * Sets the annotation hover of this source viewer. The annotation hover
107      * provides the information to be displayed in a hover popup window
108      * if requested over the annotation presentation area. The annotation
109      * hover is assumed to be line oriented.
110      *
111      * @param annotationHover the hover to be used, <code>null</code> is a valid argument
112      */

113     void setAnnotationHover(IAnnotationHover annotationHover);
114
115     /**
116      * Sets the given document as this viewer's text model and the
117      * given annotation model as the model for this viewer's visual
118      * annotations. The presentation is accordingly updated. An appropriate
119      * <code>TextEvent</code> is issued. This text event does not carry
120      * a related document event.
121      *
122      * @param document the viewer's new input document
123      * @param annotationModel the model for the viewer's visual annotations
124      *
125      * @see ITextViewer#setDocument(IDocument)
126      */

127     void setDocument(IDocument document, IAnnotationModel annotationModel);
128
129     /**
130      * Sets the given document as this viewer's text model and the
131      * given annotation model as the model for this viewer's visual
132      * annotations. The presentation is accordingly updated whereby
133      * only the specified region is exposed. An appropriate
134      * <code>TextEvent</code> is issued. The text event does not carry a
135      * related document event. This method is a convenience method for
136      * <code>setDocument(document, annotationModel);setVisibleRegion(offset, length)</code>.
137      *
138      * @param document the new input document
139      * @param annotationModel the model of the viewer's visual annotations
140      * @param modelRangeOffset the offset of the model range
141      * @param modelRangeLength the length of the model range
142      *
143      * @see ITextViewer#setDocument(IDocument, int, int)
144      */

145     void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength);
146
147     /**
148      * Returns this viewer's annotation model. Use
149      * {@link ISourceViewerExtension2#getVisualAnnotationModel()}in order to
150      * get access to the viewer's visual annotation model.
151      *
152      * @return this viewer's annotation model
153      */

154     IAnnotationModel getAnnotationModel();
155
156     /**
157      * Sets the annotation used by this viewer as range indicator. The
158      * range covered by this annotation is referred to as range indication.
159      *
160      * @param rangeIndicator the annotation to be used as this viewer's range indicator
161      */

162     void setRangeIndicator(Annotation rangeIndicator);
163
164     /**
165      * Sets the viewers's range indication to the specified range. Its is indicated
166      * whether the cursor should also be moved to the beginning of the specified range.
167      *
168      * @param offset the offset of the range
169      * @param length the length of the range
170      * @param moveCursor indicates whether the cursor should be moved to the given offset
171      */

172     void setRangeIndication(int offset, int length, boolean moveCursor);
173
174     /**
175      * Returns the viewer's range indication.
176      *
177      * @return the viewer's range indication.
178      */

179     IRegion getRangeIndication();
180
181     /**
182      * Removes the viewer's range indication. There is no visible range indication
183      * after this method completed.
184      */

185     void removeRangeIndication();
186
187     /**
188      * Controls the visibility of annotations and in the case of separate
189      * presentation areas of text and annotations, the visibility of the
190      * annotation's presentation area.<p>
191      * By default, annotations and their presentation area are visible.
192      *
193      * @param show indicates the visibility of annotations
194      */

195     void showAnnotations(boolean show);
196 }
197
Popular Tags