This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 181533
Collapse All | Expand All

(-)a/debugger.jpda.projects/nbproject/project.xml (-7 / +7 lines)
Lines 94-100 Link Here
94
                    <compile-dependency/>
94
                    <compile-dependency/>
95
                    <run-dependency>
95
                    <run-dependency>
96
                        <release-version>2</release-version>
96
                        <release-version>2</release-version>
97
                        <specification-version>2.1</specification-version>
97
                        <specification-version>2.10</specification-version>
98
                    </run-dependency>
98
                    </run-dependency>
99
                </dependency>
99
                </dependency>
100
                <dependency>
100
                <dependency>
Lines 244-260 Link Here
244
                    <code-name-base>org.openide.util</code-name-base>
244
                    <code-name-base>org.openide.util</code-name-base>
245
                    <build-prerequisite/>
245
                    <build-prerequisite/>
246
                    <compile-dependency/>
246
                    <compile-dependency/>
247
		    <run-dependency>
247
                    <run-dependency>
248
                       <specification-version>8.0</specification-version>
248
                        <specification-version>8.0</specification-version>
249
	             </run-dependency>
249
                    </run-dependency>
250
                </dependency>
250
                </dependency>
251
                <dependency>
251
                <dependency>
252
                    <code-name-base>org.openide.util.lookup</code-name-base>
252
                    <code-name-base>org.openide.util.lookup</code-name-base>
253
                    <build-prerequisite/>
253
                    <build-prerequisite/>
254
                    <compile-dependency/>
254
                    <compile-dependency/>
255
		    <run-dependency>
255
                    <run-dependency>
256
                       <specification-version>8.0</specification-version>
256
                        <specification-version>8.0</specification-version>
257
	             </run-dependency>
257
                    </run-dependency>
258
                </dependency>
258
                </dependency>
259
                <dependency>
259
                <dependency>
260
                    <code-name-base>org.openide.windows</code-name-base>
260
                    <code-name-base>org.openide.windows</code-name-base>
(-)a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ToolTipAnnotation.java (-1 / +3 lines)
Lines 87-93 Link Here
87
import org.netbeans.api.java.source.JavaSource.Phase;
87
import org.netbeans.api.java.source.JavaSource.Phase;
88
import org.netbeans.api.java.source.TreeUtilities;
88
import org.netbeans.api.java.source.TreeUtilities;
89
import org.netbeans.editor.BaseDocument;
89
import org.netbeans.editor.BaseDocument;
90
import org.netbeans.editor.PopupManager;
90
import org.netbeans.editor.Utilities;
91
import org.netbeans.editor.Utilities;
92
import org.netbeans.editor.ext.ToolTipSupport;
91
import org.netbeans.modules.parsing.api.ParserManager;
93
import org.netbeans.modules.parsing.api.ParserManager;
92
import org.netbeans.modules.parsing.api.ResultIterator;
94
import org.netbeans.modules.parsing.api.ResultIterator;
93
import org.netbeans.modules.parsing.api.Source;
95
import org.netbeans.modules.parsing.api.Source;
Lines 264-270 Link Here
264
                    et.repaint();
266
                    et.repaint();
265
                    SwingUtilities.invokeLater(new Runnable() {
267
                    SwingUtilities.invokeLater(new Runnable() {
266
                        public @Override void run() {
268
                        public @Override void run() {
267
                            Utilities.getEditorUI(ep).getToolTipSupport().setToolTip(et);
269
                            Utilities.getEditorUI(ep).getToolTipSupport().setToolTip(et, PopupManager.ViewPortBounds, PopupManager.AbovePreferred, 0, 0, ToolTipSupport.FLAGS_HEAVYWEIGHT_TOOLTIP);
268
                        }
270
                        }
269
                    });
271
                    });
270
                }
272
                }
(-)a/editor.lib/apichanges.xml (+21 lines)
Lines 104-109 Link Here
104
    <!-- ACTUAL CHANGES BEGIN HERE: -->
