Mercurial > projects > dwt2
comparison org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | 52184e4b815c |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 org.eclipse.jface.text.TextViewerHoverManager; | |
14 | |
15 import org.eclipse.jface.text.IDocumentPartitioningListener; // packageimport | |
16 import org.eclipse.jface.text.DefaultTextHover; // packageimport | |
17 import org.eclipse.jface.text.AbstractInformationControl; // packageimport | |
18 import org.eclipse.jface.text.TextUtilities; // packageimport | |
19 import org.eclipse.jface.text.IInformationControlCreatorExtension; // packageimport | |
20 import org.eclipse.jface.text.AbstractInformationControlManager; // packageimport | |
21 import org.eclipse.jface.text.ITextViewerExtension2; // packageimport | |
22 import org.eclipse.jface.text.IDocumentPartitioner; // packageimport | |
23 import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport | |
24 import org.eclipse.jface.text.ITextSelection; // packageimport | |
25 import org.eclipse.jface.text.Document; // packageimport | |
26 import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport | |
27 import org.eclipse.jface.text.ITextListener; // packageimport | |
28 import org.eclipse.jface.text.BadPartitioningException; // packageimport | |
29 import org.eclipse.jface.text.ITextViewerExtension5; // packageimport | |
30 import org.eclipse.jface.text.IDocumentPartitionerExtension3; // packageimport | |
31 import org.eclipse.jface.text.IUndoManager; // packageimport | |
32 import org.eclipse.jface.text.ITextHoverExtension2; // packageimport | |
33 import org.eclipse.jface.text.IRepairableDocument; // packageimport | |
34 import org.eclipse.jface.text.IRewriteTarget; // packageimport | |
35 import org.eclipse.jface.text.DefaultPositionUpdater; // packageimport | |
36 import org.eclipse.jface.text.RewriteSessionEditProcessor; // packageimport | |
37 import org.eclipse.jface.text.DocumentRewriteSession; // packageimport | |
38 import org.eclipse.jface.text.TextViewer; // packageimport | |
39 import org.eclipse.jface.text.ITextViewerExtension8; // packageimport | |
40 import org.eclipse.jface.text.RegExMessages; // packageimport | |
41 import org.eclipse.jface.text.IDelayedInputChangeProvider; // packageimport | |
42 import org.eclipse.jface.text.ITextOperationTargetExtension; // packageimport | |
43 import org.eclipse.jface.text.IWidgetTokenOwner; // packageimport | |
44 import org.eclipse.jface.text.IViewportListener; // packageimport | |
45 import org.eclipse.jface.text.GapTextStore; // packageimport | |
46 import org.eclipse.jface.text.MarkSelection; // packageimport | |
47 import org.eclipse.jface.text.IDocumentPartitioningListenerExtension; // packageimport | |
48 import org.eclipse.jface.text.IDocumentAdapterExtension; // packageimport | |
49 import org.eclipse.jface.text.IInformationControlExtension; // packageimport | |
50 import org.eclipse.jface.text.IDocumentPartitioningListenerExtension2; // packageimport | |
51 import org.eclipse.jface.text.DefaultDocumentAdapter; // packageimport | |
52 import org.eclipse.jface.text.ITextViewerExtension3; // packageimport | |
53 import org.eclipse.jface.text.IInformationControlCreator; // packageimport | |
54 import org.eclipse.jface.text.TypedRegion; // packageimport | |
55 import org.eclipse.jface.text.ISynchronizable; // packageimport | |
56 import org.eclipse.jface.text.IMarkRegionTarget; // packageimport | |
57 import org.eclipse.jface.text.TextViewerUndoManager; // packageimport | |
58 import org.eclipse.jface.text.IRegion; // packageimport | |
59 import org.eclipse.jface.text.IInformationControlExtension2; // packageimport | |
60 import org.eclipse.jface.text.IDocumentExtension4; // packageimport | |
61 import org.eclipse.jface.text.IDocumentExtension2; // packageimport | |
62 import org.eclipse.jface.text.IDocumentPartitionerExtension2; // packageimport | |
63 import org.eclipse.jface.text.Assert; // packageimport | |
64 import org.eclipse.jface.text.DefaultInformationControl; // packageimport | |
65 import org.eclipse.jface.text.IWidgetTokenOwnerExtension; // packageimport | |
66 import org.eclipse.jface.text.DocumentClone; // packageimport | |
67 import org.eclipse.jface.text.DefaultUndoManager; // packageimport | |
68 import org.eclipse.jface.text.IFindReplaceTarget; // packageimport | |
69 import org.eclipse.jface.text.IAutoEditStrategy; // packageimport | |
70 import org.eclipse.jface.text.ILineTrackerExtension; // packageimport | |
71 import org.eclipse.jface.text.IUndoManagerExtension; // packageimport | |
72 import org.eclipse.jface.text.TextSelection; // packageimport | |
73 import org.eclipse.jface.text.DefaultAutoIndentStrategy; // packageimport | |
74 import org.eclipse.jface.text.IAutoIndentStrategy; // packageimport | |
75 import org.eclipse.jface.text.IPainter; // packageimport | |
76 import org.eclipse.jface.text.IInformationControl; // packageimport | |
77 import org.eclipse.jface.text.IInformationControlExtension3; // packageimport | |
78 import org.eclipse.jface.text.ITextViewerExtension6; // packageimport | |
79 import org.eclipse.jface.text.IInformationControlExtension4; // packageimport | |
80 import org.eclipse.jface.text.DefaultLineTracker; // packageimport | |
81 import org.eclipse.jface.text.IDocumentInformationMappingExtension; // packageimport | |
82 import org.eclipse.jface.text.IRepairableDocumentExtension; // packageimport | |
83 import org.eclipse.jface.text.ITextHover; // packageimport | |
84 import org.eclipse.jface.text.FindReplaceDocumentAdapter; // packageimport | |
85 import org.eclipse.jface.text.ILineTracker; // packageimport | |
86 import org.eclipse.jface.text.Line; // packageimport | |
87 import org.eclipse.jface.text.ITextViewerExtension; // packageimport | |
88 import org.eclipse.jface.text.IDocumentAdapter; // packageimport | |
89 import org.eclipse.jface.text.TextEvent; // packageimport | |
90 import org.eclipse.jface.text.BadLocationException; // packageimport | |
91 import org.eclipse.jface.text.AbstractDocument; // packageimport | |
92 import org.eclipse.jface.text.AbstractLineTracker; // packageimport | |
93 import org.eclipse.jface.text.TreeLineTracker; // packageimport | |
94 import org.eclipse.jface.text.ITextPresentationListener; // packageimport | |
95 import org.eclipse.jface.text.Region; // packageimport | |
96 import org.eclipse.jface.text.ITextViewer; // packageimport | |
97 import org.eclipse.jface.text.IDocumentInformationMapping; // packageimport | |
98 import org.eclipse.jface.text.MarginPainter; // packageimport | |
99 import org.eclipse.jface.text.IPaintPositionManager; // packageimport | |
100 import org.eclipse.jface.text.TextPresentation; // packageimport | |
101 import org.eclipse.jface.text.IFindReplaceTargetExtension; // packageimport | |
102 import org.eclipse.jface.text.ISlaveDocumentManagerExtension; // packageimport | |
103 import org.eclipse.jface.text.ISelectionValidator; // packageimport | |
104 import org.eclipse.jface.text.IDocumentExtension; // packageimport | |
105 import org.eclipse.jface.text.PropagatingFontFieldEditor; // packageimport | |
106 import org.eclipse.jface.text.ConfigurableLineTracker; // packageimport | |
107 import org.eclipse.jface.text.SlaveDocumentEvent; // packageimport | |
108 import org.eclipse.jface.text.IDocumentListener; // packageimport | |
109 import org.eclipse.jface.text.PaintManager; // packageimport | |
110 import org.eclipse.jface.text.IFindReplaceTargetExtension3; // packageimport | |
111 import org.eclipse.jface.text.ITextDoubleClickStrategy; // packageimport | |
112 import org.eclipse.jface.text.IDocumentExtension3; // packageimport | |
113 import org.eclipse.jface.text.Position; // packageimport | |
114 import org.eclipse.jface.text.TextMessages; // packageimport | |
115 import org.eclipse.jface.text.CopyOnWriteTextStore; // packageimport | |
116 import org.eclipse.jface.text.WhitespaceCharacterPainter; // packageimport | |
117 import org.eclipse.jface.text.IPositionUpdater; // packageimport | |
118 import org.eclipse.jface.text.DefaultTextDoubleClickStrategy; // packageimport | |
119 import org.eclipse.jface.text.ListLineTracker; // packageimport | |
120 import org.eclipse.jface.text.ITextInputListener; // packageimport | |
121 import org.eclipse.jface.text.BadPositionCategoryException; // packageimport | |
122 import org.eclipse.jface.text.IWidgetTokenKeeperExtension; // packageimport | |
123 import org.eclipse.jface.text.IInputChangedListener; // packageimport | |
124 import org.eclipse.jface.text.ITextOperationTarget; // packageimport | |
125 import org.eclipse.jface.text.IDocumentInformationMappingExtension2; // packageimport | |
126 import org.eclipse.jface.text.ITextViewerExtension7; // packageimport | |
127 import org.eclipse.jface.text.IInformationControlExtension5; // packageimport | |
128 import org.eclipse.jface.text.IDocumentRewriteSessionListener; // packageimport | |
129 import org.eclipse.jface.text.JFaceTextUtil; // packageimport | |
130 import org.eclipse.jface.text.AbstractReusableInformationControlCreator; // packageimport | |
131 import org.eclipse.jface.text.TabsToSpacesConverter; // packageimport | |
132 import org.eclipse.jface.text.CursorLinePainter; // packageimport | |
133 import org.eclipse.jface.text.ITextHoverExtension; // packageimport | |
134 import org.eclipse.jface.text.IEventConsumer; // packageimport | |
135 import org.eclipse.jface.text.IDocument; // packageimport | |
136 import org.eclipse.jface.text.IWidgetTokenKeeper; // packageimport | |
137 import org.eclipse.jface.text.DocumentCommand; // packageimport | |
138 import org.eclipse.jface.text.TypedPosition; // packageimport | |
139 import org.eclipse.jface.text.IEditingSupportRegistry; // packageimport | |
140 import org.eclipse.jface.text.IDocumentPartitionerExtension; // packageimport | |
141 import org.eclipse.jface.text.AbstractHoverInformationControlManager; // packageimport | |
142 import org.eclipse.jface.text.IEditingSupport; // packageimport | |
143 import org.eclipse.jface.text.IMarkSelection; // packageimport | |
144 import org.eclipse.jface.text.ISlaveDocumentManager; // packageimport | |
145 import org.eclipse.jface.text.DocumentEvent; // packageimport | |
146 import org.eclipse.jface.text.DocumentPartitioningChangedEvent; // packageimport | |
147 import org.eclipse.jface.text.ITextStore; // packageimport | |
148 import org.eclipse.jface.text.JFaceTextMessages; // packageimport | |
149 import org.eclipse.jface.text.DocumentRewriteSessionEvent; // packageimport | |
150 import org.eclipse.jface.text.SequentialRewriteTextStore; // packageimport | |
151 import org.eclipse.jface.text.DocumentRewriteSessionType; // packageimport | |
152 import org.eclipse.jface.text.TextAttribute; // packageimport | |
153 import org.eclipse.jface.text.ITextViewerExtension4; // packageimport | |
154 import org.eclipse.jface.text.ITypedRegion; // packageimport | |
155 | |
156 import java.lang.all; | |
157 import java.util.Set; | |
158 import java.lang.JThread; | |
159 | |
160 import org.eclipse.swt.custom.StyledText; | |
161 import org.eclipse.swt.events.MouseEvent; | |
162 import org.eclipse.swt.events.MouseMoveListener; | |
163 import org.eclipse.swt.graphics.Point; | |
164 import org.eclipse.swt.graphics.Rectangle; | |
165 import org.eclipse.swt.widgets.Display; | |
166 import org.eclipse.core.runtime.ILog; | |
167 import org.eclipse.core.runtime.IStatus; | |
168 import org.eclipse.core.runtime.Platform; | |
169 import org.eclipse.core.runtime.Status; | |
170 | |
171 | |
172 /** | |
173 * This manager controls the layout, content, and visibility of an information | |
174 * control in reaction to mouse hover events issued by the text widget of a | |
175 * text viewer. It overrides <code>computeInformation</code>, so that the | |
176 * computation is performed in a dedicated background thread. This implies | |
177 * that the used <code>ITextHover</code> objects must be capable of | |
178 * operating in a non-UI thread. | |
179 * | |
180 * @since 2.0 | |
181 */ | |
182 class TextViewerHoverManager : AbstractHoverInformationControlManager , IWidgetTokenKeeper, IWidgetTokenKeeperExtension { | |
183 | |
184 | |
185 /** | |
186 * Priority of the hovers managed by this manager. | |
187 * Default value: <code>0</code>; | |
188 * @since 3.0 | |
189 */ | |
190 public const static int WIDGET_PRIORITY= 0; | |
191 | |
192 | |
193 /** The text viewer */ | |
194 private TextViewer fTextViewer; | |
195 /** The hover information computation thread */ | |
196 private JThread fThread; | |
197 /** The stopper of the computation thread */ | |
198 private ITextListener fStopper; | |
199 /** Internal monitor */ | |
200 private Object fMutex; | |
201 /** The currently shown text hover. */ | |
202 private /+volatile+/ ITextHover fTextHover; | |
203 /** | |
204 * Tells whether the next mouse hover event | |
205 * should be processed. | |
206 * @since 3.0 | |
207 */ | |
208 private bool fProcessMouseHoverEvent= true; | |
209 /** | |
210 * Internal mouse move listener. | |
211 * @since 3.0 | |
212 */ | |
213 private MouseMoveListener fMouseMoveListener; | |
214 /** | |
215 * Internal view port listener. | |
216 * @since 3.0 | |
217 */ | |
218 private IViewportListener fViewportListener; | |
219 | |
220 | |
221 /** | |
222 * Creates a new text viewer hover manager specific for the given text viewer. | |
223 * The manager uses the given information control creator. | |
224 * | |
225 * @param textViewer the viewer for which the controller is created | |
226 * @param creator the information control creator | |
227 */ | |
228 public this(TextViewer textViewer, IInformationControlCreator creator) { | |
229 fMutex= new Object(); | |
230 super(creator); | |
231 fTextViewer= textViewer; | |
232 fStopper= new class() ITextListener { | |
233 public void textChanged(TextEvent event) { | |
234 synchronized (fMutex) { | |
235 if (fThread !is null) { | |
236 implMissing(__FILE__,__LINE__); | |
237 // SWT FIXME: how to handle Thread.interrupt? | |
238 // fThread.interrupt(); | |
239 fThread= null; | |
240 } | |
241 } | |
242 } | |
243 }; | |
244 fViewportListener= new class() IViewportListener { | |
245 /* | |
246 * @see org.eclipse.jface.text.IViewportListener#viewportChanged(int) | |
247 */ | |
248 public void viewportChanged(int verticalOffset) { | |
249 fProcessMouseHoverEvent= false; | |
250 } | |
251 }; | |
252 fTextViewer.addViewportListener(fViewportListener); | |
253 fMouseMoveListener= new class() MouseMoveListener { | |
254 /* | |
255 * @see MouseMoveListener#mouseMove(MouseEvent) | |
256 */ | |
257 public void mouseMove(MouseEvent event) { | |
258 fProcessMouseHoverEvent= true; | |
259 } | |
260 }; | |
261 fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener); | |
262 } | |
263 | |
264 /** | |
265 * Determines all necessary details and delegates the computation into | |
266 * a background thread. | |
267 */ | |
268 protected void computeInformation() { | |
269 | |
270 if (!fProcessMouseHoverEvent) { | |
271 setInformation(cast(Object)null, null); | |
272 return; | |
273 } | |
274 | |
275 Point location= getHoverEventLocation(); | |
276 int offset= computeOffsetAtLocation(location.x, location.y); | |
277 if (offset is -1) { | |
278 setInformation(cast(Object)null, null); | |
279 return; | |
280 } | |
281 | |
282 ITextHover hover= fTextViewer.getTextHover_package(offset, getHoverEventStateMask()); | |
283 if (hover is null) { | |
284 setInformation(cast(Object)null, null); | |
285 return; | |
286 } | |
287 | |
288 IRegion region= hover.getHoverRegion(fTextViewer, offset); | |
289 if (region is null) { | |
290 setInformation(cast(Object)null, null); | |
291 return; | |
292 } | |
293 | |
294 Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | |
295 if (area is null || area.isEmpty()) { | |
296 setInformation(cast(Object)null, null); | |
297 return; | |
298 } | |
299 | |
300 if (fThread !is null) { | |
301 setInformation(cast(Object)null, null); | |
302 return; | |
303 } | |
304 fThread= new JThread( dgRunnable( (ITextHover hover_, IRegion region_, Rectangle area_){ | |
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 { | |
311 if ( cast(ITextHoverExtension2)hover_ ) | |
312 information= (cast(ITextHoverExtension2)hover_).getHoverInfo2(fTextViewer, region_); | |
313 else | |
314 information= stringcast(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 | |
324 if ( cast(ITextHoverExtension)hover_ ) | |
325 setCustomInformationControlCreator((cast(ITextHoverExtension) hover_).getHoverControlCreator()); | |
326 else | |
327 setCustomInformationControlCreator(null); | |
328 | |
329 setInformation(information, area_); | |
330 if (information !is null) | |
331 fTextHover= hover_; | |
332 } else { | |
333 setInformation(cast(Object)null, null); | |
334 } | |
335 hasFinished= true; | |
336 } catch (RuntimeException ex) { | |
337 String PLUGIN_ID= "org.eclipse.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(cast(Object)null, null); | |
348 } | |
349 } | |
350 }, hover, region, area ) ); | |
351 | |
352 fThread.setName( "Text Viewer Hover Presenter" ); //$NON-NLS-1$ | |
353 | |
354 fThread.setDaemon(true); | |
355 fThread.setPriority(JThread.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 | |
378 display.asyncExec(new class() Runnable { | |
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 | |
413 if ( cast(ITextViewerExtension5)fTextViewer ) { | |
414 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fTextViewer; | |
415 return extension.widgetOffset2ModelOffset(widgetOffset); | |
416 } | |
417 | |
418 return widgetOffset + fTextViewer._getVisibleRegionOffset_package(); | |
419 | |
420 } catch (IllegalArgumentException e) { | |
421 return -1; | |
422 } | |
423 } | |
424 | |
425 /* | |
426 * @see org.eclipse.jface.text.AbstractInformationControlManager#showInformationControl(org.eclipse.swt.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 | |
432 if (DEBUG) | |
433 System.out_.println("TextViewerHoverManager#showInformationControl(..) did not get widget token"); //$NON-NLS-1$ | |
434 } | |
435 | |
436 /* | |
437 * @see org.eclipse.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 } | |
448 | |
449 /* | |
450 * @see org.eclipse.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 org.eclipse.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 org.eclipse.jface.text.IWidgetTokenKeeper#requestWidgetToken(org.eclipse.jface.text.IWidgetTokenOwner) | |
473 */ | |
474 public bool requestWidgetToken(IWidgetTokenOwner owner) { | |
475 fTextHover= null; | |
476 super.hideInformationControl(); | |
477 return true; | |
478 } | |
479 | |
480 /* | |
481 * @see org.eclipse.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(org.eclipse.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 org.eclipse.jface.text.IWidgetTokenKeeperExtension#setFocus(org.eclipse.jface.text.IWidgetTokenOwner) | |
495 * @since 3.0 | |
496 */ | |
497 public bool setFocus(IWidgetTokenOwner owner) { | |
498 if (! hasInformationControlReplacer()) | |
499 return false; | |
500 | |
501 IInformationControl iControl= getCurrentInformationControl(); | |
502 if (canReplace(iControl)) { | |
503 if (cancelReplacingDelay()) | |
504 replaceInformationControl(true); | |
505 | |
506 return true; | |
507 } | |
508 | |
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 package ITextHover getCurrentTextHover_package() { | |
522 return getCurrentTextHover(); | |
523 } | |
524 | |
525 /* | |
526 * @see org.eclipse.jface.text.AbstractHoverInformationControlManager#dispose() | |
527 * @since 3.0 | |
528 */ | |
529 public void dispose() { | |
530 if (fTextViewer !is null) { | |
531 fTextViewer.removeViewportListener(fViewportListener); | |
532 fViewportListener= null; | |
533 | |
534 StyledText st= fTextViewer.getTextWidget(); | |
535 if (st !is null && !st.isDisposed()) | |
536 st.removeMouseMoveListener(fMouseMoveListener); | |
537 fMouseMoveListener= null; | |
538 } | |
539 super.dispose(); | |
540 } | |
541 } |