Mercurial > projects > dwt-addons
annotate dwtx/jface/text/TextViewerHoverManager.d @ 156:a9566845f1cb
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 25 Aug 2008 19:03:46 +0200 |
parents | 75302ef3f92f |
children | 7926b636c282 |
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.TextViewerHoverManager; | |
14 | |
131 | 15 import dwtx.jface.text.IDocumentPartitioningListener; // packageimport |
16 import dwtx.jface.text.DefaultTextHover; // packageimport | |
17 import dwtx.jface.text.AbstractInformationControl; // packageimport | |
18 import dwtx.jface.text.TextUtilities; // packageimport | |
19 import dwtx.jface.text.IInformationControlCreatorExtension; // packageimport | |
20 import dwtx.jface.text.AbstractInformationControlManager; // packageimport | |
21 import dwtx.jface.text.ITextViewerExtension2; // packageimport | |
22 import dwtx.jface.text.IDocumentPartitioner; // packageimport | |
23 import dwtx.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport | |
24 import dwtx.jface.text.ITextSelection; // packageimport | |
25 import dwtx.jface.text.Document; // packageimport | |
26 import dwtx.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport | |
27 import dwtx.jface.text.ITextListener; // packageimport | |
28 import dwtx.jface.text.BadPartitioningException; // packageimport | |
29 import dwtx.jface.text.ITextViewerExtension5; // packageimport | |
30 import dwtx.jface.text.IDocumentPartitionerExtension3; // packageimport | |
31 import dwtx.jface.text.IUndoManager; // packageimport | |
32 import dwtx.jface.text.ITextHoverExtension2; // packageimport | |
33 import dwtx.jface.text.IRepairableDocument; // packageimport | |
34 import dwtx.jface.text.IRewriteTarget; // packageimport | |
35 import dwtx.jface.text.DefaultPositionUpdater; // packageimport | |
36 import dwtx.jface.text.RewriteSessionEditProcessor; // packageimport | |
37 import dwtx.jface.text.DocumentRewriteSession; // packageimport | |
38 import dwtx.jface.text.TextViewer; // packageimport | |
39 import dwtx.jface.text.ITextViewerExtension8; // packageimport | |
40 import dwtx.jface.text.RegExMessages; // packageimport | |
41 import dwtx.jface.text.IDelayedInputChangeProvider; // packageimport | |
42 import dwtx.jface.text.ITextOperationTargetExtension; // packageimport | |
43 import dwtx.jface.text.IWidgetTokenOwner; // packageimport | |
44 import dwtx.jface.text.IViewportListener; // packageimport | |
45 import dwtx.jface.text.GapTextStore; // packageimport | |
46 import dwtx.jface.text.MarkSelection; // packageimport | |
47 import dwtx.jface.text.IDocumentPartitioningListenerExtension; // packageimport | |
48 import dwtx.jface.text.IDocumentAdapterExtension; // packageimport | |
49 import dwtx.jface.text.IInformationControlExtension; // packageimport | |
50 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; // packageimport | |
51 import dwtx.jface.text.DefaultDocumentAdapter; // packageimport | |
52 import dwtx.jface.text.ITextViewerExtension3; // packageimport | |
53 import dwtx.jface.text.IInformationControlCreator; // packageimport | |
54 import dwtx.jface.text.TypedRegion; // packageimport | |
55 import dwtx.jface.text.ISynchronizable; // packageimport | |
56 import dwtx.jface.text.IMarkRegionTarget; // packageimport | |
57 import dwtx.jface.text.TextViewerUndoManager; // packageimport | |
58 import dwtx.jface.text.IRegion; // packageimport | |
59 import dwtx.jface.text.IInformationControlExtension2; // packageimport | |
60 import dwtx.jface.text.IDocumentExtension4; // packageimport | |
61 import dwtx.jface.text.IDocumentExtension2; // packageimport | |
62 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport | |
63 import dwtx.jface.text.Assert; // packageimport | |
64 import dwtx.jface.text.DefaultInformationControl; // packageimport | |
65 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport | |
66 import dwtx.jface.text.DocumentClone; // packageimport | |
67 import dwtx.jface.text.DefaultUndoManager; // packageimport | |
68 import dwtx.jface.text.IFindReplaceTarget; // packageimport | |
69 import dwtx.jface.text.IAutoEditStrategy; // packageimport | |
70 import dwtx.jface.text.ILineTrackerExtension; // packageimport | |
71 import dwtx.jface.text.IUndoManagerExtension; // packageimport | |
72 import dwtx.jface.text.TextSelection; // packageimport | |
73 import dwtx.jface.text.DefaultAutoIndentStrategy; // packageimport | |
74 import dwtx.jface.text.IAutoIndentStrategy; // packageimport | |
75 import dwtx.jface.text.IPainter; // packageimport | |
76 import dwtx.jface.text.IInformationControl; // packageimport | |
77 import dwtx.jface.text.IInformationControlExtension3; // packageimport | |
78 import dwtx.jface.text.ITextViewerExtension6; // packageimport | |
79 import dwtx.jface.text.IInformationControlExtension4; // packageimport | |
80 import dwtx.jface.text.DefaultLineTracker; // packageimport | |
81 import dwtx.jface.text.IDocumentInformationMappingExtension; // packageimport | |
82 import dwtx.jface.text.IRepairableDocumentExtension; // packageimport | |
83 import dwtx.jface.text.ITextHover; // packageimport | |
84 import dwtx.jface.text.FindReplaceDocumentAdapter; // packageimport | |
85 import dwtx.jface.text.ILineTracker; // packageimport | |
86 import dwtx.jface.text.Line; // packageimport | |
87 import dwtx.jface.text.ITextViewerExtension; // packageimport | |
88 import dwtx.jface.text.IDocumentAdapter; // packageimport | |
89 import dwtx.jface.text.TextEvent; // packageimport | |
90 import dwtx.jface.text.BadLocationException; // packageimport | |
91 import dwtx.jface.text.AbstractDocument; // packageimport | |
92 import dwtx.jface.text.AbstractLineTracker; // packageimport | |
93 import dwtx.jface.text.TreeLineTracker; // packageimport | |
94 import dwtx.jface.text.ITextPresentationListener; // packageimport | |
95 import dwtx.jface.text.Region; // packageimport | |
96 import dwtx.jface.text.ITextViewer; // packageimport | |
97 import dwtx.jface.text.IDocumentInformationMapping; // packageimport | |
98 import dwtx.jface.text.MarginPainter; // packageimport | |
99 import dwtx.jface.text.IPaintPositionManager; // packageimport | |
100 import dwtx.jface.text.TextPresentation; // packageimport | |
101 import dwtx.jface.text.IFindReplaceTargetExtension; // packageimport | |
102 import dwtx.jface.text.ISlaveDocumentManagerExtension; // packageimport | |
103 import dwtx.jface.text.ISelectionValidator; // packageimport | |
104 import dwtx.jface.text.IDocumentExtension; // packageimport | |
105 import dwtx.jface.text.PropagatingFontFieldEditor; // packageimport | |
106 import dwtx.jface.text.ConfigurableLineTracker; // packageimport | |
107 import dwtx.jface.text.SlaveDocumentEvent; // packageimport | |
108 import dwtx.jface.text.IDocumentListener; // packageimport | |
109 import dwtx.jface.text.PaintManager; // packageimport | |
110 import dwtx.jface.text.IFindReplaceTargetExtension3; // packageimport | |
111 import dwtx.jface.text.ITextDoubleClickStrategy; // packageimport | |
112 import dwtx.jface.text.IDocumentExtension3; // packageimport | |
113 import dwtx.jface.text.Position; // packageimport | |
114 import dwtx.jface.text.TextMessages; // packageimport | |
115 import dwtx.jface.text.CopyOnWriteTextStore; // packageimport | |
116 import dwtx.jface.text.WhitespaceCharacterPainter; // packageimport | |
117 import dwtx.jface.text.IPositionUpdater; // packageimport | |
118 import dwtx.jface.text.DefaultTextDoubleClickStrategy; // packageimport | |
119 import dwtx.jface.text.ListLineTracker; // packageimport | |
120 import dwtx.jface.text.ITextInputListener; // packageimport | |
121 import dwtx.jface.text.BadPositionCategoryException; // packageimport | |
122 import dwtx.jface.text.IWidgetTokenKeeperExtension; // packageimport | |
123 import dwtx.jface.text.IInputChangedListener; // packageimport | |
124 import dwtx.jface.text.ITextOperationTarget; // packageimport | |
125 import dwtx.jface.text.IDocumentInformationMappingExtension2; // packageimport | |
126 import dwtx.jface.text.ITextViewerExtension7; // packageimport | |
127 import dwtx.jface.text.IInformationControlExtension5; // packageimport | |
128 import dwtx.jface.text.IDocumentRewriteSessionListener; // packageimport | |
129 import dwtx.jface.text.JFaceTextUtil; // packageimport | |
130 import dwtx.jface.text.AbstractReusableInformationControlCreator; // packageimport | |
131 import dwtx.jface.text.TabsToSpacesConverter; // packageimport | |
132 import dwtx.jface.text.CursorLinePainter; // packageimport | |
133 import dwtx.jface.text.ITextHoverExtension; // packageimport | |
134 import dwtx.jface.text.IEventConsumer; // packageimport | |
135 import dwtx.jface.text.IDocument; // packageimport | |
136 import dwtx.jface.text.IWidgetTokenKeeper; // packageimport | |
137 import dwtx.jface.text.DocumentCommand; // packageimport | |
138 import dwtx.jface.text.TypedPosition; // packageimport | |
139 import dwtx.jface.text.IEditingSupportRegistry; // packageimport | |
140 import dwtx.jface.text.IDocumentPartitionerExtension; // packageimport | |
141 import dwtx.jface.text.AbstractHoverInformationControlManager; // packageimport | |
142 import dwtx.jface.text.IEditingSupport; // packageimport | |
143 import dwtx.jface.text.IMarkSelection; // packageimport | |
144 import dwtx.jface.text.ISlaveDocumentManager; // packageimport | |
145 import dwtx.jface.text.DocumentEvent; // packageimport | |
146 import dwtx.jface.text.DocumentPartitioningChangedEvent; // packageimport | |
147 import dwtx.jface.text.ITextStore; // packageimport | |
148 import dwtx.jface.text.JFaceTextMessages; // packageimport | |
149 import dwtx.jface.text.DocumentRewriteSessionEvent; // packageimport | |
150 import dwtx.jface.text.SequentialRewriteTextStore; // packageimport | |
151 import dwtx.jface.text.DocumentRewriteSessionType; // packageimport | |
152 import dwtx.jface.text.TextAttribute; // packageimport | |
153 import dwtx.jface.text.ITextViewerExtension4; // packageimport | |
154 import dwtx.jface.text.ITypedRegion; // packageimport | |
155 | |
156 | |
129 | 157 import dwt.dwthelper.utils; |
158 | |
159 | |
160 | |
161 | |
162 import dwt.custom.StyledText; | |
163 import dwt.events.MouseEvent; | |
164 import dwt.events.MouseMoveListener; | |
165 import dwt.graphics.Point; | |
166 import dwt.graphics.Rectangle; | |
167 import dwt.widgets.Display; | |
168 import dwtx.core.runtime.ILog; | |
169 import dwtx.core.runtime.IStatus; | |
170 import dwtx.core.runtime.Platform; | |
171 import dwtx.core.runtime.Status; | |
172 | |
173 | |
174 /** | |
175 * This manager controls the layout, content, and visibility of an information | |
176 * control in reaction to mouse hover events issued by the text widget of a | |
177 * text viewer. It overrides <code>computeInformation</code>, so that the | |
178 * computation is performed in a dedicated background thread. This implies | |
179 * that the used <code>ITextHover</code> objects must be capable of | |
180 * operating in a non-UI thread. | |
181 * | |
182 * @since 2.0 | |
183 */ | |
184 class TextViewerHoverManager : AbstractHoverInformationControlManager , IWidgetTokenKeeper, IWidgetTokenKeeperExtension { | |
185 | |
186 | |
187 /** | |
188 * Priority of the hovers managed by this manager. | |
189 * Default value: <code>0</code>; | |
190 * @since 3.0 | |
191 */ | |
146 | 192 public const static int WIDGET_PRIORITY= 0; |
129 | 193 |
194 | |
195 /** The text viewer */ | |
196 private TextViewer fTextViewer; | |
197 /** The hover information computation thread */ | |
198 private Thread fThread; | |
199 /** The stopper of the computation thread */ | |
200 private ITextListener fStopper; | |
201 /** Internal monitor */ | |
202 private Object fMutex= new Object(); | |
203 /** The currently shown text hover. */ | |
156 | 204 private /+volatile+/ ITextHover fTextHover; |
129 | 205 /** |
206 * Tells whether the next mouse hover event | |
207 * should be processed. | |
208 * @since 3.0 | |
209 */ | |
210 private bool fProcessMouseHoverEvent= true; | |
211 /** | |
212 * Internal mouse move listener. | |
213 * @since 3.0 | |
214 */ | |
215 private MouseMoveListener fMouseMoveListener; | |
216 /** | |
217 * Internal view port listener. | |
218 * @since 3.0 | |
219 */ | |
220 private IViewportListener fViewportListener; | |
221 | |
222 | |
223 /** | |
224 * Creates a new text viewer hover manager specific for the given text viewer. | |
225 * The manager uses the given information control creator. | |
226 * | |
227 * @param textViewer the viewer for which the controller is created | |
228 * @param creator the information control creator | |
229 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
230 public this(TextViewer textViewer, IInformationControlCreator creator) { |
129 | 231 super(creator); |
232 fTextViewer= textViewer; | |
135 | 233 fStopper= new class() ITextListener { |
129 | 234 public void textChanged(TextEvent event) { |
235 synchronized (fMutex) { | |
236 if (fThread !is null) { | |
237 fThread.interrupt(); | |
238 fThread= null; | |
239 } | |
240 } | |
241 } | |
242 }; | |
135 | 243 fViewportListener= new class() IViewportListener { |
129 | 244 /* |
245 * @see dwtx.jface.text.IViewportListener#viewportChanged(int) | |
246 */ | |
247 public void viewportChanged(int verticalOffset) { | |
248 fProcessMouseHoverEvent= false; | |
249 } | |
250 }; | |
251 fTextViewer.addViewportListener(fViewportListener); | |
135 | 252 fMouseMoveListener= new class() MouseMoveListener { |
129 | 253 /* |
254 * @see MouseMoveListener#mouseMove(MouseEvent) | |
255 */ | |
256 public void mouseMove(MouseEvent event) { | |
257 fProcessMouseHoverEvent= true; | |
258 } | |
259 }; | |
260 fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener); | |
261 } | |
262 | |
263 /** | |
264 * Determines all necessary details and delegates the computation into | |
265 * a background thread. | |
266 */ | |
267 protected void computeInformation() { | |
268 | |
269 if (!fProcessMouseHoverEvent) { | |
270 setInformation(null, null); | |
271 return; | |
272 } | |
273 | |
274 Point location= getHoverEventLocation(); | |
275 int offset= computeOffsetAtLocation(location.x, location.y); | |
276 if (offset is -1) { | |
277 setInformation(null, null); | |
278 return; | |
279 } | |
280 | |
281 final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask()); | |
282 if (hover is null) { | |
283 setInformation(null, null); | |
284 return; | |
285 } | |
286 | |
287 final IRegion region= hover.getHoverRegion(fTextViewer, offset); | |
288 if (region is null) { | |
289 setInformation(null, null); | |
290 return; | |
291 } | |
292 | |
293 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | |
294 if (area is null || area.isEmpty()) { | |
295 setInformation(null, null); | |
296 return; | |
297 } | |
298 | |
299 if (fThread !is null) { | |
300 setInformation(null, null); | |
301 return; | |
302 } | |
303 | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
304 void threadrun() { |
129 | 305 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 |
306 bool hasFinished= false; | |
307 try { | |
308 if (fThread !is null) { | |
309 Object information; | |
310 try { | |
138 | 311 if ( cast(ITextHoverExtension2)hover ) |
134 | 312 information= (cast(ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region); |
129 | 313 else |
314 information= hover.getHoverInfo(fTextViewer, region); | |
315 } catch (ArrayIndexOutOfBoundsException x) { | |
316 /* | |
317 * This code runs in a separate thread which can | |
318 * lead to text offsets being out of bounds when | |
319 * computing the hover info (see bug 32848). | |
320 */ | |
321 information= null; | |
322 } | |
323 | |
138 | 324 if ( cast(ITextHoverExtension)hover ) |
134 | 325 setCustomInformationControlCreator((cast(ITextHoverExtension) hover).getHoverControlCreator()); |
129 | 326 else |
327 setCustomInformationControlCreator(null); | |
328 | |
329 setInformation(information, area); | |
330 if (information !is null) | |
331 fTextHover= hover; | |
332 } else { | |
333 setInformation(null, null); | |
334 } | |
335 hasFinished= true; | |
336 } catch (RuntimeException ex) { | |
337 String PLUGIN_ID= "dwtx.jface.text"; //$NON-NLS-1$ | |
338 ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); | |
339 log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Unexpected runtime error while computing a text hover", ex)); //$NON-NLS-1$ | |
340 } finally { | |
341 synchronized (fMutex) { | |
342 if (fTextViewer !is null) | |
343 fTextViewer.removeTextListener(fStopper); | |
344 fThread= null; | |
345 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756 | |
346 if (!hasFinished) | |
347 setInformation(null, null); | |
348 } | |
349 } | |
350 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
351 fThread= new Thread( &threadrun ); |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
352 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ |
129 | 353 |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
354 fThread.isDaemon(true); |
129 | 355 fThread.setPriority(Thread.MIN_PRIORITY); |
356 synchronized (fMutex) { | |
357 fTextViewer.addTextListener(fStopper); | |
358 fThread.start(); | |
359 } | |
360 } | |
361 | |
362 /** | |
363 * As computation is done in the background, this method is | |
364 * also called in the background thread. Delegates the control | |
365 * flow back into the UI thread, in order to allow displaying the | |
366 * information in the information control. | |
367 */ | |
368 protected void presentInformation() { | |
369 if (fTextViewer is null) | |
370 return; | |
371 | |
372 StyledText textWidget= fTextViewer.getTextWidget(); | |
373 if (textWidget !is null && !textWidget.isDisposed()) { | |
374 Display display= textWidget.getDisplay(); | |
375 if (display is null) | |
376 return; | |
377 | |
135 | 378 display.asyncExec(new class() Runnable { |
129 | 379 public void run() { |
380 doPresentInformation(); | |
381 } | |
382 }); | |
383 } | |
384 } | |
385 | |
386 /* | |
387 * @see AbstractInformationControlManager#presentInformation() | |
388 */ | |
389 protected void doPresentInformation() { | |
390 super.presentInformation(); | |
391 } | |
392 | |
393 /** | |
394 * Computes the document offset underlying the given text widget coordinates. | |
395 * This method uses a linear search as it cannot make any assumption about | |
396 * how the document is actually presented in the widget. (Covers cases such | |
397 * as bidirectional text.) | |
398 * | |
399 * @param x the horizontal coordinate inside the text widget | |
400 * @param y the vertical coordinate inside the text widget | |
401 * @return the document offset corresponding to the given point | |
402 */ | |
403 private int computeOffsetAtLocation(int x, int y) { | |
404 | |
405 try { | |
406 | |
407 StyledText styledText= fTextViewer.getTextWidget(); | |
408 int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y)); | |
409 Point p= styledText.getLocationAtOffset(widgetOffset); | |
410 if (p.x > x) | |
411 widgetOffset--; | |
412 | |
138 | 413 if ( cast(ITextViewerExtension5)fTextViewer ) { |
134 | 414 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fTextViewer; |
129 | 415 return extension.widgetOffset2ModelOffset(widgetOffset); |
416 } | |
417 | |
418 return widgetOffset + fTextViewer._getVisibleRegionOffset(); | |
419 | |
420 } catch (IllegalArgumentException e) { | |
421 return -1; | |
422 } | |
423 } | |
424 | |
425 /* | |
426 * @see dwtx.jface.text.AbstractInformationControlManager#showInformationControl(dwt.graphics.Rectangle) | |
427 */ | |
428 protected void showInformationControl(Rectangle subjectArea) { | |
429 if (fTextViewer !is null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY)) | |
430 super.showInformationControl(subjectArea); | |
431 else | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
432 if (DEBUG) |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
433 System.out_.println("TextViewerHoverManager#showInformationControl(..) did not get widget token"); //$NON-NLS-1$ |
129 | 434 } |
435 | |
436 /* | |
437 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() | |
438 */ | |
439 protected void hideInformationControl() { | |
440 try { | |
441 fTextHover= null; | |
442 super.hideInformationControl(); | |
443 } finally { | |
444 if (fTextViewer !is null) | |
445 fTextViewer.releaseWidgetToken(this); | |
446 } | |
447 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
448 |
129 | 449 /* |
450 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) | |
451 * @since 3.4 | |
452 */ | |
453 void replaceInformationControl(bool takeFocus) { | |
454 if (fTextViewer !is null) | |
455 fTextViewer.releaseWidgetToken(this); | |
456 super.replaceInformationControl(takeFocus); | |
457 } | |
458 | |
459 /* | |
460 * @see dwtx.jface.text.AbstractInformationControlManager#handleInformationControlDisposed() | |
461 */ | |
462 protected void handleInformationControlDisposed() { | |
463 try { | |
464 super.handleInformationControlDisposed(); | |
465 } finally { | |
466 if (fTextViewer !is null) | |
467 fTextViewer.releaseWidgetToken(this); | |
468 } | |
469 } | |
470 | |
471 /* | |
472 * @see dwtx.jface.text.IWidgetTokenKeeper#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner) | |
473 */ | |
474 public bool requestWidgetToken(IWidgetTokenOwner owner) { | |
475 fTextHover= null; | |
476 super.hideInformationControl(); | |
477 return true; | |
478 } | |
479 | |
480 /* | |
481 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner, int) | |
482 * @since 3.0 | |
483 */ | |
484 public bool requestWidgetToken(IWidgetTokenOwner owner, int priority) { | |
485 if (priority > WIDGET_PRIORITY) { | |
486 fTextHover= null; | |
487 super.hideInformationControl(); | |
488 return true; | |
489 } | |
490 return false; | |
491 } | |
492 | |
493 /* | |
494 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#setFocus(dwtx.jface.text.IWidgetTokenOwner) | |
495 * @since 3.0 | |
496 */ | |
497 public bool setFocus(IWidgetTokenOwner owner) { | |
498 if (! hasInformationControlReplacer()) | |
499 return false; | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
500 |
129 | 501 IInformationControl iControl= getCurrentInformationControl(); |
502 if (canReplace(iControl)) { | |
503 if (cancelReplacingDelay()) | |
504 replaceInformationControl(true); | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
505 |
129 | 506 return true; |
507 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
508 |
129 | 509 return false; |
510 } | |
511 | |
512 /** | |
513 * Returns the currently shown text hover or <code>null</code> if no text | |
514 * hover is shown. | |
515 * | |
516 * @return the currently shown text hover or <code>null</code> | |
517 */ | |
518 protected ITextHover getCurrentTextHover() { | |
519 return fTextHover; | |
520 } | |
521 | |
522 /* | |
523 * @see dwtx.jface.text.AbstractHoverInformationControlManager#dispose() | |
524 * @since 3.0 | |
525 */ | |
526 public void dispose() { | |
527 if (fTextViewer !is null) { | |
528 fTextViewer.removeViewportListener(fViewportListener); | |
529 fViewportListener= null; | |
530 | |
531 StyledText st= fTextViewer.getTextWidget(); | |
532 if (st !is null && !st.isDisposed()) | |
533 st.removeMouseMoveListener(fMouseMoveListener); | |
534 fMouseMoveListener= null; | |
535 } | |
536 super.dispose(); | |
537 } | |
538 } |