Mercurial > projects > dwt-addons
annotate dwtx/jface/text/source/SourceViewer.d @ 192:c3583c6ec027
Added missing default cases for switch statements
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 03 Nov 2008 22:52:26 +0100 |
parents | 1a5b8f8129df |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 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.SourceViewer; | |
14 | |
131 | 15 import dwtx.jface.text.source.ISharedTextColors; // packageimport |
16 import dwtx.jface.text.source.ILineRange; // packageimport | |
17 import dwtx.jface.text.source.IAnnotationPresentation; // packageimport | |
18 import dwtx.jface.text.source.IVerticalRulerInfoExtension; // packageimport | |
19 import dwtx.jface.text.source.ICharacterPairMatcher; // packageimport | |
20 import dwtx.jface.text.source.TextInvocationContext; // packageimport | |
21 import dwtx.jface.text.source.LineChangeHover; // packageimport | |
22 import dwtx.jface.text.source.IChangeRulerColumn; // packageimport | |
23 import dwtx.jface.text.source.IAnnotationMap; // packageimport | |
24 import dwtx.jface.text.source.IAnnotationModelListenerExtension; // packageimport | |
25 import dwtx.jface.text.source.ISourceViewerExtension2; // packageimport | |
26 import dwtx.jface.text.source.IAnnotationHover; // packageimport | |
27 import dwtx.jface.text.source.ContentAssistantFacade; // packageimport | |
28 import dwtx.jface.text.source.IAnnotationAccess; // packageimport | |
29 import dwtx.jface.text.source.IVerticalRulerExtension; // packageimport | |
30 import dwtx.jface.text.source.IVerticalRulerColumn; // packageimport | |
31 import dwtx.jface.text.source.LineNumberRulerColumn; // packageimport | |
32 import dwtx.jface.text.source.MatchingCharacterPainter; // packageimport | |
33 import dwtx.jface.text.source.IAnnotationModelExtension; // packageimport | |
34 import dwtx.jface.text.source.ILineDifferExtension; // packageimport | |
35 import dwtx.jface.text.source.DefaultCharacterPairMatcher; // packageimport | |
36 import dwtx.jface.text.source.LineNumberChangeRulerColumn; // packageimport | |
37 import dwtx.jface.text.source.IAnnotationAccessExtension; // packageimport | |
38 import dwtx.jface.text.source.ISourceViewer; // packageimport | |
39 import dwtx.jface.text.source.AnnotationModel; // packageimport | |
40 import dwtx.jface.text.source.ILineDifferExtension2; // packageimport | |
41 import dwtx.jface.text.source.IAnnotationModelListener; // packageimport | |
42 import dwtx.jface.text.source.IVerticalRuler; // packageimport | |
43 import dwtx.jface.text.source.DefaultAnnotationHover; // packageimport | |
44 import dwtx.jface.text.source.SourceViewerConfiguration; // packageimport | |
45 import dwtx.jface.text.source.AnnotationBarHoverManager; // packageimport | |
46 import dwtx.jface.text.source.CompositeRuler; // packageimport | |
47 import dwtx.jface.text.source.ImageUtilities; // packageimport | |
48 import dwtx.jface.text.source.VisualAnnotationModel; // packageimport | |
49 import dwtx.jface.text.source.IAnnotationModel; // packageimport | |
50 import dwtx.jface.text.source.ISourceViewerExtension3; // packageimport | |
51 import dwtx.jface.text.source.ILineDiffInfo; // packageimport | |
52 import dwtx.jface.text.source.VerticalRulerEvent; // packageimport | |
53 import dwtx.jface.text.source.ChangeRulerColumn; // packageimport | |
54 import dwtx.jface.text.source.ILineDiffer; // packageimport | |
55 import dwtx.jface.text.source.AnnotationModelEvent; // packageimport | |
56 import dwtx.jface.text.source.AnnotationColumn; // packageimport | |
57 import dwtx.jface.text.source.AnnotationRulerColumn; // packageimport | |
58 import dwtx.jface.text.source.IAnnotationHoverExtension; // packageimport | |
59 import dwtx.jface.text.source.AbstractRulerColumn; // packageimport | |
60 import dwtx.jface.text.source.ISourceViewerExtension; // packageimport | |
61 import dwtx.jface.text.source.AnnotationMap; // packageimport | |
62 import dwtx.jface.text.source.IVerticalRulerInfo; // packageimport | |
63 import dwtx.jface.text.source.IAnnotationModelExtension2; // packageimport | |
64 import dwtx.jface.text.source.LineRange; // packageimport | |
65 import dwtx.jface.text.source.IAnnotationAccessExtension2; // packageimport | |
66 import dwtx.jface.text.source.VerticalRuler; // packageimport | |
67 import dwtx.jface.text.source.JFaceTextMessages; // packageimport | |
68 import dwtx.jface.text.source.IOverviewRuler; // packageimport | |
69 import dwtx.jface.text.source.Annotation; // packageimport | |
70 import dwtx.jface.text.source.IVerticalRulerListener; // packageimport | |
71 import dwtx.jface.text.source.ISourceViewerExtension4; // packageimport | |
72 import dwtx.jface.text.source.AnnotationPainter; // packageimport | |
73 import dwtx.jface.text.source.IAnnotationHoverExtension2; // packageimport | |
74 import dwtx.jface.text.source.OverviewRuler; // packageimport | |
75 import dwtx.jface.text.source.OverviewRulerHoverManager; // packageimport | |
76 | |
77 | |
129 | 78 import dwt.dwthelper.utils; |
79 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
145
diff
changeset
|
80 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
145
diff
changeset
|
81 |
129 | 82 |
83 import dwt.DWT; | |
84 import dwt.graphics.Point; | |
85 import dwt.graphics.Rectangle; | |
86 import dwt.widgets.Canvas; | |
87 import dwt.widgets.Composite; | |
88 import dwt.widgets.Control; | |
89 import dwt.widgets.Layout; | |
90 import dwtx.jface.internal.text.NonDeletingPositionUpdater; | |
91 import dwtx.jface.internal.text.StickyHoverManager; | |
92 import dwtx.jface.text.AbstractHoverInformationControlManager; | |
93 import dwtx.jface.text.BadLocationException; | |
94 import dwtx.jface.text.BadPositionCategoryException; | |
95 import dwtx.jface.text.DocumentRewriteSession; | |
96 import dwtx.jface.text.DocumentRewriteSessionType; | |
97 import dwtx.jface.text.IDocument; | |
98 import dwtx.jface.text.IDocumentExtension4; | |
99 import dwtx.jface.text.IPositionUpdater; | |
100 import dwtx.jface.text.IRegion; | |
101 import dwtx.jface.text.IRewriteTarget; | |
102 import dwtx.jface.text.ISlaveDocumentManager; | |
103 import dwtx.jface.text.ISlaveDocumentManagerExtension; | |
104 import dwtx.jface.text.ITextViewerExtension2; | |
159 | 105 import dwtx.jface.text.ITextViewerExtension8; |
129 | 106 import dwtx.jface.text.Position; |
107 import dwtx.jface.text.Region; | |
108 import dwtx.jface.text.TextViewer; | |
109 import dwtx.jface.text.contentassist.IContentAssistant; | |
110 import dwtx.jface.text.contentassist.IContentAssistantExtension4; | |
111 import dwtx.jface.text.formatter.FormattingContext; | |
112 import dwtx.jface.text.formatter.FormattingContextProperties; | |
113 import dwtx.jface.text.formatter.IContentFormatter; | |
114 import dwtx.jface.text.formatter.IContentFormatterExtension; | |
115 import dwtx.jface.text.formatter.IFormattingContext; | |
116 import dwtx.jface.text.hyperlink.IHyperlinkDetector; | |
117 import dwtx.jface.text.information.IInformationPresenter; | |
118 import dwtx.jface.text.presentation.IPresentationReconciler; | |
119 import dwtx.jface.text.projection.ChildDocument; | |
120 import dwtx.jface.text.quickassist.IQuickAssistAssistant; | |
121 import dwtx.jface.text.quickassist.IQuickAssistInvocationContext; | |
122 import dwtx.jface.text.reconciler.IReconciler; | |
123 | |
124 /** | |
125 * DWT based implementation of | |
126 * {@link dwtx.jface.text.source.ISourceViewer} and its extension | |
127 * interfaces. The same rules apply as for | |
128 * {@link dwtx.jface.text.TextViewer}. A source viewer uses an | |
129 * <code>IVerticalRuler</code> as its annotation presentation area. The | |
130 * vertical ruler is a small strip shown left of the viewer's text widget. A | |
131 * source viewer uses an <code>IOverviewRuler</code> as its presentation area | |
132 * for the annotation overview. The overview ruler is a small strip shown right | |
133 * of the viewer's text widget. | |
134 * <p> | |
135 * Clients are supposed to instantiate a source viewer and subsequently to | |
136 * communicate with it exclusively using the <code>ISourceViewer</code> and | |
137 * its extension interfaces.</p> | |
138 * <p> | |
139 * Clients may subclass this class but should expect some breakage by future releases.</p> | |
140 */ | |
141 public class SourceViewer : TextViewer , ISourceViewer, ISourceViewerExtension, ISourceViewerExtension2, ISourceViewerExtension3, ISourceViewerExtension4 { | |
142 | |
143 | |
144 /** | |
145 * Layout of a source viewer. Vertical ruler, text widget, and overview ruler are shown side by side. | |
146 */ | |
147 protected class RulerLayout : Layout { | |
148 | |
149 /** The gap between the text viewer and the vertical ruler. */ | |
150 protected int fGap; | |
151 | |
152 /** | |
153 * Creates a new ruler layout with the given gap between text viewer and vertical ruler. | |
154 * | |
155 * @param gap the gap between text viewer and vertical ruler | |
156 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
157 public this(int gap) { |
129 | 158 fGap= gap; |
159 } | |
160 | |
161 /* | |
162 * @see Layout#computeSize(Composite, int, int, bool) | |
163 */ | |
164 protected Point computeSize(Composite composite, int wHint, int hHint, bool flushCache) { | |
165 Control[] children= composite.getChildren(); | |
166 Point s= children[children.length - 1].computeSize(DWT.DEFAULT, DWT.DEFAULT, flushCache); | |
167 if (fVerticalRuler !is null && fIsVerticalRulerVisible) | |
168 s.x += fVerticalRuler.getWidth() + fGap; | |
169 return s; | |
170 } | |
171 | |
172 /* | |
173 * @see Layout#layout(Composite, bool) | |
174 */ | |
175 protected void layout(Composite composite, bool flushCache) { | |
176 Rectangle clArea= composite.getClientArea(); | |
177 Rectangle trim= getTextWidget().computeTrim(0, 0, 0, 0); | |
178 int topTrim= - trim.y; | |
179 int scrollbarHeight= trim.height - topTrim; // scrollbar is only under the client area | |
180 | |
181 int x= clArea.x; | |
182 int width= clArea.width; | |
183 | |
184 if (fOverviewRuler !is null && fIsOverviewRulerVisible) { | |
185 int overviewRulerWidth= fOverviewRuler.getWidth(); | |
186 fOverviewRuler.getControl().setBounds(clArea.x + clArea.width - overviewRulerWidth - 1, clArea.y + scrollbarHeight, overviewRulerWidth, clArea.height - 3*scrollbarHeight); | |
187 fOverviewRuler.getHeaderControl().setBounds(clArea.x + clArea.width - overviewRulerWidth - 1, clArea.y, overviewRulerWidth, scrollbarHeight); | |
188 | |
189 width -= overviewRulerWidth + fGap; | |
190 } | |
191 | |
192 if (fVerticalRuler !is null && fIsVerticalRulerVisible) { | |
193 int verticalRulerWidth= fVerticalRuler.getWidth(); | |
194 final Control verticalRulerControl= fVerticalRuler.getControl(); | |
195 int oldWidth= verticalRulerControl.getBounds().width; | |
196 verticalRulerControl.setBounds(clArea.x, clArea.y + topTrim, verticalRulerWidth, clArea.height - scrollbarHeight - topTrim); | |
197 if (flushCache && getVisualAnnotationModel() !is null && oldWidth is verticalRulerWidth) | |
198 verticalRulerControl.redraw(); | |
199 | |
200 x += verticalRulerWidth + fGap; | |
201 width -= verticalRulerWidth + fGap; | |
202 } | |
203 | |
204 getTextWidget().setBounds(x, clArea.y, width, clArea.height); | |
205 } | |
206 } | |
207 | |
208 /** | |
209 * The size of the gap between the vertical ruler and the text widget | |
210 * (value <code>2</code>). | |
211 * <p> | |
212 * Note: As of 3.2, the text editor framework is no longer using 2 as | |
213 * gap but 1, see {{@link #GAP_SIZE_1 }. | |
214 * </p> | |
215 */ | |
216 protected final static int GAP_SIZE= 2; | |
217 /** | |
218 * The size of the gap between the vertical ruler and the text widget | |
219 * (value <code>1</code>). | |
220 * @since 3.2 | |
221 */ | |
222 protected final static int GAP_SIZE_1= 1; | |
223 /** | |
224 * Partial name of the position category to manage remembered selections. | |
225 * @since 3.0 | |
226 */ | |
227 protected final static String _SELECTION_POSITION_CATEGORY= "__selection_category"; //$NON-NLS-1$ | |
228 /** | |
229 * Key of the model annotation model inside the visual annotation model. | |
230 * @since 3.0 | |
231 */ | |
162 | 232 private static Object MODEL_ANNOTATION_MODEL_; |
233 protected static Object MODEL_ANNOTATION_MODEL(){ | |
234 if( MODEL_ANNOTATION_MODEL_ is null ){ | |
235 synchronized(SourceViewer.classinfo ){ | |
236 if( MODEL_ANNOTATION_MODEL_ is null ){ | |
237 MODEL_ANNOTATION_MODEL_ = new Object(); | |
238 } | |
239 } | |
240 } | |
241 return MODEL_ANNOTATION_MODEL_; | |
242 } | |
129 | 243 |
244 /** The viewer's content assistant */ | |
245 protected IContentAssistant fContentAssistant; | |
246 /** | |
247 * The viewer's facade to its content assistant. | |
248 * @since 3.4 | |
249 */ | |
250 private ContentAssistantFacade fContentAssistantFacade; | |
251 /** | |
252 * Flag indicating whether the viewer's content assistant is installed. | |
253 * @since 2.0 | |
254 */ | |
255 protected bool fContentAssistantInstalled; | |
256 /** | |
257 * This viewer's quick assist assistant. | |
258 * @since 3.2 | |
259 */ | |
260 protected IQuickAssistAssistant fQuickAssistAssistant; | |
261 /** | |
262 * Flag indicating whether this viewer's quick assist assistant is installed. | |
263 * @since 3.2 | |
264 */ | |
265 protected bool fQuickAssistAssistantInstalled; | |
266 /** The viewer's content formatter */ | |
267 protected IContentFormatter fContentFormatter; | |
268 /** The viewer's model reconciler */ | |
269 protected IReconciler fReconciler; | |
270 /** The viewer's presentation reconciler */ | |
271 protected IPresentationReconciler fPresentationReconciler; | |
272 /** The viewer's annotation hover */ | |
273 protected IAnnotationHover fAnnotationHover; | |
274 /** | |
275 * Stack of saved selections in the underlying document | |
276 * @since 3.0 | |
277 */ | |
162 | 278 protected const Stack fSelections; |
129 | 279 /** |
280 * Position updater for saved selections | |
281 * @since 3.0 | |
282 */ | |
283 protected IPositionUpdater fSelectionUpdater= null; | |
284 /** | |
285 * Position category used by the selection updater | |
286 * @since 3.0 | |
287 */ | |
288 protected String fSelectionCategory; | |
289 /** | |
290 * The viewer's overview ruler annotation hover | |
291 * @since 3.0 | |
292 */ | |
293 protected IAnnotationHover fOverviewRulerAnnotationHover; | |
294 /** | |
295 * The viewer's information presenter | |
296 * @since 2.0 | |
297 */ | |
298 protected IInformationPresenter fInformationPresenter; | |
299 | |
300 /** Visual vertical ruler */ | |
301 private IVerticalRuler fVerticalRuler; | |
302 /** Visibility of vertical ruler */ | |
303 private bool fIsVerticalRulerVisible; | |
304 /** The DWT widget used when supporting a vertical ruler */ | |
305 private Composite fComposite; | |
306 /** The vertical ruler's annotation model */ | |
307 private IAnnotationModel fVisualAnnotationModel; | |
308 /** The viewer's range indicator to be shown in the vertical ruler */ | |
309 private Annotation fRangeIndicator; | |
310 /** The viewer's vertical ruler hovering controller */ | |
311 private AnnotationBarHoverManager fVerticalRulerHoveringController; | |
312 /** | |
313 * The viewer's overview ruler hovering controller | |
314 * @since 2.1 | |
315 */ | |
316 private AbstractHoverInformationControlManager fOverviewRulerHoveringController; | |
317 | |
318 /** | |
319 * The overview ruler. | |
320 * @since 2.1 | |
321 */ | |
322 private IOverviewRuler fOverviewRuler; | |
323 /** | |
324 * The visibility of the overview ruler | |
325 * @since 2.1 | |
326 */ | |
327 private bool fIsOverviewRulerVisible; | |
328 | |
329 | |
330 /** | |
331 * Constructs a new source viewer. The vertical ruler is initially visible. | |
332 * The viewer has not yet been initialized with a source viewer configuration. | |
333 * | |
334 * @param parent the parent of the viewer's control | |
335 * @param ruler the vertical ruler used by this source viewer | |
336 * @param styles the DWT style bits for the viewer's control, | |
337 * <em>if <code>DWT.WRAP</code> is set then a custom document adapter needs to be provided, see {@link #createDocumentAdapter()} | |
338 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
339 public this(Composite parent, IVerticalRuler ruler, int styles) { |
129 | 340 this(parent, ruler, null, false, styles); |
341 } | |
342 | |
343 /** | |
344 * Constructs a new source viewer. The vertical ruler is initially visible. | |
345 * The overview ruler visibility is controlled by the value of <code>showAnnotationsOverview</code>. | |
346 * The viewer has not yet been initialized with a source viewer configuration. | |
347 * | |
348 * @param parent the parent of the viewer's control | |
349 * @param verticalRuler the vertical ruler used by this source viewer | |
350 * @param overviewRuler the overview ruler | |
351 * @param showAnnotationsOverview <code>true</code> if the overview ruler should be visible, <code>false</code> otherwise | |
352 * @param styles the DWT style bits for the viewer's control, | |
353 * <em>if <code>DWT.WRAP</code> is set then a custom document adapter needs to be provided, see {@link #createDocumentAdapter()} | |
354 * @since 2.1 | |
355 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
356 public this(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, bool showAnnotationsOverview, int styles) { |
162 | 357 fSelections= new Stack(); |
129 | 358 super(); |
359 | |
360 fVerticalRuler= verticalRuler; | |
361 fIsVerticalRulerVisible= (verticalRuler !is null); | |
362 fOverviewRuler= overviewRuler; | |
363 fIsOverviewRulerVisible= (showAnnotationsOverview && overviewRuler !is null); | |
364 | |
365 createControl(parent, styles); | |
366 } | |
367 | |
368 /* | |
369 * @see TextViewer#createControl(Composite, int) | |
370 */ | |
371 protected void createControl(Composite parent, int styles) { | |
372 | |
373 if (fVerticalRuler !is null || fOverviewRuler !is null) { | |
374 styles= (styles & ~DWT.BORDER); | |
375 fComposite= new Canvas(parent, DWT.NONE); | |
376 fComposite.setLayout(createLayout()); | |
377 parent= fComposite; | |
378 } | |
379 | |
380 super.createControl(parent, styles); | |
381 | |
382 if (fVerticalRuler !is null) | |
383 fVerticalRuler.createControl(fComposite, this); | |
384 if (fOverviewRuler !is null) | |
385 fOverviewRuler.createControl(fComposite, this); | |
386 } | |
387 | |
388 /** | |
389 * Creates the layout used for this viewer. | |
390 * Subclasses may override this method. | |
391 * | |
392 * @return the layout used for this viewer | |
393 * @since 3.0 | |
394 */ | |
395 protected Layout createLayout() { | |
396 return new RulerLayout(GAP_SIZE_1); | |
397 } | |
398 | |
399 /* | |
400 * @see TextViewer#getControl() | |
401 */ | |
402 public Control getControl() { | |
403 if (fComposite !is null) | |
404 return fComposite; | |
405 return super.getControl(); | |
406 } | |
407 | |
408 /* | |
409 * @see ISourceViewer#setAnnotationHover(IAnnotationHover) | |
410 */ | |
411 public void setAnnotationHover(IAnnotationHover annotationHover) { | |
412 fAnnotationHover= annotationHover; | |
413 } | |
414 | |
415 /** | |
416 * Sets the overview ruler's annotation hover of this source viewer. | |
417 * The annotation hover provides the information to be displayed in a hover | |
418 * popup window if requested over the overview rulers area. The annotation | |
419 * hover is assumed to be line oriented. | |
420 * | |
421 * @param annotationHover the hover to be used, <code>null</code> is a valid argument | |
422 * @since 3.0 | |
423 */ | |
424 public void setOverviewRulerAnnotationHover(IAnnotationHover annotationHover) { | |
425 fOverviewRulerAnnotationHover= annotationHover; | |
426 } | |
427 | |
428 /* | |
429 * @see ISourceViewer#configure(SourceViewerConfiguration) | |
430 */ | |
431 public void configure(SourceViewerConfiguration configuration) { | |
432 | |
433 if (getTextWidget() is null) | |
434 return; | |
435 | |
436 setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this)); | |
437 | |
438 // install content type independent plug-ins | |
439 fPresentationReconciler= configuration.getPresentationReconciler(this); | |
440 if (fPresentationReconciler !is null) | |
441 fPresentationReconciler.install(this); | |
442 | |
443 fReconciler= configuration.getReconciler(this); | |
444 if (fReconciler !is null) | |
445 fReconciler.install(this); | |
446 | |
447 fContentAssistant= configuration.getContentAssistant(this); | |
448 if (fContentAssistant !is null) { | |
449 fContentAssistant.install(this); | |
143 | 450 if ( cast(IContentAssistantExtension4)fContentAssistant && cast(IContentAssistantExtension4)fContentAssistant ) |
129 | 451 fContentAssistantFacade= new ContentAssistantFacade(fContentAssistant); |
452 fContentAssistantInstalled= true; | |
453 } | |
454 | |
455 fQuickAssistAssistant= configuration.getQuickAssistAssistant(this); | |
456 if (fQuickAssistAssistant !is null) { | |
457 fQuickAssistAssistant.install(this); | |
458 fQuickAssistAssistantInstalled= true; | |
459 } | |
460 | |
461 fContentFormatter= configuration.getContentFormatter(this); | |
462 | |
463 fInformationPresenter= configuration.getInformationPresenter(this); | |
464 if (fInformationPresenter !is null) | |
465 fInformationPresenter.install(this); | |
466 | |
467 setUndoManager(configuration.getUndoManager(this)); | |
468 | |
469 getTextWidget().setTabs(configuration.getTabWidth(this)); | |
470 | |
471 setAnnotationHover(configuration.getAnnotationHover(this)); | |
472 setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this)); | |
473 | |
474 setHoverControlCreator(configuration.getInformationControlCreator(this)); | |
475 | |
476 setHyperlinkPresenter(configuration.getHyperlinkPresenter(this)); | |
477 IHyperlinkDetector[] hyperlinkDetectors= configuration.getHyperlinkDetectors(this); | |
478 int eventStateMask= configuration.getHyperlinkStateMask(this); | |
479 setHyperlinkDetectors(hyperlinkDetectors, eventStateMask); | |
480 | |
481 // install content type specific plug-ins | |
482 String[] types= configuration.getConfiguredContentTypes(this); | |
483 for (int i= 0; i < types.length; i++) { | |
484 | |
485 String t= types[i]; | |
486 | |
487 setAutoEditStrategies(configuration.getAutoEditStrategies(this, t), t); | |
488 setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t); | |
489 | |
490 int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(this, t); | |
491 if (stateMasks !is null) { | |
492 for (int j= 0; j < stateMasks.length; j++) { | |
493 int stateMask= stateMasks[j]; | |
494 setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask); | |
495 } | |
496 } else { | |
497 setTextHover(configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); | |
498 } | |
499 | |
500 String[] prefixes= configuration.getIndentPrefixes(this, t); | |
501 if (prefixes !is null && prefixes.length > 0) | |
502 setIndentPrefixes(prefixes, t); | |
503 | |
504 prefixes= configuration.getDefaultPrefixes(this, t); | |
505 if (prefixes !is null && prefixes.length > 0) | |
506 setDefaultPrefixes(prefixes, t); | |
507 } | |
508 | |
509 activatePlugins(); | |
510 } | |
511 | |
512 /** | |
513 * After this method has been executed the caller knows that any installed annotation hover has been installed. | |
514 */ | |
515 protected void ensureAnnotationHoverManagerInstalled() { | |
516 if (fVerticalRuler !is null && (fAnnotationHover !is null || !isVerticalRulerOnlyShowingAnnotations()) && fVerticalRulerHoveringController is null && fHoverControlCreator !is null) { | |
517 fVerticalRulerHoveringController= new AnnotationBarHoverManager(fVerticalRuler, this, fAnnotationHover, fHoverControlCreator); | |
518 fVerticalRulerHoveringController.install(fVerticalRuler.getControl()); | |
519 fVerticalRulerHoveringController.getInternalAccessor().setInformationControlReplacer(new StickyHoverManager(this)); | |
520 } | |
521 } | |
522 | |
523 /** | |
524 * After this method has been executed the caller knows that any installed overview hover has been installed. | |
525 */ | |
526 protected void ensureOverviewHoverManagerInstalled() { | |
527 if (fOverviewRuler !is null && fOverviewRulerAnnotationHover !is null && fOverviewRulerHoveringController is null && fHoverControlCreator !is null) { | |
528 fOverviewRulerHoveringController= new OverviewRulerHoverManager(fOverviewRuler, this, fOverviewRulerAnnotationHover, fHoverControlCreator); | |
529 fOverviewRulerHoveringController.install(fOverviewRuler.getControl()); | |
530 fOverviewRulerHoveringController.getInternalAccessor().setInformationControlReplacer(new StickyHoverManager(this)); | |
531 } | |
532 } | |
145 | 533 |
129 | 534 /* |
535 * @see dwtx.jface.text.TextViewer#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode) | |
536 * @since 3.4 | |
537 */ | |
159 | 538 public void setHoverEnrichMode(ITextViewerExtension8_EnrichMode mode) { |
129 | 539 super.setHoverEnrichMode(mode); |
540 if (fVerticalRulerHoveringController !is null) | |
541 fVerticalRulerHoveringController.getInternalAccessor().setHoverEnrichMode(mode); | |
542 if (fOverviewRulerHoveringController !is null) | |
543 fOverviewRulerHoveringController.getInternalAccessor().setHoverEnrichMode(mode); | |
544 } | |
545 | |
546 /* | |
547 * @see TextViewer#activatePlugins() | |
548 */ | |
549 public void activatePlugins() { | |
550 ensureAnnotationHoverManagerInstalled(); | |
551 ensureOverviewHoverManagerInstalled(); | |
552 super.activatePlugins(); | |
553 } | |
554 | |
555 /* | |
556 * @see ISourceViewer#setDocument(IDocument, IAnnotationModel) | |
557 */ | |
558 public void setDocument(IDocument document) { | |
559 setDocument(document, null, -1, -1); | |
560 } | |
561 | |
562 /* | |
563 * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int) | |
564 */ | |
565 public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength) { | |
566 setDocument(document, null, visibleRegionOffset, visibleRegionLength); | |
567 } | |
568 | |
569 /* | |
570 * @see ISourceViewer#setDocument(IDocument, IAnnotationModel) | |
571 */ | |
572 public void setDocument(IDocument document, IAnnotationModel annotationModel) { | |
573 setDocument(document, annotationModel, -1, -1); | |
574 } | |
575 | |
576 /** | |
577 * Creates the visual annotation model on top of the given annotation model. | |
578 * | |
579 * @param annotationModel the wrapped annotation model | |
580 * @return the visual annotation model on top of the given annotation model | |
581 * @since 3.0 | |
582 */ | |
583 protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) { | |
584 IAnnotationModelExtension model= new AnnotationModel(); | |
585 model.addAnnotationModel(MODEL_ANNOTATION_MODEL, annotationModel); | |
134 | 586 return cast(IAnnotationModel) model; |
129 | 587 } |
588 | |
589 /** | |
590 * Disposes the visual annotation model. | |
145 | 591 * |
129 | 592 * @since 3.1 |
593 */ | |
594 protected void disposeVisualAnnotationModel() { | |
595 if (fVisualAnnotationModel !is null) { | |
596 if (getDocument() !is null) | |
597 fVisualAnnotationModel.disconnect(getDocument()); | |
145 | 598 |
138 | 599 if ( cast(IAnnotationModelExtension)fVisualAnnotationModel ) |
134 | 600 (cast(IAnnotationModelExtension)fVisualAnnotationModel).removeAnnotationModel(MODEL_ANNOTATION_MODEL); |
145 | 601 |
129 | 602 fVisualAnnotationModel= null; |
603 } | |
604 } | |
605 | |
606 /* | |
607 * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int) | |
608 */ | |
609 public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength) { | |
610 disposeVisualAnnotationModel(); | |
611 | |
612 if (annotationModel !is null && document !is null) { | |
613 fVisualAnnotationModel= createVisualAnnotationModel(annotationModel); | |
614 fVisualAnnotationModel.connect(document); | |
615 } | |
616 | |
617 if (modelRangeOffset is -1 && modelRangeLength is -1) | |
618 super.setDocument(document); | |
619 else | |
620 super.setDocument(document, modelRangeOffset, modelRangeLength); | |
621 | |
622 if (fVerticalRuler !is null) | |
623 fVerticalRuler.setModel(fVisualAnnotationModel); | |
624 | |
625 if (fOverviewRuler !is null) | |
626 fOverviewRuler.setModel(fVisualAnnotationModel); | |
627 } | |
628 | |
629 /* | |
630 * @see ISourceViewer#getAnnotationModel() | |
631 */ | |
632 public IAnnotationModel getAnnotationModel() { | |
138 | 633 if ( cast(IAnnotationModelExtension)fVisualAnnotationModel ) { |
134 | 634 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fVisualAnnotationModel; |
129 | 635 return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL); |
636 } | |
637 return null; | |
638 } | |
639 | |
640 /* | |
641 * @see dwtx.jface.text.source.ISourceViewerExtension3#getQuickAssistAssistant() | |
642 * @since 3.2 | |
643 */ | |
644 public IQuickAssistAssistant getQuickAssistAssistant() { | |
645 return fQuickAssistAssistant; | |
646 } | |
647 | |
648 /** | |
649 * {@inheritDoc} | |
145 | 650 * |
129 | 651 * @since 3.4 |
652 */ | |
653 public final ContentAssistantFacade getContentAssistantFacade() { | |
654 return fContentAssistantFacade; | |
655 } | |
656 | |
657 /* | |
658 * @see dwtx.jface.text.source.ISourceViewerExtension3#getQuickAssistInvocationContext() | |
659 * @since 3.2 | |
660 */ | |
661 public IQuickAssistInvocationContext getQuickAssistInvocationContext() { | |
662 Point selection= getSelectedRange(); | |
663 return new TextInvocationContext(this, selection.x, selection.x); | |
664 } | |
665 | |
666 /* | |
667 * @see dwtx.jface.text.source.ISourceViewerExtension2#getVisualAnnotationModel() | |
668 * @since 3.0 | |
669 */ | |
670 public IAnnotationModel getVisualAnnotationModel() { | |
671 return fVisualAnnotationModel; | |
672 } | |
673 | |
674 /* | |
675 * @see dwtx.jface.text.source.ISourceViewerExtension2#unconfigure() | |
676 * @since 3.0 | |
677 */ | |
678 public void unconfigure() { | |
679 clearRememberedSelection(); | |
680 | |
681 if (fPresentationReconciler !is null) { | |
682 fPresentationReconciler.uninstall(); | |
683 fPresentationReconciler= null; | |
684 } | |
685 | |
686 if (fReconciler !is null) { | |
687 fReconciler.uninstall(); | |
688 fReconciler= null; | |
689 } | |
690 | |
691 if (fContentAssistant !is null) { | |
692 fContentAssistant.uninstall(); | |
693 fContentAssistantInstalled= false; | |
694 fContentAssistant= null; | |
695 if (fContentAssistantFacade !is null) | |
696 fContentAssistantFacade= null; | |
697 } | |
698 | |
699 if (fQuickAssistAssistant !is null) { | |
700 fQuickAssistAssistant.uninstall(); | |
701 fQuickAssistAssistantInstalled= false; | |
702 fQuickAssistAssistant= null; | |
703 } | |
704 | |
705 fContentFormatter= null; | |
706 | |
707 if (fInformationPresenter !is null) { | |
708 fInformationPresenter.uninstall(); | |
709 fInformationPresenter= null; | |
710 } | |
711 | |
712 fAutoIndentStrategies= null; | |
713 fDoubleClickStrategies= null; | |
714 fTextHovers= null; | |
715 fIndentChars= null; | |
716 fDefaultPrefixChars= null; | |
717 | |
718 if (fVerticalRulerHoveringController !is null) { | |
719 fVerticalRulerHoveringController.dispose(); | |
720 fVerticalRulerHoveringController= null; | |
721 } | |
722 | |
723 if (fOverviewRulerHoveringController !is null) { | |
724 fOverviewRulerHoveringController.dispose(); | |
725 fOverviewRulerHoveringController= null; | |
726 } | |
727 | |
728 if (fUndoManager !is null) { | |
729 fUndoManager.disconnect(); | |
730 fUndoManager= null; | |
731 } | |
732 | |
733 setHyperlinkDetectors(null, DWT.NONE); | |
734 } | |
735 | |
736 /* | |
737 * @see dwtx.jface.text.TextViewer#handleDispose() | |
738 */ | |
739 protected void handleDispose() { | |
740 unconfigure(); | |
741 | |
742 disposeVisualAnnotationModel(); | |
743 | |
744 fVerticalRuler= null; | |
745 | |
746 fOverviewRuler= null; | |
747 | |
748 // http://dev.eclipse.org/bugs/show_bug.cgi?id=15300 | |
749 fComposite= null; | |
750 | |
751 super.handleDispose(); | |
752 } | |
753 | |
754 /* | |
755 * @see ITextOperationTarget#canDoOperation(int) | |
756 */ | |
757 public bool canDoOperation(int operation) { | |
758 | |
759 if (getTextWidget() is null || (!redraws() && operation !is FORMAT)) | |
760 return false; | |
761 | |
762 if (operation is CONTENTASSIST_PROPOSALS) | |
763 return fContentAssistant !is null && fContentAssistantInstalled && isEditable(); | |
764 | |
765 if (operation is CONTENTASSIST_CONTEXT_INFORMATION) | |
766 return fContentAssistant !is null && fContentAssistantInstalled && isEditable(); | |
145 | 767 |
129 | 768 if (operation is QUICK_ASSIST) |
769 return fQuickAssistAssistant !is null && fQuickAssistAssistantInstalled && isEditable(); | |
770 | |
771 if (operation is INFORMATION) | |
772 return fInformationPresenter !is null; | |
773 | |
774 if (operation is FORMAT) { | |
775 return fContentFormatter !is null && isEditable(); | |
776 } | |
777 | |
778 return super.canDoOperation(operation); | |
779 } | |
780 | |
781 /** | |
782 * Creates a new formatting context for a format operation. | |
783 * <p> | |
784 * After the use of the context, clients are required to call | |
785 * its <code>dispose</code> method. | |
786 * | |
787 * @return The new formatting context | |
788 * @since 3.0 | |
789 */ | |
790 protected IFormattingContext createFormattingContext() { | |
791 return new FormattingContext(); | |
792 } | |
793 | |
794 /** | |
795 * Remembers and returns the current selection. The saved selection can be restored | |
796 * by calling <code>restoreSelection()</code>. | |
797 * | |
798 * @return the current selection | |
799 * @see dwtx.jface.text.ITextViewer#getSelectedRange() | |
800 * @since 3.0 | |
801 */ | |
802 protected Point rememberSelection() { | |
803 | |
804 final Point selection= getSelectedRange(); | |
805 final IDocument document= getDocument(); | |
806 | |
807 if (fSelections.isEmpty()) { | |
162 | 808 fSelectionCategory= _SELECTION_POSITION_CATEGORY ~ Integer.toString(toHash()); |
129 | 809 fSelectionUpdater= new NonDeletingPositionUpdater(fSelectionCategory); |
810 document.addPositionCategory(fSelectionCategory); | |
811 document.addPositionUpdater(fSelectionUpdater); | |
812 } | |
813 | |
814 try { | |
815 | |
816 final Position position= new Position(selection.x, selection.y); | |
817 document.addPosition(fSelectionCategory, position); | |
818 fSelections.push(position); | |
819 | |
820 } catch (BadLocationException exception) { | |
821 // Should not happen | |
822 } catch (BadPositionCategoryException exception) { | |
823 // Should not happen | |
824 } | |
825 | |
826 return selection; | |
827 } | |
828 | |
829 /** | |
830 * Restores a previously saved selection in the document. | |
831 * <p> | |
832 * If no selection was previously saved, nothing happens. | |
833 * | |
834 * @since 3.0 | |
835 */ | |
836 protected void restoreSelection() { | |
837 | |
838 if (!fSelections.isEmpty()) { | |
839 | |
840 final IDocument document= getDocument(); | |
134 | 841 final Position position= cast(Position) fSelections.pop(); |
129 | 842 |
843 try { | |
844 document.removePosition(fSelectionCategory, position); | |
845 Point currentSelection= getSelectedRange(); | |
846 if (currentSelection is null || currentSelection.x !is position.getOffset() || currentSelection.y !is position.getLength()) | |
847 setSelectedRange(position.getOffset(), position.getLength()); | |
848 | |
849 if (fSelections.isEmpty()) | |
850 clearRememberedSelection(); | |
851 } catch (BadPositionCategoryException exception) { | |
852 // Should not happen | |
853 } | |
854 } | |
855 } | |
856 | |
857 protected void clearRememberedSelection() { | |
858 if (!fSelections.isEmpty()) | |
859 fSelections.clear(); | |
860 | |
861 IDocument document= getDocument(); | |
862 if (document !is null && fSelectionUpdater !is null) { | |
863 document.removePositionUpdater(fSelectionUpdater); | |
864 try { | |
865 document.removePositionCategory(fSelectionCategory); | |
866 } catch (BadPositionCategoryException e) { | |
867 // ignore | |
868 } | |
869 } | |
870 fSelectionUpdater= null; | |
871 fSelectionCategory= null; | |
872 } | |
873 | |
874 /* | |
875 * @see ITextOperationTarget#doOperation(int) | |
876 */ | |
877 public void doOperation(int operation) { | |
878 | |
879 if (getTextWidget() is null || (!redraws() && operation !is FORMAT)) | |
880 return; | |
881 | |
882 switch (operation) { | |
883 case CONTENTASSIST_PROPOSALS: | |
884 fContentAssistant.showPossibleCompletions(); | |
885 return; | |
886 case CONTENTASSIST_CONTEXT_INFORMATION: | |
887 fContentAssistant.showContextInformation(); | |
888 return; | |
889 case QUICK_ASSIST: | |
890 // FIXME: must find a way to post to the status line | |
891 /* String msg= */ fQuickAssistAssistant.showPossibleQuickAssists(); | |
892 // setStatusLineErrorMessage(msg); | |
893 return; | |
894 case INFORMATION: | |
895 fInformationPresenter.showInformation(); | |
896 return; | |
897 case FORMAT: | |
898 { | |
899 final Point selection= rememberSelection(); | |
900 final IRewriteTarget target= getRewriteTarget(); | |
901 final IDocument document= getDocument(); | |
902 IFormattingContext context= null; | |
903 DocumentRewriteSession rewriteSession= null; | |
904 | |
138 | 905 if ( cast(IDocumentExtension4)document ) { |
134 | 906 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
129 | 907 DocumentRewriteSessionType type= selection.y is 0 || selection.y > 1000 ? DocumentRewriteSessionType.SEQUENTIAL : DocumentRewriteSessionType.UNRESTRICTED_SMALL; |
908 rewriteSession= extension.startRewriteSession(type); | |
909 } else { | |
910 setRedraw(false); | |
911 target.beginCompoundChange(); | |
912 } | |
913 | |
914 try { | |
915 | |
916 final String rememberedContents= document.get(); | |
917 | |
918 try { | |
919 | |
138 | 920 if ( cast(IContentFormatterExtension)fContentFormatter ) { |
134 | 921 final IContentFormatterExtension extension= cast(IContentFormatterExtension) fContentFormatter; |
129 | 922 context= createFormattingContext(); |
923 if (selection.y is 0) { | |
162 | 924 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT), Boolean.TRUE); |
129 | 925 } else { |
162 | 926 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_DOCUMENT), Boolean.FALSE); |
927 context.setProperty(stringcast(FormattingContextProperties.CONTEXT_REGION), new Region(selection.x, selection.y)); | |
129 | 928 } |
929 extension.format(document, context); | |
930 } else { | |
931 IRegion r; | |
932 if (selection.y is 0) { | |
933 IRegion coverage= getModelCoverage(); | |
934 r= coverage is null ? new Region(0, 0) : coverage; | |
935 } else { | |
936 r= new Region(selection.x, selection.y); | |
937 } | |
938 fContentFormatter.format(document, r); | |
939 } | |
940 | |
941 updateSlaveDocuments(document); | |
942 | |
943 } catch (RuntimeException x) { | |
944 // fire wall for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47472 | |
945 // if something went wrong we undo the changes we just did | |
946 // TODO to be removed after 3.0 M8 | |
947 document.set(rememberedContents); | |
948 throw x; | |
949 } | |
950 | |
951 } finally { | |
952 | |
138 | 953 if ( cast(IDocumentExtension4)document ) { |
134 | 954 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
129 | 955 extension.stopRewriteSession(rewriteSession); |
956 } else { | |
957 target.endCompoundChange(); | |
958 setRedraw(true); | |
959 } | |
960 | |
961 restoreSelection(); | |
962 if (context !is null) | |
963 context.dispose(); | |
964 } | |
965 return; | |
966 } | |
967 default: | |
968 super.doOperation(operation); | |
969 } | |
970 } | |
971 | |
972 /** | |
973 * Updates all slave documents of the given document. This default implementation calls <code>updateSlaveDocument</code> | |
974 * for their current visible range. Subclasses may reimplement. | |
975 * | |
976 * @param masterDocument the master document | |
977 * @since 3.0 | |
978 */ | |
979 protected void updateSlaveDocuments(IDocument masterDocument) { | |
980 ISlaveDocumentManager manager= getSlaveDocumentManager(); | |
138 | 981 if ( cast(ISlaveDocumentManagerExtension)manager ) { |
134 | 982 ISlaveDocumentManagerExtension extension= cast(ISlaveDocumentManagerExtension) manager; |
129 | 983 IDocument[] slaves= extension.getSlaveDocuments(masterDocument); |
984 if (slaves !is null) { | |
985 for (int i= 0; i < slaves.length; i++) { | |
145 | 986 if ( auto child = cast(ChildDocument)slaves[i] ) { |
129 | 987 Position p= child.getParentDocumentRange(); |
988 try { | |
989 | |
990 if (!updateSlaveDocument(child, p.getOffset(), p.getLength())) | |
991 child.repairLineInformation(); | |
992 | |
993 } catch (BadLocationException e) { | |
994 // ignore | |
995 } | |
996 } | |
997 } | |
998 } | |
999 } | |
1000 } | |
1001 | |
1002 /* | |
1003 * @see ITextOperationTargetExtension#enableOperation(int, bool) | |
1004 * @since 2.0 | |
1005 */ | |
1006 public void enableOperation(int operation, bool enable) { | |
1007 | |
1008 switch (operation) { | |
1009 case CONTENTASSIST_PROPOSALS: | |
1010 case CONTENTASSIST_CONTEXT_INFORMATION: { | |
1011 | |
1012 if (fContentAssistant is null) | |
1013 return; | |
1014 | |
1015 if (enable) { | |
1016 if (!fContentAssistantInstalled) { | |
1017 fContentAssistant.install(this); | |
1018 fContentAssistantInstalled= true; | |
1019 } | |
1020 } else if (fContentAssistantInstalled) { | |
1021 fContentAssistant.uninstall(); | |
1022 fContentAssistantInstalled= false; | |
1023 } | |
1024 break; | |
1025 } | |
1026 case QUICK_ASSIST: { | |
145 | 1027 |
129 | 1028 if (fQuickAssistAssistant is null) |
1029 return; | |
145 | 1030 |
129 | 1031 if (enable) { |
1032 if (!fQuickAssistAssistantInstalled) { | |
1033 fQuickAssistAssistant.install(this); | |
1034 fQuickAssistAssistantInstalled= true; | |
1035 } | |
1036 } else if (fContentAssistantInstalled) { | |
1037 fQuickAssistAssistant.uninstall(); | |
1038 fContentAssistantInstalled= false; | |
1039 } | |
1040 } | |
192
c3583c6ec027
Added missing default cases for switch statements
Frank Benoit <benoit@tionex.de>
parents:
162
diff
changeset
|
1041 default: |
129 | 1042 } |
1043 } | |
1044 | |
1045 /* | |
1046 * @see ISourceViewer#setRangeIndicator(Annotation) | |
1047 */ | |
1048 public void setRangeIndicator(Annotation rangeIndicator) { | |
1049 fRangeIndicator= rangeIndicator; | |
1050 } | |
1051 | |
1052 /* | |
1053 * @see ISourceViewer#setRangeIndication(int, int, bool) | |
1054 */ | |
1055 public void setRangeIndication(int start, int length, bool moveCursor) { | |
1056 | |
1057 if (moveCursor) { | |
1058 setSelectedRange(start, 0); | |
1059 revealRange(start, length); | |
1060 } | |
1061 | |
143 | 1062 if (fRangeIndicator !is null && cast(IAnnotationModelExtension)fVisualAnnotationModel ) { |
134 | 1063 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fVisualAnnotationModel; |
129 | 1064 extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); |
1065 } | |
1066 } | |
1067 | |
1068 /* | |
1069 * @see ISourceViewer#getRangeIndication() | |
1070 */ | |
1071 public IRegion getRangeIndication() { | |
1072 if (fRangeIndicator !is null && fVisualAnnotationModel !is null) { | |
1073 Position position= fVisualAnnotationModel.getPosition(fRangeIndicator); | |
1074 if (position !is null) | |
1075 return new Region(position.getOffset(), position.getLength()); | |
1076 } | |
1077 | |
1078 return null; | |
1079 } | |
1080 | |
1081 /* | |
1082 * @see ISourceViewer#removeRangeIndication() | |
1083 */ | |
1084 public void removeRangeIndication() { | |
1085 if (fRangeIndicator !is null && fVisualAnnotationModel !is null) | |
1086 fVisualAnnotationModel.removeAnnotation(fRangeIndicator); | |
1087 } | |
1088 | |
1089 /* | |
1090 * @see ISourceViewer#showAnnotations(bool) | |
1091 */ | |
1092 public void showAnnotations(bool show) { | |
1093 bool old= fIsVerticalRulerVisible; | |
1094 | |
1095 fIsVerticalRulerVisible= (fVerticalRuler !is null && (show || !isVerticalRulerOnlyShowingAnnotations())); | |
1096 if (old !is fIsVerticalRulerVisible && fComposite !is null && !fComposite.isDisposed()) | |
1097 fComposite.layout(); | |
1098 | |
1099 if (fIsVerticalRulerVisible && show) | |
1100 ensureAnnotationHoverManagerInstalled(); | |
1101 else if (fVerticalRulerHoveringController !is null) { | |
1102 fVerticalRulerHoveringController.dispose(); | |
1103 fVerticalRulerHoveringController= null; | |
1104 } | |
1105 } | |
1106 | |
1107 /** | |
1108 * Tells whether the vertical ruler only acts as annotation ruler. | |
145 | 1109 * |
129 | 1110 * @return <code>true</code> if the vertical ruler only show annotations |
1111 * @since 3.3 | |
1112 */ | |
1113 private bool isVerticalRulerOnlyShowingAnnotations() { | |
138 | 1114 if ( cast(VerticalRuler)fVerticalRuler ) |
129 | 1115 return true; |
145 | 1116 |
138 | 1117 if ( cast(CompositeRuler)fVerticalRuler ) { |
134 | 1118 Iterator iter= (cast(CompositeRuler)fVerticalRuler).getDecoratorIterator(); |
145 | 1119 return iter.hasNext() && cast(AnnotationRulerColumn)iter.next() && !iter.hasNext(); |
129 | 1120 } |
1121 return false; | |
1122 } | |
1123 | |
1124 /** | |
1125 * Returns the vertical ruler of this viewer. | |
1126 * | |
1127 * @return the vertical ruler of this viewer | |
1128 * @since 3.0 | |
1129 */ | |
1130 protected final IVerticalRuler getVerticalRuler() { | |
1131 return fVerticalRuler; | |
1132 } | |
1133 | |
1134 /* | |
1135 * @see dwtx.jface.text.source.ISourceViewerExtension#showAnnotationsOverview(bool) | |
1136 * @since 2.1 | |
1137 */ | |
1138 public void showAnnotationsOverview(bool show) { | |
1139 bool old= fIsOverviewRulerVisible; | |
1140 fIsOverviewRulerVisible= (show && fOverviewRuler !is null); | |
1141 if (old !is fIsOverviewRulerVisible) { | |
1142 if (fComposite !is null && !fComposite.isDisposed()) | |
1143 fComposite.layout(); | |
1144 if (fIsOverviewRulerVisible) { | |
1145 ensureOverviewHoverManagerInstalled(); | |
1146 } else if (fOverviewRulerHoveringController !is null) { | |
1147 fOverviewRulerHoveringController.dispose(); | |
1148 fOverviewRulerHoveringController= null; | |
1149 } | |
1150 } | |
1151 } | |
145 | 1152 |
129 | 1153 /* |
1154 * @see dwtx.jface.text.source.ISourceViewer#getCurrentAnnotationHover() | |
1155 * @since 3.2 | |
1156 */ | |
1157 public IAnnotationHover getCurrentAnnotationHover() { | |
1158 if (fVerticalRulerHoveringController is null) | |
1159 return null; | |
1160 return fVerticalRulerHoveringController.getCurrentAnnotationHover(); | |
1161 } | |
1162 } |