63 transient Popup tipWindow;
64 /** The Window tip is being displayed in. This will be non-null if
65 * the Window tip is in differs from that of insideComponent's Window.
66 */
67 private Window window;
68 JToolTip tip;
69
70 private Rectangle popupRect = null;
71 private Rectangle popupFrameRect = null;
72
73 boolean enabled = true;
74 private boolean tipShowing = false;
75
76 private FocusListener focusChangeListener = null;
77 private MouseMotionListener moveBeforeEnterListener = null;
78 private KeyListener accessibilityKeyListener = null;
79
80 private KeyStroke postTip;
81 private KeyStroke hideTip;
82
83 // PENDING(ges)
84 protected boolean lightWeightPopupEnabled = true;
85 protected boolean heavyWeightPopupEnabled = false;
86
87 ToolTipManager() {
88 enterTimer = new Timer(750, new insideTimerAction());
89 enterTimer.setRepeats(false);
90 exitTimer = new Timer(500, new outsideTimerAction());
91 exitTimer.setRepeats(false);
92 insideTimer = new Timer(4000, new stillInsideTimerAction());
93 insideTimer.setRepeats(false);
94
95 moveBeforeEnterListener = new MoveBeforeEnterListener();
96 accessibilityKeyListener = new AccessibilityKeyListener();
97
98 postTip = KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.CTRL_MASK);
99 hideTip = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
100 }
101
102 /**
103 * Enables or disables the tooltip.
104 *
640 preferredLocation = newPreferredLocation;
641 if (showImmediately) {
642 hideTipWindow();
643 showTipWindow();
644 exitTimer.stop();
645 } else {
646 enterTimer.restart();
647 }
648 }
649 } else {
650 toolTipText = null;
651 preferredLocation = null;
652 mouseEvent = null;
653 insideComponent = null;
654 hideTipWindow();
655 enterTimer.stop();
656 exitTimer.restart();
657 }
658 }
659
660 protected class insideTimerAction implements ActionListener {
661 public void actionPerformed(ActionEvent e) {
662 if(insideComponent != null && insideComponent.isShowing()) {
663 // Lazy lookup
664 if (toolTipText == null && mouseEvent != null) {
665 toolTipText = insideComponent.getToolTipText(mouseEvent);
666 preferredLocation = insideComponent.getToolTipLocation(
667 mouseEvent);
668 }
669 if(toolTipText != null) {
670 showImmediately = true;
671 showTipWindow();
672 }
673 else {
674 insideComponent = null;
675 toolTipText = null;
676 preferredLocation = null;
677 mouseEvent = null;
678 hideTipWindow();
679 }
680 }
681 }
682 }
683
684 protected class outsideTimerAction implements ActionListener {
685 public void actionPerformed(ActionEvent e) {
686 showImmediately = false;
687 }
688 }
689
690 protected class stillInsideTimerAction implements ActionListener {
691 public void actionPerformed(ActionEvent e) {
692 hideTipWindow();
693 enterTimer.stop();
694 showImmediately = false;
695 insideComponent = null;
696 mouseEvent = null;
697 }
698 }
699
700 /* This listener is registered when the tooltip is first registered
701 * on a component in order to catch the situation where the tooltip
702 * was turned on while the mouse was already within the bounds of
703 * the component. This way, the tooltip will be initiated on a
704 * mouse-entered or mouse-moved, whichever occurs first. Once the
705 * tooltip has been initiated, we can remove this listener and rely
706 * solely on mouse-entered to initiate the tooltip.
707 */
708 private class MoveBeforeEnterListener extends MouseMotionAdapter {
709 public void mouseMoved(MouseEvent e) {
710 initiateToolTip(e);
|
63 transient Popup tipWindow;
64 /** The Window tip is being displayed in. This will be non-null if
65 * the Window tip is in differs from that of insideComponent's Window.
66 */
67 private Window window;
68 JToolTip tip;
69
70 private Rectangle popupRect = null;
71 private Rectangle popupFrameRect = null;
72
73 boolean enabled = true;
74 private boolean tipShowing = false;
75
76 private FocusListener focusChangeListener = null;
77 private MouseMotionListener moveBeforeEnterListener = null;
78 private KeyListener accessibilityKeyListener = null;
79
80 private KeyStroke postTip;
81 private KeyStroke hideTip;
82
83 /**
84 * Lightweight popup enabled.
85 */
86 protected boolean lightWeightPopupEnabled = true;
87 /**
88 * Heavyweight popup enabled.
89 */
90 protected boolean heavyWeightPopupEnabled = false;
91
92 ToolTipManager() {
93 enterTimer = new Timer(750, new insideTimerAction());
94 enterTimer.setRepeats(false);
95 exitTimer = new Timer(500, new outsideTimerAction());
96 exitTimer.setRepeats(false);
97 insideTimer = new Timer(4000, new stillInsideTimerAction());
98 insideTimer.setRepeats(false);
99
100 moveBeforeEnterListener = new MoveBeforeEnterListener();
101 accessibilityKeyListener = new AccessibilityKeyListener();
102
103 postTip = KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.CTRL_MASK);
104 hideTip = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
105 }
106
107 /**
108 * Enables or disables the tooltip.
109 *
645 preferredLocation = newPreferredLocation;
646 if (showImmediately) {
647 hideTipWindow();
648 showTipWindow();
649 exitTimer.stop();
650 } else {
651 enterTimer.restart();
652 }
653 }
654 } else {
655 toolTipText = null;
656 preferredLocation = null;
657 mouseEvent = null;
658 insideComponent = null;
659 hideTipWindow();
660 enterTimer.stop();
661 exitTimer.restart();
662 }
663 }
664
665 /**
666 * Inside timer action.
667 */
668 protected class insideTimerAction implements ActionListener {
669 /**
670 * {@inheritDoc}
671 */
672 public void actionPerformed(ActionEvent e) {
673 if(insideComponent != null && insideComponent.isShowing()) {
674 // Lazy lookup
675 if (toolTipText == null && mouseEvent != null) {
676 toolTipText = insideComponent.getToolTipText(mouseEvent);
677 preferredLocation = insideComponent.getToolTipLocation(
678 mouseEvent);
679 }
680 if(toolTipText != null) {
681 showImmediately = true;
682 showTipWindow();
683 }
684 else {
685 insideComponent = null;
686 toolTipText = null;
687 preferredLocation = null;
688 mouseEvent = null;
689 hideTipWindow();
690 }
691 }
692 }
693 }
694
695 /**
696 * Outside timer action.
697 */
698 protected class outsideTimerAction implements ActionListener {
699 /**
700 * {@inheritDoc}
701 */
702 public void actionPerformed(ActionEvent e) {
703 showImmediately = false;
704 }
705 }
706
707 /**
708 * Still inside timer action.
709 */
710 protected class stillInsideTimerAction implements ActionListener {
711 /**
712 * {@inheritDoc}
713 */
714 public void actionPerformed(ActionEvent e) {
715 hideTipWindow();
716 enterTimer.stop();
717 showImmediately = false;
718 insideComponent = null;
719 mouseEvent = null;
720 }
721 }
722
723 /* This listener is registered when the tooltip is first registered
724 * on a component in order to catch the situation where the tooltip
725 * was turned on while the mouse was already within the bounds of
726 * the component. This way, the tooltip will be initiated on a
727 * mouse-entered or mouse-moved, whichever occurs first. Once the
728 * tooltip has been initiated, we can remove this listener and rely
729 * solely on mouse-entered to initiate the tooltip.
730 */
731 private class MoveBeforeEnterListener extends MouseMotionAdapter {
732 public void mouseMoved(MouseEvent e) {
733 initiateToolTip(e);
|