129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2007 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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.source.ISourceViewer;
|
|
14
|
168
|
15 import dwtx.jface.text.source.SourceViewerConfiguration;
|
|
16 import dwtx.jface.text.source.IAnnotationHover;
|
|
17 import dwtx.jface.text.source.IAnnotationModel;
|
|
18 import dwtx.jface.text.source.Annotation;
|
131
|
19
|
129
|
20 import dwt.dwthelper.utils;
|
|
21
|
|
22 import dwtx.jface.text.IDocument;
|
|
23 import dwtx.jface.text.IRegion;
|
|
24 import dwtx.jface.text.ITextOperationTarget;
|
|
25 import dwtx.jface.text.ITextViewer;
|
|
26
|
|
27
|
|
28 /**
|
|
29 * In addition to the text viewer functionality a source viewer supports:
|
|
30 * <ul>
|
|
31 * <li>visual annotations based on an annotation model
|
|
32 * <li>visual range indication
|
|
33 * <li>management of text viewer add-ons
|
|
34 * <li>explicit configuration
|
|
35 * </ul>
|
|
36 * It is assumed that range indication and visual annotations are shown inside
|
|
37 * the same presentation area. There are no assumptions about whether this area
|
|
38 * is different from the viewer's text widget.
|
|
39 * <p>
|
|
40 * As the visibility of visual annotations can dynamically be changed, it is
|
|
41 * assumed that the annotation presentation area can dynamically be hidden if it
|
|
42 * is different from the text widget.
|
|
43 * <p>
|
|
44 * In order to provide backward compatibility for clients of
|
|
45 * <code>ISourceViewer</code>, extension interfaces are used as a means of
|
|
46 * evolution. The following extension interfaces exist:
|
|
47 * <ul>
|
|
48 * <li>{@link dwtx.jface.text.source.ISourceViewerExtension} since version 2.1
|
|
49 * introducing the concept of an annotation overview.</li>
|
|
50 * <li>{@link dwtx.jface.text.source.ISourceViewerExtension2} since version 3.0
|
|
51 * allowing source viewers to roll back a previously performed configuration and
|
|
52 * allows access to the viewer's visual annotation model.</li>
|
|
53 * <li>{@link dwtx.jface.text.source.ISourceViewerExtension3} since version 3.2
|
|
54 * introducing the concept of a quick assist assistant and providing access
|
|
55 * to the quick assist invocation context as well as the current annotation hover.</li>
|
|
56 * <li>{@link dwtx.jface.text.source.ISourceViewerExtension4} since version 3.4
|
|
57 * introducing API to access a minimal set of content assistant APIs.</li>
|
|
58 * </ul></p>
|
|
59 * <p>
|
|
60 * Clients may implement this interface and its extension interfaces or use the
|
|
61 * default implementation provided by
|
|
62 * {@link dwtx.jface.text.source.SourceViewer}.</p>
|
|
63 *
|
|
64 * @see dwtx.jface.text.source.ISourceViewerExtension
|
|
65 * @see dwtx.jface.text.source.ISourceViewerExtension2
|
|
66 * @see dwtx.jface.text.source.ISourceViewerExtension3
|
|
67 * @see dwtx.jface.text.source.ISourceViewerExtension4
|
|
68 */
|
|
69 public interface ISourceViewer : ITextViewer {
|
|
70
|
|
71 /**
|
|
72 * Text operation code for requesting content assist to show completion
|
|
73 * proposals for the current insert position.
|
|
74 */
|
158
|
75 static const int CONTENTASSIST_PROPOSALS= ITextOperationTarget.STRIP_PREFIX + 1;
|
129
|
76
|
|
77 /**
|
|
78 * Text operation code for requesting content assist to show
|
|
79 * the content information for the current insert position.
|
|
80 */
|
158
|
81 static const int CONTENTASSIST_CONTEXT_INFORMATION= ITextOperationTarget.STRIP_PREFIX + 2;
|
129
|
82
|
|
83 /**
|
|
84 * Text operation code for formatting the selected text or complete document
|
|
85 * of this viewer if the selection is empty.
|
|
86 */
|
158
|
87 static const int FORMAT= ITextOperationTarget.STRIP_PREFIX + 3;
|
129
|
88
|
|
89 /**
|
|
90 * Text operation code for requesting information at the current insertion position.
|
|
91 * @since 2.0
|
|
92 */
|
162
|
93 static const int INFORMATION = ITextOperationTarget.STRIP_PREFIX + 4;
|
129
|
94
|
|
95 /*
|
|
96 * XXX: Cannot continue numbering due to operation codes used in ProjectionViewer
|
158
|
97 */
|
129
|
98
|
|
99 /**
|
|
100 * Text operation code for requesting quick assist. This will normally
|
|
101 * show quick assist and quick fix proposals for the current position.
|
|
102 * @since 3.2
|
|
103 */
|
158
|
104 static const int QUICK_ASSIST= ITextOperationTarget.STRIP_PREFIX + 10;
|
129
|
105
|
|
106 /**
|
|
107 * Configures the source viewer using the given configuration. Prior to 3.0 this
|
|
108 * method can only be called once. Since 3.0 this method can be called again
|
|
109 * after a call to {@link ISourceViewerExtension2#unconfigure()}.
|
|
110 *
|
|
111 * @param configuration the source viewer configuration to be used
|
|
112 */
|
|
113 void configure(SourceViewerConfiguration configuration);
|
|
114
|
|
115 /**
|
|
116 * Sets the annotation hover of this source viewer. The annotation hover
|
|
117 * provides the information to be displayed in a hover popup window
|
|
118 * if requested over the annotation presentation area. The annotation
|
|
119 * hover is assumed to be line oriented.
|
|
120 *
|
|
121 * @param annotationHover the hover to be used, <code>null</code> is a valid argument
|
|
122 */
|
|
123 void setAnnotationHover(IAnnotationHover annotationHover);
|
|
124
|
|
125 /**
|
|
126 * Sets the given document as this viewer's text model and the
|
|
127 * given annotation model as the model for this viewer's visual
|
|
128 * annotations. The presentation is accordingly updated. An appropriate
|
|
129 * <code>TextEvent</code> is issued. This text event does not carry
|
|
130 * a related document event.
|
|
131 *
|
|
132 * @param document the viewer's new input document
|
|
133 * @param annotationModel the model for the viewer's visual annotations
|
|
134 *
|
|
135 * @see ITextViewer#setDocument(IDocument)
|
|
136 */
|
|
137 void setDocument(IDocument document, IAnnotationModel annotationModel);
|
|
138
|
|
139 /**
|
|
140 * Sets the given document as this viewer's text model and the
|
|
141 * given annotation model as the model for this viewer's visual
|
|
142 * annotations. The presentation is accordingly updated whereby
|
|
143 * only the specified region is exposed. An appropriate
|
|
144 * <code>TextEvent</code> is issued. The text event does not carry a
|
|
145 * related document event. This method is a convenience method for
|
|
146 * <code>setDocument(document, annotationModel);setVisibleRegion(offset, length)</code>.
|
|
147 *
|
|
148 * @param document the new input document
|
|
149 * @param annotationModel the model of the viewer's visual annotations
|
|
150 * @param modelRangeOffset the offset of the model range
|
|
151 * @param modelRangeLength the length of the model range
|
|
152 *
|
|
153 * @see ITextViewer#setDocument(IDocument, int, int)
|
|
154 */
|
|
155 void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength);
|
|
156
|
|
157 /**
|
|
158 * Returns this viewer's annotation model. Use
|
|
159 * {@link ISourceViewerExtension2#getVisualAnnotationModel()}in order to
|
|
160 * get access to the viewer's visual annotation model.
|
|
161 *
|
|
162 * @return this viewer's annotation model
|
|
163 */
|
|
164 IAnnotationModel getAnnotationModel();
|
|
165
|
|
166 /**
|
|
167 * Sets the annotation used by this viewer as range indicator. The
|
|
168 * range covered by this annotation is referred to as range indication.
|
|
169 *
|
|
170 * @param rangeIndicator the annotation to be used as this viewer's range indicator
|
|
171 */
|
|
172 void setRangeIndicator(Annotation rangeIndicator);
|
|
173
|
|
174 /**
|
|
175 * Sets the viewers's range indication to the specified range. Its is indicated
|
|
176 * whether the cursor should also be moved to the beginning of the specified range.
|
|
177 *
|
|
178 * @param offset the offset of the range
|
|
179 * @param length the length of the range
|
|
180 * @param moveCursor indicates whether the cursor should be moved to the given offset
|
|
181 */
|
|
182 void setRangeIndication(int offset, int length, bool moveCursor);
|
|
183
|
|
184 /**
|
|
185 * Returns the viewer's range indication.
|
|
186 *
|
|
187 * @return the viewer's range indication.
|
|
188 */
|
|
189 IRegion getRangeIndication();
|
|
190
|
|
191 /**
|
|
192 * Removes the viewer's range indication. There is no visible range indication
|
|
193 * after this method completed.
|
|
194 */
|
|
195 void removeRangeIndication();
|
|
196
|
|
197 /**
|
|
198 * Controls the visibility of annotations and in the case of separate
|
|
199 * presentation areas of text and annotations, the visibility of the
|
|
200 * annotation's presentation area.<p>
|
|
201 * By default, annotations and their presentation area are visible.
|
|
202 *
|
|
203 * @param show indicates the visibility of annotations
|
|
204 */
|
|
205 void showAnnotations(bool show);
|
|
206 }
|