104
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
105
106
    <changes>
106
    <changes>
107
        <change id="ToolTipSupport-heavyweight-tooltips">
108
            <summary>Support for heavyweight tooltips</summary>
109
            <version major="2" minor="10"/>
110
            <date day="5" month="5" year="2010"/>
111
            <author login="vstejskal"/>
112
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes" deprecation="no" deletion="no" modification="no" />
113
            <description>
114
                <p>
115
                    Adding flags to <code>o.n.editor.ext.ToolTipSupport</code> class that control
116
                    tooltip behavior such as if the tooltip should be hidden on mouse move, timeout, etc.
117
                    The flags are <code>FLAG_HIDE_ON_MOUSE_MOVE</code>, <code>FLAG_HIDE_ON_TIMER</code>, <code>FLAG_PERMANENT</code>
118
                    and <code>FLAGS_LIGHTWEIGHT_TOOLTIP</code>, <code>FLAGS_HEAVYWEIGHT_TOOLTIP</code>.
119
                </p>
120
                <p>
121
                    A new method <code>ToolTipSupport.setTooltip()</code> accepting the additional <code>flags</code>
122
                    parameter has also been added.
123
                </p>
124
            </description>
125
            <issue number="181533"/>
126
        </change>
127
107
        <change id="Utilities.createSingleLineEditor">
128
        <change id="Utilities.createSingleLineEditor">
108
            <summary>Adding Utilities.createSingleLineEditor</summary>
129
            <summary>Adding Utilities.createSingleLineEditor</summary>
109
            <version major="2" minor="7"/>
130
            <version major="2" minor="7"/>
(-)a/editor.lib/nbproject/project.properties (-1 / +1 lines)
Lines 39-45 Link Here
39
39
40
javac.compilerargs=-Xlint:unchecked
40
javac.compilerargs=-Xlint:unchecked
41
javac.source=1.6
41
javac.source=1.6
42
spec.version.base=2.9.0
42
spec.version.base=2.10.0
43
is.autoload=true
43
is.autoload=true
44
44
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
(-)a/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java (-40 / +82 lines)
Lines 106-111 Link Here
106
 */
106
 */
