Mercurial > projects > dwt-addons
annotate dwtx/jface/text/TextViewerHoverManager.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | a9566845f1cb |
children | f8d52b926852 |
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 | |
129 | 156 import dwt.dwthelper.utils; |
159 | 157 import tango.core.Thread; |
129 | 158 |
159 import dwt.custom.StyledText; | |
160 import dwt.events.MouseEvent; | |
161 import dwt.events.MouseMoveListener; | |
162 import dwt.graphics.Point; | |
163 import dwt.graphics.Rectangle; | |
164 import dwt.widgets.Display; | |
165 import dwtx.core.runtime.ILog; | |
166 import dwtx.core.runtime.IStatus; | |
167 import dwtx.core.runtime.Platform; | |
168 import dwtx.core.runtime.Status; | |
169 | |
170 | |
171 /** | |
172 * This manager controls the layout, content, and visibility of an information | |
173 * control in reaction to mouse hover events issued by the text widget of a | |
174 * text viewer. It overrides <code>computeInformation</code>, so that the | |
175 * computation is performed in a dedicated background thread. This implies | |
176 * that the used <code>ITextHover</code> objects must be capable of | |
177 * operating in a non-UI thread. | |
178 * | |
179 * @since 2.0 | |
180 */ | |
181 class TextViewerHoverManager : AbstractHoverInformationControlManager , IWidgetTokenKeeper, IWidgetTokenKeeperExtension { | |
182 | |
183 | |
184 /** | |
185 * Priority of the hovers managed by this manager. | |
186 * Default value: <code>0</code>; | |
187 * @since 3.0 | |
188 */ | |
146 | 189 public const static int WIDGET_PRIORITY= 0; |
129 | 190 |
191 | |
192 /** The text viewer */ | |
193 private TextViewer fTextViewer; | |
194 /** The hover information computation thread */ | |
195 private Thread fThread; | |
196 /** The stopper of the computation thread */ | |
197 private ITextListener fStopper; | |
198 /** Internal monitor */ | |
199 private Object fMutex= new Object(); | |
200 /** The currently shown text hover. */ | |
156 | 201 private /+volatile+/ ITextHover fTextHover; |
129 | 202 /** |
203 * Tells whether the next mouse hover event | |
204 * should be processed. | |
205 * @since 3.0 | |
206 */ | |
207 private bool fProcessMouseHoverEvent= true; | |
208 /** | |
209 * Internal mouse move listener. | |
210 * @since 3.0 | |
211 */ | |
212 private MouseMoveListener fMouseMoveListener; | |
213 /** | |
214 * Internal view port listener. | |
215 * @since 3.0 | |
216 */ | |
217 private IViewportListener fViewportListener; | |
218 | |
219 | |
220 /** | |
221 * Creates a new text viewer hover manager specific for the given text viewer. | |
222 * The manager uses the given information control creator. | |
223 * | |
224 * @param textViewer the viewer for which the controller is created | |
225 * @param creator the information control creator | |
226 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
227 public this(TextViewer textViewer, IInformationControlCreator creator) { |
129 | 228 super(creator); |
229 fTextViewer= textViewer; | |
135 | 230 fStopper= new class() ITextListener { |
129 | 231 public void textChanged(TextEvent event) { |
232 synchronized (fMutex) { | |
233 if (fThread !is null) { | |
234 fThread.interrupt(); | |
235 fThread= null; | |
236 } | |
237 } | |
238 } | |
239 }; | |
135 | 240 fViewportListener= new class() IViewportListener { |
129 | 241 /* |
242 * @see dwtx.jface.text.IViewportListener#viewportChanged(int) | |
243 */ | |
244 public void viewportChanged(int verticalOffset) { | |
245 fProcessMouseHoverEvent= false; | |
246 } | |
247 }; | |
248 fTextViewer.addViewportListener(fViewportListener); | |
135 | 249 fMouseMoveListener= new class() MouseMoveListener { |
129 | 250 /* |
251 * @see MouseMoveListener#mouseMove(MouseEvent) | |
252 */ | |
253 public void mouseMove(MouseEvent event) { | |
254 fProcessMouseHoverEvent= true; | |
255 } | |
256 }; | |
257 fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener); | |
258 } | |
259 | |
260 /** | |
261 * Determines all necessary details and delegates the computation into | |
262 * a background thread. | |
263 */ | |
264 protected void computeInformation() { | |
265 | |
266 if (!fProcessMouseHoverEvent) { | |
267 setInformation(null, null); | |
268 return; | |
269 } | |
270 | |
271 Point location= getHoverEventLocation(); | |
272 int offset= computeOffsetAtLocation(location.x, location.y); | |
273 if (offset is -1) { | |
274 setInformation(null, null); | |
275 return; | |
276 } | |
277 | |
278 final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask()); | |
279 if (hover is null) { | |
280 setInformation(null, null); | |
281 return; | |
282 } | |
283 | |
284 final IRegion region= hover.getHoverRegion(fTextViewer, offset); | |
285 if (region is null) { | |
286 setInformation(null, null); | |
287 return; | |
288 } | |
289 | |
290 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | |
291 if (area is null || area.isEmpty()) { | |
292 setInformation(null, null); | |
293 return; | |
294 } | |
295 | |
296 if (fThread !is null) { | |
297 setInformation(null, null); | |
298 return; | |
299 } | |
300 | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
301 void threadrun() { |
129 | 302 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 |
303 bool hasFinished= false; | |
304 try { | |
305 if (fThread !is null) { | |
306 Object information; | |
307 try { | |
138 | 308 if ( cast(ITextHoverExtension2)hover ) |
134 | 309 information= (cast(ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region); |
129 | 310 else |
311 information= hover.getHoverInfo(fTextViewer, region); | |
312 } catch (ArrayIndexOutOfBoundsException x) { | |
313 /* | |
314 * This code runs in a separate thread which can | |
315 * lead to text offsets being out of bounds when | |
316 * computing the hover info (see bug 32848). | |
317 */ | |
318 information= null; | |
319 } | |
320 | |
138 | 321 if ( cast(ITextHoverExtension)hover ) |
134 | 322 setCustomInformationControlCreator((cast(ITextHoverExtension) hover).getHoverControlCreator()); |
129 | 323 else |
324 setCustomInformationControlCreator(null); | |
325 | |
326 setInformation(information, area); | |
327 if (information !is null) | |
328 fTextHover= hover; | |
329 } else { | |
330 setInformation(null, null); | |
331 } | |
332 hasFinished= true; | |
333 } catch (RuntimeException ex) { | |
334 String PLUGIN_ID= "dwtx.jface.text"; //$NON-NLS-1$ | |
335 ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); | |
336 log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Unexpected runtime error while computing a text hover", ex)); //$NON-NLS-1$ | |
337 } finally { | |
338 synchronized (fMutex) { | |
339 if (fTextViewer !is null) | |
340 fTextViewer.removeTextListener(fStopper); | |
341 fThread= null; | |
342 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756 | |
343 if (!hasFinished) | |
344 setInformation(null, null); | |
345 } | |
346 } | |
347 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
348 fThread= new Thread( &threadrun ); |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
349 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ |
129 | 350 |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
351 fThread.isDaemon(true); |
129 | 352 fThread.setPriority(Thread.MIN_PRIORITY); |
353 synchronized (fMutex) { | |
354 fTextViewer.addTextListener(fStopper); | |
355 fThread.start(); | |
356 } | |
357 } | |
358 | |
359 /** | |
360 * As computation is done in the background, this method is | |
361 * also called in the background thread. Delegates the control | |
362 * flow back into the UI thread, in order to allow displaying the | |
363 * information in the information control. | |
364 */ | |
365 protected void presentInformation() { | |
366 if (fTextViewer is null) | |
367 return; | |
368 | |
369 StyledText textWidget= fTextViewer.getTextWidget(); | |
370 if (textWidget !is null && !textWidget.isDisposed()) { | |
371 Display display= textWidget.getDisplay(); | |
372 if (display is null) | |
373 return; | |
374 | |
135 | 375 display.asyncExec(new class() Runnable { |
129 | 376 public void run() { |
377 doPresentInformation(); | |
378 } | |
379 }); | |
380 } | |
381 } | |
382 | |
383 /* | |
384 * @see AbstractInformationControlManager#presentInformation() | |
385 */ | |
386 protected void doPresentInformation() { | |
387 super.presentInformation(); | |
388 } | |
389 | |
390 /** | |
391 * Computes the document offset underlying the given text widget coordinates. | |
392 * This method uses a linear search as it cannot make any assumption about | |
393 * how the document is actually presented in the widget. (Covers cases such | |
394 * as bidirectional text.) | |
395 * | |
396 * @param x the horizontal coordinate inside the text widget | |
397 * @param y the vertical coordinate inside the text widget | |
398 * @return the document offset corresponding to the given point | |
399 */ | |
400 private int computeOffsetAtLocation(int x, int y) { | |
401 | |
402 try { | |
403 | |
404 StyledText styledText= fTextViewer.getTextWidget(); | |
405 int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y)); | |
406 Point p= styledText.getLocationAtOffset(widgetOffset); | |
407 if (p.x > x) | |
408 widgetOffset--; | |
409 | |
138 | 410 if ( cast(ITextViewerExtension5)fTextViewer ) { |
134 | 411 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fTextViewer; |
129 | 412 return extension.widgetOffset2ModelOffset(widgetOffset); |
413 } | |
414 | |
415 return widgetOffset + fTextViewer._getVisibleRegionOffset(); | |
416 | |
417 } catch (IllegalArgumentException e) { | |
418 return -1; | |
419 } | |
420 } | |
421 | |
422 /* | |
423 * @see dwtx.jface.text.AbstractInformationControlManager#showInformationControl(dwt.graphics.Rectangle) | |
424 */ | |
425 protected void showInformationControl(Rectangle subjectArea) { | |
426 if (fTextViewer !is null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY)) | |
427 super.showInformationControl(subjectArea); | |
428 else | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
429 if (DEBUG) |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
430 System.out_.println("TextViewerHoverManager#showInformationControl(..) did not get widget token"); //$NON-NLS-1$ |
129 | 431 } |
432 | |
433 /* | |
434 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() | |
435 */ | |
436 protected void hideInformationControl() { | |
437 try { | |
438 fTextHover= null; | |
439 super.hideInformationControl(); | |
440 } finally { | |
441 if (fTextViewer !is null) | |
442 fTextViewer.releaseWidgetToken(this); | |
443 } | |
444 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
445 |
129 | 446 /* |
447 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) | |
448 * @since 3.4 | |
449 */ | |
450 void replaceInformationControl(bool takeFocus) { | |
451 if (fTextViewer !is null) | |
452 fTextViewer.releaseWidgetToken(this); | |
453 super.replaceInformationControl(takeFocus); | |
454 } | |
455 | |
456 /* | |
457 * @see dwtx.jface.text.AbstractInformationControlManager#handleInformationControlDisposed() | |
458 */ | |
459 protected void handleInformationControlDisposed() { | |
460 try { | |
461 super.handleInformationControlDisposed(); | |
462 } finally { | |
463 if (fTextViewer !is null) | |
464 fTextViewer.releaseWidgetToken(this); | |
465 } | |
466 } | |
467 | |
468 /* | |
469 * @see dwtx.jface.text.IWidgetTokenKeeper#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner) | |
470 */ | |
471 public bool requestWidgetToken(IWidgetTokenOwner owner) { | |
472 fTextHover= null; | |
473 super.hideInformationControl(); | |
474 return true; | |
475 } | |
476 | |
477 /* | |
478 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner, int) | |
479 * @since 3.0 | |
480 */ | |
481 public bool requestWidgetToken(IWidgetTokenOwner owner, int priority) { | |
482 if (priority > WIDGET_PRIORITY) { | |
483 fTextHover= null; | |
484 super.hideInformationControl(); | |
485 return true; | |
486 } | |
487 return false; | |
488 } | |
489 | |
490 /* | |
491 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#setFocus(dwtx.jface.text.IWidgetTokenOwner) | |
492 * @since 3.0 | |
493 */ | |
494 public bool setFocus(IWidgetTokenOwner owner) { | |
495 if (! hasInformationControlReplacer()) | |
496 return false; | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
497 |
129 | 498 IInformationControl iControl= getCurrentInformationControl(); |
499 if (canReplace(iControl)) { | |
500 if (cancelReplacingDelay()) | |
501 replaceInformationControl(true); | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
502 |
129 | 503 return true; |
504 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
505 |
129 | 506 return false; |
507 } | |
508 | |
509 /** | |
510 * Returns the currently shown text hover or <code>null</code> if no text | |
511 * hover is shown. | |
512 * | |
513 * @return the currently shown text hover or <code>null</code> | |
514 */ | |
515 protected ITextHover getCurrentTextHover() { | |
516 return fTextHover; | |
517 } | |
518 | |
519 /* | |
520 * @see dwtx.jface.text.AbstractHoverInformationControlManager#dispose() | |
521 * @since 3.0 | |
522 */ | |
523 public void dispose() { | |
524 if (fTextViewer !is null) { | |
525 fTextViewer.removeViewportListener(fViewportListener); | |
526 fViewportListener= null; | |
527 | |
528 StyledText st= fTextViewer.getTextWidget(); | |
529 if (st !is null && !st.isDisposed()) | |
530 st.removeMouseMoveListener(fMouseMoveListener); | |
531 fMouseMoveListener= null; | |
532 } | |
533 super.dispose(); | |
534 } | |
535 } |