comparison dwtx/jface/text/AbstractHoverInformationControlManager.d @ 148:b3dec671d1f7

...
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 22:40:25 +0200
parents 000f9136b8f7
children b411f1c62131
comparison
equal deleted inserted replaced
147:000f9136b8f7 148:b3dec671d1f7
208 * 208 *
209 * @see dwt.events.MouseTrackListener 209 * @see dwt.events.MouseTrackListener
210 * @since 2.0 210 * @since 2.0
211 */ 211 */
212 abstract public class AbstractHoverInformationControlManager : AbstractInformationControlManager { 212 abstract public class AbstractHoverInformationControlManager : AbstractInformationControlManager {
213 213
214 /** 214 /**
215 * The information control closer for the hover information. Closes the information control as 215 * The information control closer for the hover information. Closes the information control as
216 * soon as the mouse pointer leaves the subject area (unless "move into hover" is enabled), 216 * soon as the mouse pointer leaves the subject area (unless "move into hover" is enabled),
217 * a mouse button is pressed, the user presses a key, or the subject control is resized, moved, or loses focus. 217 * a mouse button is pressed, the user presses a key, or the subject control is resized, moved, or loses focus.
218 */ 218 */
219 class Closer : IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, SelectionListener, Listener { 219 class Closer : IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, SelectionListener, Listener {
220 220
221 /** The closer's subject control */ 221 /** The closer's subject control */
222 private Control fSubjectControl; 222 private Control fSubjectControl;
223 /** The subject area */ 223 /** The subject area */
224 private Rectangle fSubjectArea; 224 private Rectangle fSubjectArea;
225 /** Indicates whether this closer is active */ 225 /** Indicates whether this closer is active */
275 vBar.addSelectionListener(this); 275 vBar.addSelectionListener(this);
276 ScrollBar hBar= scrollable.getHorizontalBar(); 276 ScrollBar hBar= scrollable.getHorizontalBar();
277 if (hBar !is null) 277 if (hBar !is null)
278 hBar.addSelectionListener(this); 278 hBar.addSelectionListener(this);
279 } 279 }
280 280
281 fDisplay= fSubjectControl.getDisplay(); 281 fDisplay= fSubjectControl.getDisplay();
282 if (!fDisplay.isDisposed()) { 282 if (!fDisplay.isDisposed()) {
283 fDisplay.addFilter(DWT.Activate, this); 283 fDisplay.addFilter(DWT.Activate, this);
284 fDisplay.addFilter(DWT.MouseWheel, this); 284 fDisplay.addFilter(DWT.MouseWheel, this);
285 285
286 fDisplay.addFilter(DWT.FocusOut, this); 286 fDisplay.addFilter(DWT.FocusOut, this);
287 287
288 fDisplay.addFilter(DWT.MouseDown, this); 288 fDisplay.addFilter(DWT.MouseDown, this);
289 fDisplay.addFilter(DWT.MouseUp, this); 289 fDisplay.addFilter(DWT.MouseUp, this);
290 290
291 fDisplay.addFilter(DWT.MouseMove, this); 291 fDisplay.addFilter(DWT.MouseMove, this);
292 fDisplay.addFilter(DWT.MouseEnter, this); 292 fDisplay.addFilter(DWT.MouseEnter, this);
293 fDisplay.addFilter(DWT.MouseExit, this); 293 fDisplay.addFilter(DWT.MouseExit, this);
294 } 294 }
295 } 295 }
302 if (!fIsActive) 302 if (!fIsActive)
303 return; 303 return;
304 304
305 fIsActive= false; 305 fIsActive= false;
306 306
307 if cast(DEBUG) 307 if (DEBUG)
308 System.out_.println("AbstractHoverInformationControlManager.Closer stopped"); //$NON-NLS-1$ 308 System.out_.println("AbstractHoverInformationControlManager.Closer stopped"); //$NON-NLS-1$
309 309
310 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { 310 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) {
311 fSubjectControl.removeMouseListener(this); 311 fSubjectControl.removeMouseListener(this);
312 fSubjectControl.removeMouseMoveListener(this); 312 fSubjectControl.removeMouseMoveListener(this);
324 } 324 }
325 325
326 if (fDisplay !is null && !fDisplay.isDisposed()) { 326 if (fDisplay !is null && !fDisplay.isDisposed()) {
327 fDisplay.removeFilter(DWT.Activate, this); 327 fDisplay.removeFilter(DWT.Activate, this);
328 fDisplay.removeFilter(DWT.MouseWheel, this); 328 fDisplay.removeFilter(DWT.MouseWheel, this);
329 329
330 fDisplay.removeFilter(DWT.FocusOut, this); 330 fDisplay.removeFilter(DWT.FocusOut, this);
331 331
332 fDisplay.removeFilter(DWT.MouseDown, this); 332 fDisplay.removeFilter(DWT.MouseDown, this);
333 fDisplay.removeFilter(DWT.MouseUp, this); 333 fDisplay.removeFilter(DWT.MouseUp, this);
334 334
335 fDisplay.removeFilter(DWT.MouseMove, this); 335 fDisplay.removeFilter(DWT.MouseMove, this);
336 fDisplay.removeFilter(DWT.MouseEnter, this); 336 fDisplay.removeFilter(DWT.MouseEnter, this);
337 fDisplay.removeFilter(DWT.MouseExit, this); 337 fDisplay.removeFilter(DWT.MouseExit, this);
338 } 338 }
339 fDisplay= null; 339 fDisplay= null;
406 * @see dwt.events.SelectionListener#widgetSelected(dwt.events.SelectionEvent) 406 * @see dwt.events.SelectionListener#widgetSelected(dwt.events.SelectionEvent)
407 */ 407 */
408 public void widgetSelected(SelectionEvent e) { 408 public void widgetSelected(SelectionEvent e) {
409 hideInformationControl(); 409 hideInformationControl();
410 } 410 }
411 411
412 /* 412 /*
413 * @see dwt.events.SelectionListener#widgetDefaultSelected(dwt.events.SelectionEvent) 413 * @see dwt.events.SelectionListener#widgetDefaultSelected(dwt.events.SelectionEvent)
414 */ 414 */
415 public void widgetDefaultSelected(SelectionEvent e) { 415 public void widgetDefaultSelected(SelectionEvent e) {
416 } 416 }
417 417
418 /* 418 /*
419 * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) 419 * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event)
420 * @since 3.1 420 * @since 3.1
421 */ 421 */
422 public void handleEvent(Event event) { 422 public void handleEvent(Event event) {
438 } else if (infoControl !is null && infoControl.isFocusControl() && cancelReplacingDelay()) { 438 } else if (infoControl !is null && infoControl.isFocusControl() && cancelReplacingDelay()) {
439 replaceInformationControl(true); 439 replaceInformationControl(true);
440 } 440 }
441 } 441 }
442 break; 442 break;
443 443
444 case DWT.MouseUp: 444 case DWT.MouseUp:
445 case DWT.MouseDown: 445 case DWT.MouseDown:
446 if (!hasInformationControlReplacer()) 446 if (!hasInformationControlReplacer())
447 hideInformationControl(); 447 hideInformationControl();
448 else if (!isReplaceInProgress()) { 448 else if (!isReplaceInProgress()) {
464 public void run() { 464 public void run() {
465 delayedICP.setDelayedInputChangeListener(null); 465 delayedICP.setDelayedInputChangeListener(null);
466 } 466 }
467 }); 467 });
468 } 468 }
469 469
470 // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 : 470 // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 :
471 control.getShell().getDisplay().asyncExec(new class() Runnable { 471 control.getShell().getDisplay().asyncExec(new class() Runnable {
472 public void run() { 472 public void run() {
473 replaceInformationControl(true); 473 replaceInformationControl(true);
474 } 474 }
486 case DWT.FocusOut: 486 case DWT.FocusOut:
487 IInformationControl iControl= getCurrentInformationControl(); 487 IInformationControl iControl= getCurrentInformationControl();
488 if (iControl !is null && ! iControl.isFocusControl()) 488 if (iControl !is null && ! iControl.isFocusControl())
489 hideInformationControl(); 489 hideInformationControl();
490 break; 490 break;
491 491
492 case DWT.MouseMove: 492 case DWT.MouseMove:
493 case DWT.MouseEnter: 493 case DWT.MouseEnter:
494 case DWT.MouseExit: 494 case DWT.MouseExit:
495 handleMouseMove(event); 495 handleMouseMove(event);
496 break; 496 break;
497 } 497 }
498 } 498 }
499 499
500 /** 500 /**
501 * Handle mouse movement events. 501 * Handle mouse movement events.
502 * 502 *
503 * @param event the event 503 * @param event the event
504 * @since 3.4 504 * @since 3.4
505 */ 505 */
506 private void handleMouseMove(Event event) { 506 private void handleMouseMove(Event event) {
507 // if cast(DEBUG) 507 // if (DEBUG)
508 // System.out_.println("AbstractHoverInformationControl.Closer.handleMouseMove():" + event); //$NON-NLS-1$ 508 // System.out_.println("AbstractHoverInformationControl.Closer.handleMouseMove():" + event); //$NON-NLS-1$
509 509
510 if (!(event.widget instanceof Control)) 510 if (!(event.widget instanceof Control))
511 return; 511 return;
512 Control eventControl= cast(Control) event.widget; 512 Control eventControl= cast(Control) event.widget;
513 513
514 //transform coordinates to subject control: 514 //transform coordinates to subject control:
515 Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y); 515 Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y);
516 516
517 if (fSubjectArea.contains(mouseLoc)) 517 if (fSubjectArea.contains(mouseLoc))
518 return; 518 return;
519 519
520 IInformationControl iControl= getCurrentInformationControl(); 520 IInformationControl iControl= getCurrentInformationControl();
521 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(iControl)) { 521 if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(iControl)) {
522 if (this.outer instanceof AnnotationBarHoverManager) { 522 if (this.outer instanceof AnnotationBarHoverManager) {
523 if (getInternalAccessor().getAllowMouseExit()) 523 if (getInternalAccessor().getAllowMouseExit())
524 return; 524 return;
525 } 525 }
526 hideInformationControl(); 526 hideInformationControl();
527 return; 527 return;
528 } 528 }
529 529
530 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; 530 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl;
531 Rectangle controlBounds= iControl3.getBounds(); 531 Rectangle controlBounds= iControl3.getBounds();
532 if (controlBounds !is null) { 532 if (controlBounds !is null) {
533 Rectangle tooltipBounds= event.display.map(null, eventControl, controlBounds); 533 Rectangle tooltipBounds= event.display.map(null, eventControl, controlBounds);
534 if (tooltipBounds.contains(event.x, event.y)) { 534 if (tooltipBounds.contains(event.x, event.y)) {
637 * @param event the mouse hover event 637 * @param event the mouse hover event
638 */ 638 */
639 public void mouseHover(MouseEvent event) { 639 public void mouseHover(MouseEvent event) {
640 if (fIsComputing || fIsInRestartMode || 640 if (fIsComputing || fIsInRestartMode ||
641 (fSubjectControl !is null && !fSubjectControl.isDisposed() && fSubjectControl.getShell() !is fSubjectControl.getShell().getDisplay().getActiveShell())) { 641 (fSubjectControl !is null && !fSubjectControl.isDisposed() && fSubjectControl.getShell() !is fSubjectControl.getShell().getDisplay().getActiveShell())) {
642 if cast(DEBUG) 642 if (DEBUG)
643 System.out_.println("AbstractHoverInformationControlManager...mouseHover: @ " + event.x + "/" + event.y + " : hover cancelled: fIsComputing= " + fIsComputing + ", fIsInRestartMode= " + fIsInRestartMode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 643 System.out_.println("AbstractHoverInformationControlManager...mouseHover: @ " + event.x + "/" + event.y + " : hover cancelled: fIsComputing= " + fIsComputing + ", fIsInRestartMode= " + fIsInRestartMode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
644 return; 644 return;
645 } 645 }
646 646
647 fIsInRestartMode= true; 647 fIsInRestartMode= true;
648 fIsComputing= true; 648 fIsComputing= true;
649 fMouseLostWhileComputing= false; 649 fMouseLostWhileComputing= false;
650 fShellDeactivatedWhileComputing= false; 650 fShellDeactivatedWhileComputing= false;
651 651
671 * computing the information to be presented. 671 * computing the information to be presented.
672 */ 672 */
673 protected void deactivate() { 673 protected void deactivate() {
674 if (fIsComputing) 674 if (fIsComputing)
675 return; 675 return;
676 676
677 fIsInRestartMode= false; 677 fIsInRestartMode= false;
678 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { 678 if (fSubjectControl !is null && !fSubjectControl.isDisposed()) {
679 fSubjectControl.removeMouseMoveListener(this); 679 fSubjectControl.removeMouseMoveListener(this);
680 fSubjectControl.getShell().removeShellListener(this); 680 fSubjectControl.getShell().removeShellListener(this);
681 } 681 }
777 /** The remembered hover event state mask of the keyboard modifiers */ 777 /** The remembered hover event state mask of the keyboard modifiers */
778 private int fHoverEventStateMask= 0; 778 private int fHoverEventStateMask= 0;
779 /** 779 /**
780 * The thread that delays replacing of the hover information control. 780 * The thread that delays replacing of the hover information control.
781 * To be accessed in the UI thread only! 781 * To be accessed in the UI thread only!
782 * 782 *
783 * @since 3.4 783 * @since 3.4
784 */ 784 */
785 private Job fReplacingDelayJob; 785 private Job fReplacingDelayJob;
786 786
787 /** 787 /**
788 * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>. 788 * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>.
789 * @since 3.4 789 * @since 3.4
790 */ 790 */
791 private EnrichMode fEnrichMode; 791 private EnrichMode fEnrichMode;
792 792
793 /** 793 /**
794 * Indicates whether we have received a MouseDown event and are waiting for a MouseUp 794 * Indicates whether we have received a MouseDown event and are waiting for a MouseUp
795 * (and don't replace the information control until that happened). 795 * (and don't replace the information control until that happened).
796 * @since 3.4 796 * @since 3.4
797 */ 797 */
798 private bool fWaitForMouseUp= false; 798 private bool fWaitForMouseUp= false;
799 799
800 /** 800 /**
801 * Creates a new hover information control manager using the given information control creator. 801 * Creates a new hover information control manager using the given information control creator.
802 * By default a <code>Closer</code> instance is set as this manager's closer. 802 * By default a <code>Closer</code> instance is set as this manager's closer.
803 * 803 *
804 * @param creator the information control creator 804 * @param creator the information control creator
810 } 810 }
811 811
812 /** 812 /**
813 * Tests whether a given mouse location is within the keep-up zone. 813 * Tests whether a given mouse location is within the keep-up zone.
814 * The hover should not be hidden as long as the mouse stays inside this zone. 814 * The hover should not be hidden as long as the mouse stays inside this zone.
815 * 815 *
816 * @param x the x coordinate, relative to the <em>subject control</em> 816 * @param x the x coordinate, relative to the <em>subject control</em>
817 * @param y the y coordinate, relative to the <em>subject control</em> 817 * @param y the y coordinate, relative to the <em>subject control</em>
818 * @param subjectControl the subject control 818 * @param subjectControl the subject control
819 * @param subjectArea the area for which the presented information is valid 819 * @param subjectArea the area for which the presented information is valid
820 * @param blowUp If <code>true</code>, then calculate for the closer, i.e. blow up the keepUp area. 820 * @param blowUp If <code>true</code>, then calculate for the closer, i.e. blow up the keepUp area.
821 * If <code>false</code>, then use tight bounds for hover detection. 821 * If <code>false</code>, then use tight bounds for hover detection.
822 * 822 *
823 * @return <code>true</code> iff the mouse event occurred in the keep-up zone 823 * @return <code>true</code> iff the mouse event occurred in the keep-up zone
824 * @since 3.4 824 * @since 3.4
825 */ 825 */
826 private bool inKeepUpZone(int x, int y, Control subjectControl, Rectangle subjectArea, bool blowUp) { 826 private bool inKeepUpZone(int x, int y, Control subjectControl, Rectangle subjectArea, bool blowUp) {
827 if (subjectArea.contains(x, y)) 827 if (subjectArea.contains(x, y))
828 return true; 828 return true;
829 829
830 IInformationControl iControl= getCurrentInformationControl(); 830 IInformationControl iControl= getCurrentInformationControl();
831 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { 831 if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) {
832 iControl= null; 832 iControl= null;
833 if (getInformationControlReplacer() !is null) { 833 if (getInformationControlReplacer() !is null) {
834 iControl= getInformationControlReplacer().getCurrentInformationControl2(); 834 iControl= getInformationControlReplacer().getCurrentInformationControl2();
837 } 837 }
838 } 838 }
839 } 839 }
840 if ( cast(IInformationControlExtension3)iControl ) { 840 if ( cast(IInformationControlExtension3)iControl ) {
841 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; 841 IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl;
842 842
843 Rectangle iControlBounds= subjectControl.getDisplay().map(null, subjectControl, iControl3.getBounds()); 843 Rectangle iControlBounds= subjectControl.getDisplay().map(null, subjectControl, iControl3.getBounds());
844 Rectangle totalBounds= Geometry.copy(iControlBounds); 844 Rectangle totalBounds= Geometry.copy(iControlBounds);
845 if (blowUp && isReplaceInProgress()) { 845 if (blowUp && isReplaceInProgress()) {
846 //Problem: blown up iControl overlaps rest of subjectArea's line 846 //Problem: blown up iControl overlaps rest of subjectArea's line
847 // solution for now: only blow up for keep up (closer), but not for further hover detection 847 // solution for now: only blow up for keep up (closer), but not for further hover detection
848 int margin= getInformationControlReplacer().getKeepUpMargin(); 848 int margin= getInformationControlReplacer().getKeepUpMargin();
849 Geometry.expand(totalBounds, margin, margin, margin, margin); 849 Geometry.expand(totalBounds, margin, margin, margin, margin);
850 } 850 }
851 851
852 if (!blowUp) { 852 if (!blowUp) {
853 if (iControlBounds.contains(x, y)) 853 if (iControlBounds.contains(x, y))
854 return true; 854 return true;
855 855
856 if (subjectArea.y + subjectArea.height < iControlBounds.y) { 856 if (subjectArea.y + subjectArea.height < iControlBounds.y) {
857 // special case for hover events: subjectArea totally above iControl: 857 // special case for hover events: subjectArea totally above iControl:
858 // +-----------+ 858 // +-----------+
859 // |subjectArea| 859 // |subjectArea|
860 // +-----------+ 860 // +-----------+
869 return true; 869 return true;
870 } 870 }
871 // FIXME: cases when subjectArea extends to left or right of iControl? 871 // FIXME: cases when subjectArea extends to left or right of iControl?
872 } 872 }
873 return false; 873 return false;
874 874
875 } else if (iControlBounds.x + iControlBounds.width < subjectArea.x) { 875 } else if (iControlBounds.x + iControlBounds.width < subjectArea.x) {
876 // special case for hover events (e.g. in overview ruler): iControl totally left of subjectArea 876 // special case for hover events (e.g. in overview ruler): iControl totally left of subjectArea
877 // +--------------------+-----------+ 877 // +--------------------+-----------+
878 // | | +-----------+ 878 // | | +-----------+
879 // | InformationControl |also keepUp|subjectArea| 879 // | InformationControl |also keepUp|subjectArea|
885 // is to the right of iControl (in a horizontal projection) 885 // is to the right of iControl (in a horizontal projection)
886 return true; 886 return true;
887 } 887 }
888 } 888 }
889 return false; 889 return false;
890 890
891 } else if (subjectArea.x + subjectArea.width < iControlBounds.x) { 891 } else if (subjectArea.x + subjectArea.width < iControlBounds.x) {
892 // special case for hover events (e.g. in annotation ruler): subjectArea totally left of iControl 892 // special case for hover events (e.g. in annotation ruler): subjectArea totally left of iControl
893 // +-----------+--------------------+ 893 // +-----------+--------------------+
894 // +-----------+ | | 894 // +-----------+ | |
895 // |subjectArea|also keepUp| InformationControl | 895 // |subjectArea|also keepUp| InformationControl |
903 } 903 }
904 } 904 }
905 return false; 905 return false;
906 } 906 }
907 } 907 }
908 908
909 // FIXME: should maybe use convex hull, not bounding box 909 // FIXME: should maybe use convex hull, not bounding box
910 totalBounds.add(subjectArea); 910 totalBounds.add(subjectArea);
911 if (totalBounds.contains(x, y)) 911 if (totalBounds.contains(x, y))
912 return true; 912 return true;
913 } 913 }
914 return false; 914 return false;
915 } 915 }
916 916
917 /** 917 /**
918 * Tests whether the given information control allows the mouse to be moved 918 * Tests whether the given information control allows the mouse to be moved
919 * into it. 919 * into it.
920 * 920 *
921 * @param iControl information control or <code>null</code> if none 921 * @param iControl information control or <code>null</code> if none
922 * @return <code>true</code> if information control allows mouse move into 922 * @return <code>true</code> if information control allows mouse move into
923 * control, <code>false</code> otherwise 923 * control, <code>false</code> otherwise
924 */ 924 */
925 bool canMoveIntoInformationControl(IInformationControl iControl) { 925 bool canMoveIntoInformationControl(IInformationControl iControl) {
926 return fEnrichMode !is null && canReplace(iControl); 926 return fEnrichMode !is null && canReplace(iControl);
927 } 927 }
928 928
929 /* 929 /*
930 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() 930 * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl()
931 */ 931 */
932 protected void hideInformationControl() { 932 protected void hideInformationControl() {
933 cancelReplacingDelay(); 933 cancelReplacingDelay();
936 936
937 /** 937 /**
938 * Sets the hover enrich mode. Only applicable when an information 938 * Sets the hover enrich mode. Only applicable when an information
939 * control replacer has been set with 939 * control replacer has been set with
940 * {@link #setInformationControlReplacer(InformationControlReplacer)} . 940 * {@link #setInformationControlReplacer(InformationControlReplacer)} .
941 * 941 *
942 * @param mode the enrich mode 942 * @param mode the enrich mode
943 * @since 3.4 943 * @since 3.4
944 * @see ITextViewerExtension8#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode) 944 * @see ITextViewerExtension8#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode)
945 */ 945 */
946 void setHoverEnrichMode(EnrichMode mode) { 946 void setHoverEnrichMode(EnrichMode mode) {
947 fEnrichMode= mode; 947 fEnrichMode= mode;
948 } 948 }
949 949
950 /* 950 /*
951 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) 951 * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool)
952 */ 952 */
953 void replaceInformationControl(bool takeFocus) { 953 void replaceInformationControl(bool takeFocus) {
954 fWaitForMouseUp= false; 954 fWaitForMouseUp= false;
955 super.replaceInformationControl(takeFocus); 955 super.replaceInformationControl(takeFocus);
956 } 956 }
957 957
958 /** 958 /**
959 * Cancels the replacing delay job. 959 * Cancels the replacing delay job.
960 * @return <code>true</code> iff canceling was successful, <code>false</code> if replacing has already started 960 * @return <code>true</code> iff canceling was successful, <code>false</code> if replacing has already started
961 */ 961 */
962 bool cancelReplacingDelay() { 962 bool cancelReplacingDelay() {
963 fWaitForMouseUp= false; 963 fWaitForMouseUp= false;
964 if (fReplacingDelayJob !is null && fReplacingDelayJob.getState() !is Job.RUNNING) { 964 if (fReplacingDelayJob !is null && fReplacingDelayJob.getState() !is Job.RUNNING) {
965 bool cancelled= fReplacingDelayJob.cancel(); 965 bool cancelled= fReplacingDelayJob.cancel();
966 fReplacingDelayJob= null; 966 fReplacingDelayJob= null;
967 // if cast(DEBUG) 967 // if (DEBUG)
968 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): cancelled=" + cancelled); //$NON-NLS-1$ 968 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): cancelled=" + cancelled); //$NON-NLS-1$
969 return cancelled; 969 return cancelled;
970 } 970 }
971 // if cast(DEBUG) 971 // if (DEBUG)
972 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): not delayed"); //$NON-NLS-1$ 972 // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): not delayed"); //$NON-NLS-1$
973 return true; 973 return true;
974 } 974 }
975 975
976 /** 976 /**
977 * Starts replacing the information control, considering the current 977 * Starts replacing the information control, considering the current
978 * {@link ITextViewerExtension8.EnrichMode}. 978 * {@link ITextViewerExtension8.EnrichMode}.
979 * If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this 979 * If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this
980 * method cancels previous requests and restarts the delay timer. 980 * method cancels previous requests and restarts the delay timer.
981 * 981 *
982 * @param display the display to be used for the call to 982 * @param display the display to be used for the call to
983 * {@link #replaceInformationControl(bool)} in the UI thread 983 * {@link #replaceInformationControl(bool)} in the UI thread
984 */ 984 */
985 private void startReplaceInformationControl(final Display display) { 985 private void startReplaceInformationControl(final Display display) {
986 if (fEnrichMode is EnrichMode.ON_CLICK) 986 if (fEnrichMode is EnrichMode.ON_CLICK)
987 return; 987 return;
988 988
989 if (fReplacingDelayJob !is null) { 989 if (fReplacingDelayJob !is null) {
990 if (fReplacingDelayJob.getState() !is Job.RUNNING) { 990 if (fReplacingDelayJob.getState() !is Job.RUNNING) {
991 if (fReplacingDelayJob.cancel()) { 991 if (fReplacingDelayJob.cancel()) {
992 if (fEnrichMode is EnrichMode.IMMEDIATELY) { 992 if (fEnrichMode is EnrichMode.IMMEDIATELY) {
993 fReplacingDelayJob= null; 993 fReplacingDelayJob= null;
994 if (! fWaitForMouseUp) 994 if (! fWaitForMouseUp)
995 replaceInformationControl(false); 995 replaceInformationControl(false);
996 } else { 996 } else {
997 // if cast(DEBUG) 997 // if (DEBUG)
998 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$ 998 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$
999 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); 999 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY);
1000 } 1000 }
1001 } 1001 }
1002 } 1002 }
1003 return; 1003 return;
1004 } 1004 }
1005 1005
1006 fReplacingDelayJob= new Job("AbstractHoverInformationControlManager Replace Delayer") { //$NON-NLS-1$ 1006 fReplacingDelayJob= new Job("AbstractHoverInformationControlManager Replace Delayer") { //$NON-NLS-1$
1007 public IStatus run(final IProgressMonitor monitor) { 1007 public IStatus run(final IProgressMonitor monitor) {
1008 if (monitor.isCanceled() || display.isDisposed()) { 1008 if (monitor.isCanceled() || display.isDisposed()) {
1009 return Status.CANCEL_STATUS; 1009 return Status.CANCEL_STATUS;
1010 } 1010 }
1020 return Status.OK_STATUS; 1020 return Status.OK_STATUS;
1021 } 1021 }
1022 }; 1022 };
1023 fReplacingDelayJob.setSystem(true); 1023 fReplacingDelayJob.setSystem(true);
1024 fReplacingDelayJob.setPriority(Job.INTERACTIVE); 1024 fReplacingDelayJob.setPriority(Job.INTERACTIVE);
1025 // if cast(DEBUG) 1025 // if (DEBUG)
1026 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): scheduled"); //$NON-NLS-1$ 1026 // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): scheduled"); //$NON-NLS-1$
1027 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); 1027 fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY);
1028 } 1028 }
1029 1029
1030 /* 1030 /*
1105 * @return the DWT event state of the most recent mouse hover event 1105 * @return the DWT event state of the most recent mouse hover event
1106 */ 1106 */
1107 protected int getHoverEventStateMask() { 1107 protected int getHoverEventStateMask() {
1108 return fHoverEventStateMask; 1108 return fHoverEventStateMask;
1109 } 1109 }
1110 1110
1111 /** 1111 /**
1112 * Returns an adapter that gives access to internal methods. 1112 * Returns an adapter that gives access to internal methods.
1113 * <p> 1113 * <p>
1114 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.</p> 1114 * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.</p>
1115 * 1115 *
1116 * @return the replaceable information control accessor 1116 * @return the replaceable information control accessor
1117 * @since 3.4 1117 * @since 3.4
1118 * @noreference This method is not intended to be referenced by clients. 1118 * @noreference This method is not intended to be referenced by clients.
1119 * @nooverride This method is not intended to be re-implemented or extended by clients. 1119 * @nooverride This method is not intended to be re-implemented or extended by clients.
1120 */ 1120 */