107
public class ToolTipSupport {
107
public class ToolTipSupport {
108
108
109
    // -J-Dorg.netbeans.editor.ext.ToolTipSupport.level=FINE
109
    private static final Logger LOG = Logger.getLogger(ToolTipSupport.class.getName());
110
    private static final Logger LOG = Logger.getLogger(ToolTipSupport.class.getName());
110
111
111
    static {
112
    static {
Lines 189-222 Link Here
189
190
190
    private static final MouseListener NO_OP_MOUSE_LISTENER = new MouseAdapter() {};
191
    private static final MouseListener NO_OP_MOUSE_LISTENER = new MouseAdapter() {};
191
192
193
    /** @Since 2.10 */
194
    public static final int FLAG_HIDE_ON_MOUSE_MOVE = 1;
195
    /** @Since 2.10 */
196
    public static final int FLAG_HIDE_ON_TIMER = 2;
197
    /** @Since 2.10 */
198
    public static final int FLAG_PERMANENT = 4;
199
200
    /** @Since 2.10 */
201
    public static final int FLAGS_LIGHTWEIGHT_TOOLTIP = FLAG_HIDE_ON_MOUSE_MOVE | FLAG_HIDE_ON_TIMER;
202
    /** @Since 2.10 */
203
    public static final int FLAGS_HEAVYWEIGHT_TOOLTIP = FLAG_PERMANENT;
204
192
    private final EditorUI extEditorUI;
205
    private final EditorUI extEditorUI;
193
194
    private JComponent toolTip;
195
196
    private String toolTipText;
197
    
198
    private final Timer enterTimer;
206
    private final Timer enterTimer;
199
200
    private final Timer exitTimer;
207
    private final Timer exitTimer;
208
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
209
    private final Listener listener = new Listener();
201
210
202
    private boolean enabled;
211
    private boolean enabled;
203
    
212
    private MouseEvent lastMouseEvent;
204
    /** Status of the tooltip visibility. */
213
    private boolean glyphListenerAdded = false;
205
    private int status;
206
214
207
    private MouseEvent lastMouseEvent;
215
    // The actual tooltip instance related information
208
216
    private int status; // Status of the tooltip visibility
209
    private PropertyChangeSupport pcs;
217
    private JComponent toolTip;
210
    
218
    private String toolTipText;
211
    private PopupManager.HorizontalBounds horizontalBounds = PopupManager.ViewPortBounds;
219
    private PopupManager.HorizontalBounds horizontalBounds = PopupManager.ViewPortBounds;
212
    private PopupManager.Placement placement = PopupManager.AbovePreferred;
220
    private PopupManager.Placement placement = PopupManager.AbovePreferred;
213
214
    private int verticalAdjustment;
221
    private int verticalAdjustment;
215
    private int horizontalAdjustment;
222
    private int horizontalAdjustment;
216
    
223
    private int flags;
217
    private boolean glyphListenerAdded = false;
218
219
    private final Listener listener = new Listener();
220
224
221
    /** Construct new support for tooltips.
225
    /** Construct new support for tooltips.
222
     */
226
     */
Lines 258-279 Link Here
258
        setToolTip(toolTip, PopupManager.ViewPortBounds, PopupManager.AbovePreferred);
262
        setToolTip(toolTip, PopupManager.ViewPortBounds, PopupManager.AbovePreferred);
259
    }
263
    }
260
264
261
    public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, 
265
    public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement) {
262
        PopupManager.Placement placement) {
263
        setToolTip(toolTip, PopupManager.ViewPortBounds, PopupManager.AbovePreferred, 0, 0);
266
        setToolTip(toolTip, PopupManager.ViewPortBounds, PopupManager.AbovePreferred, 0, 0);
264
    }
267
    }
265
    
268
    
266
    public void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, 
269
    public void setToolTip(
267
        PopupManager.Placement placement, int horizontalAdjustment, int verticalAdjustment) {
270
        JComponent toolTip,
271
        PopupManager.HorizontalBounds horizontalBounds,
272
        PopupManager.Placement placement,
273
        int horizontalAdjustment,
274
        int verticalAdjustment
275
    ) {
276
        setToolTip(toolTip, horizontalBounds, placement, horizontalAdjustment, verticalAdjustment, FLAGS_LIGHTWEIGHT_TOOLTIP);
277
    }
278
279
    /**
280
     * @Since 2.10
281
     */
