Mercurial > projects > dwt-addons
comparison 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 |
comparison
equal
deleted
inserted
replaced
160:3678e4f1a766 | 161:f8d52b926852 |
---|---|
225 * @param creator the information control creator | 225 * @param creator the information control creator |
226 */ | 226 */ |
227 public this(TextViewer textViewer, IInformationControlCreator creator) { | 227 public this(TextViewer textViewer, IInformationControlCreator creator) { |
228 super(creator); | 228 super(creator); |
229 fTextViewer= textViewer; | 229 fTextViewer= textViewer; |
230 fStopper= new class() ITextListener { | 230 fStopper= new class() ITextListener { |
231 public void textChanged(TextEvent event) { | 231 public void textChanged(TextEvent event) { |
232 synchronized (fMutex) { | 232 synchronized (fMutex) { |
233 if (fThread !is null) { | 233 if (fThread !is null) { |
234 fThread.interrupt(); | 234 implMissing(__FILE__,__LINE__); |
235 // DWT FIXME: how to handle Thread.interrupt? | |
236 // fThread.interrupt(); | |
235 fThread= null; | 237 fThread= null; |
236 } | 238 } |
237 } | 239 } |
238 } | 240 } |
239 }; | 241 }; |
262 * a background thread. | 264 * a background thread. |
263 */ | 265 */ |
264 protected void computeInformation() { | 266 protected void computeInformation() { |
265 | 267 |
266 if (!fProcessMouseHoverEvent) { | 268 if (!fProcessMouseHoverEvent) { |
267 setInformation(null, null); | 269 setInformation(cast(Object)null, null); |
268 return; | 270 return; |
269 } | 271 } |
270 | 272 |
271 Point location= getHoverEventLocation(); | 273 Point location= getHoverEventLocation(); |
272 int offset= computeOffsetAtLocation(location.x, location.y); | 274 int offset= computeOffsetAtLocation(location.x, location.y); |
273 if (offset is -1) { | 275 if (offset is -1) { |
274 setInformation(null, null); | 276 setInformation(cast(Object)null, null); |
275 return; | 277 return; |
276 } | 278 } |
277 | 279 |
278 final ITextHover hover= fTextViewer.getTextHover(offset, getHoverEventStateMask()); | 280 final ITextHover hover= fTextViewer.getTextHover_package(offset, getHoverEventStateMask()); |
279 if (hover is null) { | 281 if (hover is null) { |
280 setInformation(null, null); | 282 setInformation(cast(Object)null, null); |
281 return; | 283 return; |
282 } | 284 } |
283 | 285 |
284 final IRegion region= hover.getHoverRegion(fTextViewer, offset); | 286 final IRegion region= hover.getHoverRegion(fTextViewer, offset); |
285 if (region is null) { | 287 if (region is null) { |
286 setInformation(null, null); | 288 setInformation(cast(Object)null, null); |
287 return; | 289 return; |
288 } | 290 } |
289 | 291 |
290 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | 292 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); |
291 if (area is null || area.isEmpty()) { | 293 if (area is null || area.isEmpty()) { |
292 setInformation(null, null); | 294 setInformation(cast(Object)null, null); |
293 return; | 295 return; |
294 } | 296 } |
295 | 297 |
296 if (fThread !is null) { | 298 if (fThread !is null) { |
297 setInformation(null, null); | 299 setInformation(cast(Object)null, null); |
298 return; | 300 return; |
299 } | 301 } |
300 | 302 |
301 void threadrun() { | 303 void threadrun() { |
302 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 | 304 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 |
306 Object information; | 308 Object information; |
307 try { | 309 try { |
308 if ( cast(ITextHoverExtension2)hover ) | 310 if ( cast(ITextHoverExtension2)hover ) |
309 information= (cast(ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region); | 311 information= (cast(ITextHoverExtension2)hover).getHoverInfo2(fTextViewer, region); |
310 else | 312 else |
311 information= hover.getHoverInfo(fTextViewer, region); | 313 information= stringcast(hover.getHoverInfo(fTextViewer, region)); |
312 } catch (ArrayIndexOutOfBoundsException x) { | 314 } catch (ArrayIndexOutOfBoundsException x) { |
313 /* | 315 /* |
314 * This code runs in a separate thread which can | 316 * This code runs in a separate thread which can |
315 * lead to text offsets being out of bounds when | 317 * lead to text offsets being out of bounds when |
316 * computing the hover info (see bug 32848). | 318 * computing the hover info (see bug 32848). |
325 | 327 |
326 setInformation(information, area); | 328 setInformation(information, area); |
327 if (information !is null) | 329 if (information !is null) |
328 fTextHover= hover; | 330 fTextHover= hover; |
329 } else { | 331 } else { |
330 setInformation(null, null); | 332 setInformation(cast(Object)null, null); |
331 } | 333 } |
332 hasFinished= true; | 334 hasFinished= true; |
333 } catch (RuntimeException ex) { | 335 } catch (RuntimeException ex) { |
334 String PLUGIN_ID= "dwtx.jface.text"; //$NON-NLS-1$ | 336 String PLUGIN_ID= "dwtx.jface.text"; //$NON-NLS-1$ |
335 ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); | 337 ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID)); |
339 if (fTextViewer !is null) | 341 if (fTextViewer !is null) |
340 fTextViewer.removeTextListener(fStopper); | 342 fTextViewer.removeTextListener(fStopper); |
341 fThread= null; | 343 fThread= null; |
342 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756 | 344 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44756 |
343 if (!hasFinished) | 345 if (!hasFinished) |
344 setInformation(null, null); | 346 setInformation(cast(Object)null, null); |
345 } | 347 } |
346 } | 348 } |
347 } | 349 } |
348 fThread= new Thread( &threadrun ); | 350 fThread= new Thread( &threadrun ); |
349 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ | 351 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ |