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