282
    public void setToolTip(
283
        JComponent toolTip,
284
        PopupManager.HorizontalBounds horizontalBounds,
285
        PopupManager.Placement placement,
286
        int horizontalAdjustment,
287
        int verticalAdjustment,
288
        int flags
289
    ) {
268
        JComponent oldToolTip = this.toolTip;
290
        JComponent oldToolTip = this.toolTip;
269
291
270
        LOG.log(Level.FINE, "setTooltip: {0}", toolTip); //NOI18N
292
        if (LOG.isLoggable(Level.FINE)) {
293
            LOG.log(Level.FINE, "setTooltip: {0}, horizontalBounds={1}, placement={2}, horizontalAdjustment={3}, verticalAdjustment={4}, flags={5}", new Object [] { //NOI18N
294
                toolTip, horizontalBounds, placement, horizontalAdjustment, verticalAdjustment, flags
295
            });
296
        }
271
        
297
        
272
        this.toolTip = toolTip;
298
        this.toolTip = toolTip;
273
        this.horizontalBounds = horizontalBounds;
299
        this.horizontalBounds = horizontalBounds;
274
        this.placement = placement;
300
        this.placement = placement;
275
        this.horizontalAdjustment = horizontalAdjustment;
301
        this.horizontalAdjustment = horizontalAdjustment;
276
        this.verticalAdjustment = verticalAdjustment;
302
        this.verticalAdjustment = verticalAdjustment;
303
        this.flags = flags;
277
304
278
        if (this.toolTip.getClientProperty(MOUSE_LISTENER) == null) {
305
        if (this.toolTip.getClientProperty(MOUSE_LISTENER) == null) {
279
            this.toolTip.putClientProperty(MOUSE_LISTENER, NO_OP_MOUSE_LISTENER);
306
            this.toolTip.putClientProperty(MOUSE_LISTENER, NO_OP_MOUSE_LISTENER);
Lines 499-504 Link Here
499
     * @since 2.3
526
     * @since 2.3
500
     */
527
     */
501
    public void setToolTipVisible(boolean visible) {
528
    public void setToolTipVisible(boolean visible) {
529
        LOG.log(Level.FINE, "setToolTipVisible: visible={0}, status={1}, enabled={2}", new Object [] { //NOI18N
530
            visible, status, enabled
531
        });
532
502
        if (!visible) { // ensure the timers are stopped
533
        if (!visible) { // ensure the timers are stopped
503
            enterTimer.stop();
534
            enterTimer.stop();
504
            exitTimer.stop();
535
            exitTimer.stop();
Lines 524-529 Link Here
524
                            pm.uninstall(toolTip);
555
                            pm.uninstall(toolTip);
525
                        }
556
                        }
526
                    }
557
                    }
558
                    toolTip = null;
527
                }
559
                }
528
560
529
                setStatus(STATUS_HIDDEN);
561
                setStatus(STATUS_HIDDEN);
Lines 537-542 Link Here
537
    public boolean isToolTipVisible() {
569
    public boolean isToolTipVisible() {
538
        return status > STATUS_VISIBILITY_ENABLED;
570
        return status > STATUS_VISIBILITY_ENABLED;
539
    }
571
    }
572
573
    private boolean isToolTipShowing() {
574
        return toolTip != null && toolTip.isShowing();
575
    }
540
    
576
    
541
    /** @return status of the tooltip visibility. It can
577
    /** @return status of the tooltip visibility. It can
542
     * be {@link #STATUS_HIDDEN}
578
     * be {@link #STATUS_HIDDEN}
Lines 849-872 Link Here
849
        setToolTipText(component.getToolTipText());
885
        setToolTipText(component.getToolTipText());
850
    }
886
    }
851
887
852
    private synchronized PropertyChangeSupport getPCS() {
853
        if (pcs == null) {
854
            pcs = new PropertyChangeSupport(this);
855
        }
856
        return pcs;
857
    }
858
859
    /** Add the listener for the property changes. The names
888
    /** Add the listener for the property changes. The names
860
     * of the supported properties are defined
889
     * of the supported properties are defined
861
     * as "PROP_" public static string constants.
890
     * as "PROP_" public static string constants.
862
     * @param listener listener to be added.
891
     * @param listener listener to be added.
863
     */
892
     */
864
    public void addPropertyChangeListener(PropertyChangeListener listener) {
893
    public void addPropertyChangeListener(PropertyChangeListener listener) {
865
        getPCS().addPropertyChangeListener(listener);
894
        pcs.addPropertyChangeListener(listener);
866
    }
895
    }
867
    
896
    
868
    public void removePropertyChangeListener(PropertyChangeListener listener) {
897
    public void removePropertyChangeListener(PropertyChangeListener listener) {
869
        getPCS().removePropertyChangeListener(listener);
898
        pcs.removePropertyChangeListener(listener);
870
    }
899
    }
871
    
900
    
872
    /** Fire the change of the given property.
901
    /** Fire the change of the given property.
Lines 874-882 Link Here
874
     * @param oldValue old value of the property
903
     * @param oldValue old value of the property
875
     * @param newValue new value of the property.
904
     * @param newValue new value of the property.
876
     */
905
     */
877
    protected void firePropertyChange(String propertyName,
906
    protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
878
    Object oldValue, Object newValue) {
907
        pcs.firePropertyChange(propertyName, oldValue, newValue);
879
        getPCS().firePropertyChange(propertyName, oldValue, newValue);
880
    }
908
    }
