Mercurial > projects > dwt-addons
annotate dwtx/jface/text/TextViewerHoverManager.d @ 161:f8d52b926852
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:49:30 +0200 |
parents | 7926b636c282 |
children | 1a5b8f8129df |
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; | |
161 | 230 fStopper= new class() ITextListener { |
129 | 231 public void textChanged(TextEvent event) { |
232 synchronized (fMutex) { | |
233 if (fThread !is null) { | |
161 | 234 implMissing(__FILE__,__LINE__); |
235 // DWT FIXME: how to handle Thread.interrupt? | |
236 // fThread.interrupt(); | |
129 | 237 fThread= null; |
238 } | |
239 } | |
240 } | |
241 }; | |
135 | 242 fViewportListener= new class() IViewportListener { |
129 | 243 /* |
244 * @see dwtx.jface.text.IViewportListener#viewportChanged(int) | |
245 */ | |
246 public void viewportChanged(int verticalOffset) { | |
247 fProcessMouseHoverEvent= false; | |
248 } | |
249 }; | |
250 fTextViewer.addViewportListener(fViewportListener); | |
135 | 251 fMouseMoveListener= new class() MouseMoveListener { |
129 | 252 /* |
253 * @see MouseMoveListener#mouseMove(MouseEvent) | |
254 */ | |
255 public void mouseMove(MouseEvent event) { | |
256 fProcessMouseHoverEvent= true; | |
257 } | |
258 }; | |
259 fTextViewer.getTextWidget().addMouseMoveListener(fMouseMoveListener); | |
260 } | |
261 | |
262 /** | |
263 * Determines all necessary details and delegates the computation into | |
264 * a background thread. | |
265 */ | |
266 protected void computeInformation() { | |
267 | |
268 if (!fProcessMouseHoverEvent) { | |
161 | 269 setInformation(cast(Object)null, null); |
129 | 270 return; |
271 } | |
272 | |
273 Point location= getHoverEventLocation(); | |
274 int offset= computeOffsetAtLocation(location.x, location.y); | |
275 if (offset is -1) { | |
161 | 276 setInformation(cast(Object)null, null); |
129 | 277 return; |
278 } | |
279 | |
161 | 280 final ITextHover hover= fTextViewer.getTextHover_package(offset, getHoverEventStateMask()); |
129 | 281 if (hover is null) { |
161 | 282 setInformation(cast(Object)null, null); |
129 | 283 return; |
284 } | |
285 | |
286 final IRegion region= hover.getHoverRegion(fTextViewer, offset); | |
287 if (region is null) { | |
161 | 288 setInformation(cast(Object)null, null); |
129 | 289 return; |
290 } | |
291 | |
292 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | |
293 if (area is null || area.isEmpty()) { | |
161 | 294 setInformation(cast(Object)null, null); |
129 | 295 return; |
296 } | |
297 | |
298 if (fThread !is null) { | |
161 | 299 setInformation(cast(Object)null, null); |
129 | 300 return; |
301 } | |
302 | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
303 void threadrun() { |
129 | 304 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 |
305 bool hasFinished= false; | |
306 try { | |
307 if (fThread !is null) { | |
308 Object information; | |
309 try { | |
138 | 310 if ( cast(ITextHoverExtension2)hover ) |
134 | 311 information= (cast(ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region); |
129 | 312 else |
161 | 313 information= stringcast(hover.getHoverInfo(fTextViewer, region)); |
129 | 314 } catch (ArrayIndexOutOfBoundsException x) { |
315 /* | |
316 * This code runs in a separate thread which can | |
317 * lead to text offsets being out of bounds when | |
318 * computing the hover info (see bug 32848). | |
319 */ | |
320 information= null; | |
321 } | |
322 | |
138 | 323 if ( cast(ITextHoverExtension)hover ) |
134 | 324 setCustomInformationControlCreator((cast(ITextHoverExtension) hover).getHoverControlCreator()); |
129 | 325 else |
326 setCustomInformationControlCreator(null); | |
327 | |
328 setInformation(information, area); | |
329 if (information !is null) | |
330 fTextHover= hover; | |
331 } else { | |
161 | 332 setInformation(cast(Object)null, null); |
129 | 333 } |
334 hasFinished= true; | |
335 } catch (RuntimeException ex) { | |
336 String PLUGIN_ID= "dwtx.jface.text"; //$NON-NLS-1$ | |
337 ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); | |
338 log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Unexpected runtime error while computing a text hover", ex)); //$NON-NLS-1$ | |
339 } finally { | |
340 synchronized (fMutex) { | |
341 if (fTextViewer !is null) | |
342 fTextViewer.removeTextListener(fStopper); | |
343 fThread= null; | |
344 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756 | |
345 if (!hasFinished) | |
161 | 346 setInformation(cast(Object)null, null); |
129 | 347 } |
348 } | |
349 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
350 fThread= new Thread( &threadrun ); |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
351 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ |
129 | 352 |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
353 fThread.isDaemon(true); |
129 | 354 fThread.setPriority(Thread.MIN_PRIORITY); |
355 synchronized (fMutex) { | |
356 fTextViewer.addTextListener(fStopper); | |
357 fThread.start(); | |
358 } | |
359 } | |
360 | |
361 /** | |
362 * As computation is done in the background, this method is | |
363 * also called in the background thread. Delegates the control | |
364 * flow back into the UI thread, in order to allow displaying the | |
365 * information in the information control. | |
366 */ | |
367 protected void presentInformation() { | |
368 if (fTextViewer is null) | |
369 return; | |
370 | |
371 StyledText textWidget= fTextViewer.getTextWidget(); | |
372 if (textWidget !is null && !textWidget.isDisposed()) { | |
373 Display display= textWidget.getDisplay(); | |
374 if (display is null) | |
375 return; | |
376 | |
135 | 377 display.asyncExec(new class() Runnable { |
129 | 378 public void run() { |
379 doPresentInformation(); | |
380 } | |
381 }); | |
382 } | |
383 } | |
384 | |
385 /* | |
386 * @see AbstractInformationControlManager#presentInformation() | |
387 */ | |
388 protected void doPresentInformation() { | |
389 super.presentInformation(); | |
390 } | |
391 | |
392 /** | |
393 * Computes the document offset underlying the given text widget coordinates. | |
394 * This method uses a linear search as it cannot make any assumption about | |
395 * how the document is actually presented in the widget. (Covers cases such | |
396 * as bidirectional text.) | |
397 * | |
398 * @param x the horizontal coordinate inside the text widget | |
399 * @param y the vertical coordinate inside the text widget | |
400 * @return the document offset corresponding to the given point | |
401 */ | |
402 private int computeOffsetAtLocation(int x, int y) { | |
403 | |
404 try { | |
405 | |
406 StyledText styledText= fTextViewer.getTextWidget(); | |
407 int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y)); | |
408 Point p= styledText.getLocationAtOffset(widgetOffset); | |
409 if (p.x > x) | |
410 widgetOffset--; | |
411 | |
138 | 412 if ( cast(ITextViewerExtension5)fTextViewer ) { |
134 | 413 ITextViewerExtension5 extension= cast(ITextViewerExtension5) fTextViewer; |
129 | 414 return extension.widgetOffset2ModelOffset(widgetOffset); |
415 } | |
416 | |
417 return widgetOffset + fTextViewer._getVisibleRegionOffset(); | |
418 | |
419 } catch (IllegalArgumentException e) { | |
420 return -1; | |
421 } | |
422 } | |
423 | |
424 /* | |
425 * @see dwtx.jface.text.AbstractInformationControlManager#showInformationControl(dwt.graphics.Rectangle) | |
426 */ | |
427 protected void showInformationControl(Rectangle subjectArea) { | |
428 if (fTextViewer !is null && fTextViewer.requestWidgetToken(this, WIDGET_PRIORITY)) | |
429 super.showInformationControl(subjectArea); | |
430 else | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
431 if (DEBUG) |
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
432 System.out_.println("TextViewerHoverManager#showInformationControl(..) did not get widget token"); //$NON-NLS-1$ |
129 | 433 } |
434 | |
435 /* | |
436 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() | |
437 */ | |
438 protected void hideInformationControl() { | |
439 try { | |
440 fTextHover= null; | |
441 super.hideInformationControl(); | |
442 } finally { | |
443 if (fTextViewer !is null) | |
444 fTextViewer.releaseWidgetToken(this); | |
445 } | |
446 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
447 |
129 | 448 /* |
449 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) | |
450 * @since 3.4 | |
451 */ | |
452 void replaceInformationControl(bool takeFocus) { | |
453 if (fTextViewer !is null) | |
454 fTextViewer.releaseWidgetToken(this); | |
455 super.replaceInformationControl(takeFocus); | |
456 } | |
457 | |
458 /* | |
459 * @see dwtx.jface.text.AbstractInformationControlManager#handleInformationControlDisposed() | |
460 */ | |
461 protected void handleInformationControlDisposed() { | |
462 try { | |
463 super.handleInformationControlDisposed(); | |
464 } finally { | |
465 if (fTextViewer !is null) | |
466 fTextViewer.releaseWidgetToken(this); | |
467 } | |
468 } | |
469 | |
470 /* | |
471 * @see dwtx.jface.text.IWidgetTokenKeeper#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner) | |
472 */ | |
473 public bool requestWidgetToken(IWidgetTokenOwner owner) { | |
474 fTextHover= null; | |
475 super.hideInformationControl(); | |
476 return true; | |
477 } | |
478 | |
479 /* | |
480 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#requestWidgetToken(dwtx.jface.text.IWidgetTokenOwner, int) | |
481 * @since 3.0 | |
482 */ | |
483 public bool requestWidgetToken(IWidgetTokenOwner owner, int priority) { | |
484 if (priority > WIDGET_PRIORITY) { | |
485 fTextHover= null; | |
486 super.hideInformationControl(); | |
487 return true; | |
488 } | |
489 return false; | |
490 } | |
491 | |
492 /* | |
493 * @see dwtx.jface.text.IWidgetTokenKeeperExtension#setFocus(dwtx.jface.text.IWidgetTokenOwner) | |
494 * @since 3.0 | |
495 */ | |
496 public bool setFocus(IWidgetTokenOwner owner) { | |
497 if (! hasInformationControlReplacer()) | |
498 return false; | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
499 |
129 | 500 IInformationControl iControl= getCurrentInformationControl(); |
501 if (canReplace(iControl)) { | |
502 if (cancelReplacingDelay()) | |
503 replaceInformationControl(true); | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
504 |
129 | 505 return true; |
506 } | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
138
diff
changeset
|
507 |
129 | 508 return false; |
509 } | |
510 | |
511 /** | |
512 * Returns the currently shown text hover or <code>null</code> if no text | |
513 * hover is shown. | |
514 * | |
515 * @return the currently shown text hover or <code>null</code> | |
516 */ | |
517 protected ITextHover getCurrentTextHover() { | |
518 return fTextHover; | |
519 } | |
520 | |
521 /* | |
522 * @see dwtx.jface.text.AbstractHoverInformationControlManager#dispose() | |
523 * @since 3.0 | |
524 */ | |
525 public void dispose() { | |
526 if (fTextViewer !is null) { | |
527 fTextViewer.removeViewportListener(fViewportListener); | |
528 fViewportListener= null; | |
529 | |
530 StyledText st= fTextViewer.getTextWidget(); | |
531 if (st !is null && !st.isDisposed()) | |
532 st.removeMouseMoveListener(fMouseMoveListener); | |
533 fMouseMoveListener= null; | |
534 } | |
535 super.dispose(); | |
536 } | |
537 } |