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.SourceViewerConfiguration;
|
|
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.SourceViewer; // 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
|
|
80
|
|
81 import java.util.Arrays;
|
|
82
|
|
83 import dwt.DWT;
|
|
84 import dwt.graphics.RGB;
|
|
85 import dwt.widgets.Shell;
|
|
86 import dwtx.jface.text.DefaultAutoIndentStrategy;
|
|
87 import dwtx.jface.text.DefaultInformationControl;
|
|
88 import dwtx.jface.text.DefaultTextDoubleClickStrategy;
|
|
89 import dwtx.jface.text.IAutoEditStrategy;
|
|
90 import dwtx.jface.text.IAutoIndentStrategy;
|
|
91 import dwtx.jface.text.IDocument;
|
|
92 import dwtx.jface.text.IDocumentExtension3;
|
|
93 import dwtx.jface.text.IInformationControl;
|
|
94 import dwtx.jface.text.IInformationControlCreator;
|
|
95 import dwtx.jface.text.ITextDoubleClickStrategy;
|
|
96 import dwtx.jface.text.ITextHover;
|
|
97 import dwtx.jface.text.ITextViewerExtension2;
|
|
98 import dwtx.jface.text.IUndoManager;
|
|
99 import dwtx.jface.text.TextViewerUndoManager;
|
|
100 import dwtx.jface.text.contentassist.IContentAssistant;
|
|
101 import dwtx.jface.text.formatter.IContentFormatter;
|
|
102 import dwtx.jface.text.hyperlink.DefaultHyperlinkPresenter;
|
|
103 import dwtx.jface.text.hyperlink.IHyperlinkDetector;
|
|
104 import dwtx.jface.text.hyperlink.IHyperlinkPresenter;
|
|
105 import dwtx.jface.text.hyperlink.URLHyperlinkDetector;
|
|
106 import dwtx.jface.text.information.IInformationPresenter;
|
|
107 import dwtx.jface.text.presentation.IPresentationReconciler;
|
|
108 import dwtx.jface.text.presentation.PresentationReconciler;
|
|
109 import dwtx.jface.text.quickassist.IQuickAssistAssistant;
|
|
110 import dwtx.jface.text.reconciler.IReconciler;
|
|
111
|
|
112
|
|
113 /**
|
|
114 * This class bundles the configuration space of a source viewer. Instances of
|
|
115 * this class are passed to the <code>configure</code> method of
|
|
116 * <code>ISourceViewer</code>.
|
|
117 * <p>
|
|
118 * Each method in this class get as argument the source viewer for which it
|
|
119 * should provide a particular configuration setting such as a presentation
|
|
120 * reconciler. Based on its specific knowledge about the returned object, the
|
|
121 * configuration might share such objects or compute them according to some
|
|
122 * rules.</p>
|
|
123 * <p>
|
|
124 * Clients should subclass and override just those methods which must be
|
|
125 * specific to their needs.</p>
|
|
126 *
|
|
127 * @see dwtx.jface.text.source.ISourceViewer
|
|
128 */
|
|
129 public class SourceViewerConfiguration {
|
|
130
|
|
131
|
|
132 /**
|
|
133 * Creates a new source viewer configuration that behaves according to
|
|
134 * specification of this class' methods.
|
|
135 */
|
|
136 public SourceViewerConfiguration() {
|
|
137 super();
|
|
138 }
|
|
139
|
|
140 /**
|
|
141 * Returns the visual width of the tab character. This implementation always
|
|
142 * returns 4.
|
|
143 *
|
|
144 * @param sourceViewer the source viewer to be configured by this configuration
|
|
145 * @return the tab width
|
|
146 */
|
|
147 public int getTabWidth(ISourceViewer sourceViewer) {
|
|
148 return 4;
|
|
149 }
|
|
150
|
|
151 /**
|
|
152 * Returns the undo manager for the given source viewer. This implementation
|
|
153 * always returns a new instance of <code>DefaultUndoManager</code> whose
|
|
154 * history length is set to 25.
|
|
155 *
|
|
156 * @param sourceViewer the source viewer to be configured by this configuration
|
|
157 * @return an undo manager or <code>null</code> if no undo/redo should not be supported
|
|
158 */
|
|
159 public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
|
|
160 return new TextViewerUndoManager(25);
|
|
161 }
|
|
162
|
|
163 /**
|
|
164 * Returns the reconciler ready to be used with the given source viewer.
|
|
165 * This implementation always returns <code>null</code>.
|
|
166 *
|
|
167 * @param sourceViewer the source viewer to be configured by this configuration
|
|
168 * @return a reconciler or <code>null</code> if reconciling should not be supported
|
|
169 */
|
|
170 public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
|
171 return null;
|
|
172 }
|
|
173
|
|
174 /**
|
|
175 * Returns the presentation reconciler ready to be used with the given source viewer.
|
|
176 *
|
|
177 * @param sourceViewer the source viewer
|
|
178 * @return the presentation reconciler or <code>null</code> if presentation reconciling should not be supported
|
|
179 */
|
|
180 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
|
|
181 PresentationReconciler reconciler= new PresentationReconciler();
|
|
182 reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
|
|
183 return reconciler;
|
|
184 }
|
|
185
|
|
186 /**
|
|
187 * Returns the content formatter ready to be used with the given source viewer.
|
|
188 * This implementation always returns <code>null</code>.
|
|
189 *
|
|
190 * @param sourceViewer the source viewer to be configured by this configuration
|
|
191 * @return a content formatter or <code>null</code> if formatting should not be supported
|
|
192 */
|
|
193 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
|
|
194 return null;
|
|
195 }
|
|
196
|
|
197 /**
|
|
198 * Returns the content assistant ready to be used with the given source viewer.
|
|
199 * This implementation always returns <code>null</code>.
|
|
200 *
|
|
201 * @param sourceViewer the source viewer to be configured by this configuration
|
|
202 * @return a content assistant or <code>null</code> if content assist should not be supported
|
|
203 */
|
|
204 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
|
|
205 return null;
|
|
206 }
|
|
207
|
|
208 /**
|
|
209 * Returns the quick assist assistant ready to be used with the given
|
|
210 * source viewer.
|
|
211 * This implementation always returns <code>null</code>.
|
|
212 *
|
|
213 * @param sourceViewer the source viewer to be configured by this configuration
|
|
214 * @return a quick assist assistant or <code>null</code> if quick assist should not be supported
|
|
215 * @since 3.2
|
|
216 */
|
|
217 public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
|
|
218 return null;
|
|
219 }
|
|
220
|
|
221 /**
|
|
222 * Returns the auto indentation strategy ready to be used with the given source viewer
|
|
223 * when manipulating text of the given content type. This implementation always
|
|
224 * returns an new instance of <code>DefaultAutoIndentStrategy</code>.
|
|
225 *
|
|
226 * @param sourceViewer the source viewer to be configured by this configuration
|
|
227 * @param contentType the content type for which the strategy is applicable
|
|
228 * @return the auto indent strategy or <code>null</code> if automatic indentation is not to be enabled
|
|
229 * @deprecated since 3.1 use {@link #getAutoEditStrategies(ISourceViewer, String)} instead
|
|
230 */
|
|
231 public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
|
|
232 return new DefaultAutoIndentStrategy();
|
|
233 }
|
|
234
|
|
235 /**
|
|
236 * Returns the auto edit strategies ready to be used with the given source viewer
|
|
237 * when manipulating text of the given content type. For backward compatibility, this implementation always
|
|
238 * returns an array containing the result of {@link #getAutoIndentStrategy(ISourceViewer, String)}.
|
|
239 *
|
|
240 * @param sourceViewer the source viewer to be configured by this configuration
|
|
241 * @param contentType the content type for which the strategies are applicable
|
|
242 * @return the auto edit strategies or <code>null</code> if automatic editing is not to be enabled
|
|
243 * @since 3.1
|
|
244 */
|
|
245 public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
|
|
246 return new IAutoEditStrategy[] { getAutoIndentStrategy(sourceViewer, contentType) };
|
|
247 }
|
|
248
|
|
249 /**
|
|
250 * Returns the default prefixes to be used by the line-prefix operation
|
|
251 * in the given source viewer for text of the given content type. This implementation always
|
|
252 * returns <code>null</code>.
|
|
253 *
|
|
254 * @param sourceViewer the source viewer to be configured by this configuration
|
|
255 * @param contentType the content type for which the prefix is applicable
|
|
256 * @return the default prefixes or <code>null</code> if the prefix operation should not be supported
|
|
257 * @since 2.0
|
|
258 */
|
|
259 public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
|
|
260 return null;
|
|
261 }
|
|
262
|
|
263 /**
|
|
264 * Returns the double-click strategy ready to be used in this viewer when double clicking
|
|
265 * onto text of the given content type. This implementation always returns a new instance of
|
|
266 * <code>DefaultTextDoubleClickStrategy</code>.
|
|
267 *
|
|
268 * @param sourceViewer the source viewer to be configured by this configuration
|
|
269 * @param contentType the content type for which the strategy is applicable
|
|
270 * @return a double-click strategy or <code>null</code> if double clicking should not be supported
|
|
271 */
|
|
272 public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
|
|
273 return new DefaultTextDoubleClickStrategy();
|
|
274 }
|
|
275
|
|
276 /**
|
|
277 * Returns the prefixes to be used by the line-shift operation. This implementation
|
|
278 * always returns <code>new String[] { "\t", " ", "" }</code>.
|
|
279 * <p>
|
|
280 * <strong>Note:</strong> <em>This default is incorrect but cannot be changed in order not
|
|
281 * to break any existing clients. Subclasses should overwrite this method and
|
|
282 * use {@link #getIndentPrefixesForTab(int)} if applicable.</em>
|
|
283 *
|
|
284 * @param sourceViewer the source viewer to be configured by this configuration
|
|
285 * @param contentType the content type for which the prefix is applicable
|
|
286 * @return the prefixes or <code>null</code> if the prefix operation should not be supported
|
|
287 */
|
|
288 public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
|
|
289 return new String[] { "\t", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
290 }
|
|
291
|
|
292 /**
|
|
293 * Computes and returns the indent prefixes for tab indentation
|
|
294 * which is represented as <code>tabSizeInSpaces</code>.
|
|
295 *
|
|
296 * @param tabWidth the display tab width
|
|
297 * @return the indent prefixes
|
|
298 * @see #getIndentPrefixes(ISourceViewer, String)
|
|
299 * @since 3.3
|
|
300 */
|
|
301 protected String[] getIndentPrefixesForTab(int tabWidth) {
|
|
302 String[] indentPrefixes= new String[tabWidth + 2];
|
|
303 for (int i= 0; i <= tabWidth; i++) {
|
|
304 char[] spaceChars= new char[i];
|
|
305 Arrays.fill(spaceChars, ' ');
|
|
306 String spaces= new String(spaceChars);
|
|
307 if (i < tabWidth)
|
|
308 indentPrefixes[i]= spaces + '\t';
|
|
309 else
|
|
310 indentPrefixes[i]= new String(spaces);
|
|
311 }
|
|
312 indentPrefixes[tabWidth + 1]= ""; //$NON-NLS-1$
|
|
313 return indentPrefixes;
|
|
314 }
|
|
315
|
|
316 /**
|
|
317 * Returns the annotation hover which will provide the information to be
|
|
318 * shown in a hover popup window when requested for the given
|
|
319 * source viewer. This implementation always returns <code>null</code>.
|
|
320 *
|
|
321 * @param sourceViewer the source viewer to be configured by this configuration
|
|
322 * @return an annotation hover or <code>null</code> if no hover support should be installed
|
|
323 */
|
|
324 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
|
325 return null;
|
|
326 }
|
|
327
|
|
328 /**
|
|
329 * Returns the annotation hover which will provide the information to be
|
|
330 * shown in a hover popup window when requested for the overview ruler
|
|
331 * of the given source viewer.This implementation always returns the general
|
|
332 * annotation hover returned by <code>getAnnotationHover</code>.
|
|
333 *
|
|
334 * @param sourceViewer the source viewer to be configured by this configuration
|
|
335 * @return an annotation hover or <code>null</code> if no hover support should be installed
|
|
336 * @since 3.0
|
|
337 */
|
|
338 public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
|
|
339 return getAnnotationHover(sourceViewer);
|
|
340 }
|
|
341
|
|
342 /**
|
|
343 * Returns the DWT event state masks for which text hover are configured for
|
|
344 * the given content type.
|
|
345 *
|
|
346 * @param sourceViewer the source viewer to be configured by this configuration
|
|
347 * @param contentType the content type
|
|
348 * @return an <code>int</code> array with the configured DWT event state masks
|
|
349 * or <code>null</code> if text hovers are not supported for the given content type
|
|
350 * @since 2.1
|
|
351 */
|
|
352 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
|
|
353 return null;
|
|
354 }
|
|
355
|
|
356 /**
|
|
357 * Returns the text hover which will provide the information to be shown
|
|
358 * in a text hover popup window when requested for the given source viewer and
|
|
359 * the given content type. This implementation always returns <code>
|
|
360 * null</code>.
|
|
361 *
|
|
362 * @param sourceViewer the source viewer to be configured by this configuration
|
|
363 * @param contentType the content type
|
|
364 * @param stateMask the DWT event state mask
|
|
365 * @return a text hover or <code>null</code> if no hover support should be installed
|
|
366 * @since 2.1
|
|
367 */
|
|
368 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
|
|
369 if (stateMask is ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK)
|
|
370 return getTextHover(sourceViewer, contentType);
|
|
371 return null;
|
|
372 }
|
|
373
|
|
374 /**
|
|
375 * Returns the text hover which will provide the information to be shown
|
|
376 * in a text hover popup window when requested for the given source viewer and
|
|
377 * the given content type. This implementation always returns <code>
|
|
378 * null</code>.
|
|
379 *
|
|
380 * @param sourceViewer the source viewer to be configured by this configuration
|
|
381 * @param contentType the content type
|
|
382 * @return a text hover or <code>null</code> if no hover support should be installed
|
|
383 */
|
|
384 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
|
|
385 return null;
|
|
386 }
|
|
387
|
|
388 /**
|
|
389 * Returns the information control creator. The creator is a factory creating information
|
|
390 * controls for the given source viewer. This implementation always returns a creator for
|
|
391 * <code>DefaultInformationControl</code> instances.
|
|
392 *
|
|
393 * @param sourceViewer the source viewer to be configured by this configuration
|
|
394 * @return the information control creator or <code>null</code> if no information support should be installed
|
|
395 * @since 2.0
|
|
396 */
|
|
397 public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
|
|
398 return new IInformationControlCreator() {
|
|
399 public IInformationControl createInformationControl(Shell parent) {
|
|
400 return new DefaultInformationControl(parent);
|
|
401 }
|
|
402 };
|
|
403 }
|
|
404
|
|
405 /**
|
|
406 * Returns the information presenter which will determine and shown
|
|
407 * information requested for the current cursor position. This implementation
|
|
408 * always returns <code>null</code>.
|
|
409 *
|
|
410 * @param sourceViewer the source viewer to be configured by this configuration
|
|
411 * @return an information presenter <code>null</code> if no information presenter should be installed
|
|
412 * @since 2.0
|
|
413 */
|
|
414 public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
|
|
415 return null;
|
|
416 }
|
|
417
|
|
418 /**
|
|
419 * Returns all configured content types for the given source viewer. This list
|
|
420 * tells the caller which content types must be configured for the given source
|
|
421 * viewer, i.e. for which content types the given source viewer's functionalities
|
|
422 * must be specified. This implementation always returns <code>
|
|
423 * new String[] { IDocument.DEFAULT_CONTENT_TYPE }</code>.
|
|
424 *
|
|
425 * @param sourceViewer the source viewer to be configured by this configuration
|
|
426 * @return the configured content types for the given viewer
|
|
427 */
|
|
428 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
|
|
429 return new String[] { IDocument.DEFAULT_CONTENT_TYPE };
|
|
430 }
|
|
431
|
|
432 /**
|
|
433 * Returns the configured partitioning for the given source viewer. The partitioning is
|
|
434 * used when the querying content types from the source viewer's input document. This
|
|
435 * implementation always returns <code>IDocumentExtension3.DEFAULT_PARTITIONING</code>.
|
|
436 *
|
|
437 * @param sourceViewer the source viewer to be configured by this configuration
|
|
438 * @return the configured partitioning
|
|
439 * @see #getConfiguredContentTypes(ISourceViewer)
|
|
440 * @since 3.0
|
|
441 */
|
|
442 public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
|
|
443 return IDocumentExtension3.DEFAULT_PARTITIONING;
|
|
444 }
|
|
445
|
|
446 /**
|
|
447 * Returns the hyperlink detectors which be used to detect hyperlinks
|
|
448 * in the given source viewer. This
|
|
449 * implementation always returns an array with an URL hyperlink detector.
|
|
450 *
|
|
451 * @param sourceViewer the source viewer to be configured by this configuration
|
|
452 * @return an array with hyperlink detectors or <code>null</code> if no hyperlink support should be installed
|
|
453 * @since 3.1
|
|
454 */
|
|
455 public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
|
|
456 if (sourceViewer is null)
|
|
457 return null;
|
|
458
|
|
459 return new IHyperlinkDetector[] { new URLHyperlinkDetector() };
|
|
460 }
|
|
461
|
|
462 /**
|
|
463 * Returns the hyperlink presenter for the given source viewer.
|
|
464 * This implementation always returns the {@link DefaultHyperlinkPresenter}.
|
|
465 *
|
|
466 * @param sourceViewer the source viewer to be configured by this configuration
|
|
467 * @return the hyperlink presenter or <code>null</code> if no hyperlink support should be installed
|
|
468 * @since 3.1
|
|
469 */
|
|
470 public IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer) {
|
|
471 return new DefaultHyperlinkPresenter(new RGB(0, 0, 255));
|
|
472 }
|
|
473
|
|
474 /**
|
|
475 * Returns the DWT event state mask which in combination
|
|
476 * with the left mouse button activates hyperlinking.
|
|
477 * This implementation always returns the {@link DWT#MOD1}.
|
|
478 *
|
|
479 * @param sourceViewer the source viewer to be configured by this configuration
|
|
480 * @return the DWT event state mask to activate hyperlink mode
|
|
481 * @since 3.1
|
|
482 */
|
|
483 public int getHyperlinkStateMask(ISourceViewer sourceViewer) {
|
|
484 return DWT.MOD1;
|
|
485 }
|
|
486 }
|