881
    
909
    
882
    private static void filterBindings(ActionMap actionMap) {
910
    private static void filterBindings(ActionMap actionMap) {
Lines 956-965 Link Here
956
984
957
        public @Override void actionPerformed(ActionEvent evt) {
985
        public @Override void actionPerformed(ActionEvent evt) {
958
            if (evt.getSource() == enterTimer) {
986
            if (evt.getSource() == enterTimer) {
959
                setToolTipVisible(true);
987
                if (!isToolTipShowing() || (flags & FLAG_PERMANENT) == 0) {
988
                    setToolTipVisible(true);
989
                }
960
990
961
            } else if (evt.getSource() == exitTimer) {
991
            } else if (evt.getSource() == exitTimer) {
962
                setToolTipVisible(false);
992
                if (!isToolTipShowing() || (flags & FLAG_HIDE_ON_TIMER) != 0) {
993
                    setToolTipVisible(false);
994
                }
963
            }
995
            }
964
        }
996
        }
965
997
Lines 1001-1007 Link Here
1001
1033
1002
        public @Override void mouseExited(MouseEvent evt) {
1034
        public @Override void mouseExited(MouseEvent evt) {
1003
            lastMouseEvent = evt;
1035
            lastMouseEvent = evt;
1004
            if (toolTip != null && toolTip.isShowing()) {
1036
            if (isToolTipShowing()) {
1005
                Rectangle r = new Rectangle(toolTip.getLocationOnScreen(), toolTip.getSize());
1037
                Rectangle r = new Rectangle(toolTip.getLocationOnScreen(), toolTip.getSize());
1006
1038
1007
                if (LOG.isLoggable(Level.FINE)) {
1039
                if (LOG.isLoggable(Level.FINE)) {
Lines 1013-1019 Link Here
1013
                    return;
1045
                    return;
1014
                }
1046
                }
1015
            }
1047
            }
1016
            setToolTipVisible(false);
1048
1049
            if (!isToolTipShowing() || (flags & FLAG_HIDE_ON_MOUSE_MOVE) != 0) {
1050
                setToolTipVisible(false);
1051
            }
1017
        }
1052
        }
1018
1053
1019
        // -------------------------------------------------------------------
1054
        // -------------------------------------------------------------------
Lines 1026-1031 Link Here
1026
        }
1061
        }
1027
1062
1028
        public @Override void mouseMoved(MouseEvent evt) {
1063
        public @Override void mouseMoved(MouseEvent evt) {
1064
            if (LOG.isLoggable(Level.FINE)) {
1065
                LOG.log(Level.FINE, "mouseMoved: x=" + evt.getX() + "; y=" + evt.getY() + "enabled=" + enabled + ", status=" + status + ", flags=" + flags); //NOI18N
1066
            }
1067
1029
            if (toolTip != null) {
1068
            if (toolTip != null) {
1030
                Rectangle r = (Rectangle) toolTip.getClientProperty(MOUSE_MOVE_IGNORED_AREA);
1069
                Rectangle r = (Rectangle) toolTip.getClientProperty(MOUSE_MOVE_IGNORED_AREA);
1031
                if (LOG.isLoggable(Level.FINE)) {
1070
                if (LOG.isLoggable(Level.FINE)) {
Lines 1037-1043 Link Here
1037
                }
1076
                }
1038
            }
1077
            }
1039
1078
1040
            setToolTipVisible(false);
1079
            if (!isToolTipShowing() || (flags & FLAG_HIDE_ON_MOUSE_MOVE) != 0) {
1080
                setToolTipVisible(false);
1081
            }
1082
            
1041
            if (enabled) {
1083
            if (enabled) {
1042
                enterTimer.restart();
1084
                enterTimer.restart();
1043
            }
1085
            }

Return to bug 181533