Mercurial > projects > dwt-addons
comparison dwtx/jface/text/TextViewerHoverManager.d @ 172:d994a8b2cdf7
again compile fixes
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 10 Sep 2008 23:14:02 +0200 |
parents | 862b05e0334a |
children |
comparison
equal
deleted
inserted
replaced
171:ee33f30b14e2 | 172:d994a8b2cdf7 |
---|---|
276 if (offset is -1) { | 276 if (offset is -1) { |
277 setInformation(cast(Object)null, null); | 277 setInformation(cast(Object)null, null); |
278 return; | 278 return; |
279 } | 279 } |
280 | 280 |
281 final ITextHover hover= fTextViewer.getTextHover_package(offset, getHoverEventStateMask()); | 281 ITextHover hover= fTextViewer.getTextHover_package(offset, getHoverEventStateMask()); |
282 if (hover is null) { | 282 if (hover is null) { |
283 setInformation(cast(Object)null, null); | 283 setInformation(cast(Object)null, null); |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 final IRegion region= hover.getHoverRegion(fTextViewer, offset); | 287 IRegion region= hover.getHoverRegion(fTextViewer, offset); |
288 if (region is null) { | 288 if (region is null) { |
289 setInformation(cast(Object)null, null); | 289 setInformation(cast(Object)null, null); |
290 return; | 290 return; |
291 } | 291 } |
292 | 292 |
293 final Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); | 293 Rectangle area= JFaceTextUtil.computeArea(region, fTextViewer); |
294 if (area is null || area.isEmpty()) { | 294 if (area is null || area.isEmpty()) { |
295 setInformation(cast(Object)null, null); | 295 setInformation(cast(Object)null, null); |
296 return; | 296 return; |
297 } | 297 } |
298 | 298 |
299 if (fThread !is null) { | 299 if (fThread !is null) { |
300 setInformation(cast(Object)null, null); | 300 setInformation(cast(Object)null, null); |
301 return; | 301 return; |
302 } | 302 } |
303 | 303 fThread= new JThread( dgRunnable( (ITextHover hover_, IRegion region_, Rectangle area_){ |
304 void threadrun() { | 304 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 |
305 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=17693 | 305 bool hasFinished= false; |
306 bool hasFinished= false; | 306 try { |
307 try { | 307 if (fThread !is null) { |
308 if (fThread !is null) { | 308 Object information; |
309 Object information; | 309 try { |
310 try { | 310 if ( cast(ITextHoverExtension2)hover_ ) |
311 if ( cast(ITextHoverExtension2)hover ) | 311 information= (cast(ITextHoverExtension2)hover_).getHoverInfo2(fTextViewer, region_); |
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 | 312 else |
327 setCustomInformationControlCreator(null); | 313 information= stringcast(hover_.getHoverInfo(fTextViewer, region_)); |
328 | 314 } catch (ArrayIndexOutOfBoundsException x) { |
329 setInformation(information, area); | 315 /* |
330 if (information !is null) | 316 * This code runs in a separate thread which can |
331 fTextHover= hover; | 317 * lead to text offsets being out of bounds when |
332 } else { | 318 * computing the hover info (see bug 32848). |
319 */ | |
320 information= null; | |
321 } | |
322 | |
323 if ( cast(ITextHoverExtension)hover_ ) | |
324 setCustomInformationControlCreator((cast(ITextHoverExtension) hover_).getHoverControlCreator()); | |
325 else | |
326 setCustomInformationControlCreator(null); | |
327 | |
328 setInformation(information, area_); | |
329 if (information !is null) | |
330 fTextHover= hover_; | |
331 } else { | |
332 setInformation(cast(Object)null, null); | |
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) | |
333 setInformation(cast(Object)null, null); | 346 setInformation(cast(Object)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(cast(Object)null, null); | |
348 } | |
349 } | 347 } |
350 } | 348 } |
351 fThread= new Thread( &threadrun ); | 349 }, hover, region, area ) ); |
352 fThread.name = "Text Viewer Hover Presenter"; //$NON-NLS-1$ | 350 |
353 | 351 fThread.setName( "Text Viewer Hover Presenter" ); //$NON-NLS-1$ |
354 fThread.isDaemon(true); | 352 |
355 fThread.priority(Thread.PRIORITY_MIN); | 353 fThread.setDaemon(true); |
354 fThread.setPriority(JThread.MIN_PRIORITY); | |
356 synchronized (fMutex) { | 355 synchronized (fMutex) { |
357 fTextViewer.addTextListener(fStopper); | 356 fTextViewer.addTextListener(fStopper); |
358 fThread.start(); | 357 fThread.start(); |
359 } | 358 } |
360 } | 359 } |