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 262312
Collapse All | Expand All

(-)a/debugger.jpda.jsui/nbproject/project.properties (-1 / +1 lines)
Lines 42-47 Link Here
42
42
43
cp.extra=${tools.jar}
43
cp.extra=${tools.jar}
44
javac.compilerargs=-Xlint:unchecked
44
javac.compilerargs=-Xlint:unchecked
45
javac.source=1.7
45
javac.source=1.8
46
javadoc.arch=${basedir}/arch.xml
46
javadoc.arch=${basedir}/arch.xml
47
requires.nb.javac=true
47
requires.nb.javac=true
(-)a/debugger.jpda.jsui/nbproject/project.xml (-10 / +19 lines)
Lines 95-100 Link Here
95
                    </run-dependency>
95
                    </run-dependency>
96
                </dependency>
96
                </dependency>
97
                <dependency>
97
                <dependency>
98
                    <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
99
                    <build-prerequisite/>
100
                    <compile-dependency/>
101
                    <run-dependency>
102
                        <release-version>3</release-version>
103
                        <specification-version>4.7</specification-version>
104
                    </run-dependency>
105
                </dependency>
106
                <dependency>
98
                    <code-name-base>org.netbeans.modules.java.kit</code-name-base>
107
                    <code-name-base>org.netbeans.modules.java.kit</code-name-base>
99
                    <run-dependency>
108
                    <run-dependency>
100
                        <specification-version>1.0</specification-version>
109
                        <specification-version>1.0</specification-version>
Lines 106-112 Link Here
106
                    <compile-dependency/>
115
                    <compile-dependency/>
107
                    <run-dependency>
116
                    <run-dependency>
108
                        <release-version>1</release-version>
117
                        <release-version>1</release-version>
109
                        <specification-version>1.0</specification-version>
118
                        <specification-version>1.3</specification-version>
110
                    </run-dependency>
119
                    </run-dependency>
111
                </dependency>
120
                </dependency>
112
                <dependency>
121
                <dependency>
Lines 133-139 Link Here
133
                    <compile-dependency/>
142
                    <compile-dependency/>
134
                    <run-dependency>
143
                    <run-dependency>
135
                        <release-version>1</release-version>
144
                        <release-version>1</release-version>
136
                        <specification-version>2.34</specification-version>
145
                        <specification-version>2.54</specification-version>
137
                    </run-dependency>
146
                    </run-dependency>
138
                </dependency>
147
                </dependency>
139
                <dependency>
148
                <dependency>
Lines 234-247 Link Here
234
                    </run-dependency>
243
                    </run-dependency>
235
                </dependency>
244
                </dependency>
236
                <dependency>
245
                <dependency>
237
                    <code-name-base>org.openide.util.ui</code-name-base>
238
                    <build-prerequisite/>
239
                    <compile-dependency/>
240
                    <run-dependency>
241
                        <specification-version>9.3</specification-version>
242
                    </run-dependency>
243
                </dependency>
244
                <dependency>
245
                    <code-name-base>org.openide.util</code-name-base>
246
                    <code-name-base>org.openide.util</code-name-base>
246
                    <build-prerequisite/>
247
                    <build-prerequisite/>
247
                    <compile-dependency/>
248
                    <compile-dependency/>
Lines 258-263 Link Here
258
                    </run-dependency>
259
                    </run-dependency>
259
                </dependency>
260
                </dependency>
260
                <dependency>
261
                <dependency>
262
                    <code-name-base>org.openide.util.ui</code-name-base>
263
                    <build-prerequisite/>
264
                    <compile-dependency/>
265
                    <run-dependency>
266
                        <specification-version>9.3</specification-version>
267
                    </run-dependency>
268
                </dependency>
269
                <dependency>
261
                    <code-name-base>org.openide.windows</code-name-base>
270
                    <code-name-base>org.openide.windows</code-name-base>
262
                    <build-prerequisite/>
271
                    <build-prerequisite/>
263
                    <compile-dependency/>
272
                    <compile-dependency/>
(-)a/debugger.jpda.jsui/src/org/netbeans/modules/debugger/jpda/jsui/vars/tooltip/JPDADebuggerTooltipSupport.java (-94 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.debugger.jpda.jsui.vars.tooltip;
44
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import java.io.Closeable;
48
import java.io.IOException;
49
import org.netbeans.api.debugger.jpda.CallStackFrame;
50
import org.netbeans.api.debugger.jpda.JPDADebugger;
51
import org.netbeans.modules.javascript2.debug.ui.tooltip.DebuggerTooltipSupport;
52
53
/**
54
 *
55
 * @author Martin Entlicher
56
 */
57
final class JPDADebuggerTooltipSupport implements DebuggerTooltipSupport, PropertyChangeListener {
58
    
59
    private final JPDADebugger debugger;
60
    private final CallStackFrame frame;
61
    private Closeable closeable;
62
    
63
    JPDADebuggerTooltipSupport(JPDADebugger debugger, CallStackFrame frame) {
64
        this.debugger = debugger;
65
        this.frame = frame;
66
    }
67
68
    public JPDADebugger getDebugger() {
69
        return debugger;
70
    }
71
72
    public CallStackFrame getFrame() {
73
        return frame;
74
    }
75
76
    @Override
77
    public void addCloseable(Closeable closeable) {
78
        this.closeable = closeable;
79
        debugger.addPropertyChangeListener(JPDADebugger.PROP_STATE, this);
80
    }
81
82
    @Override
83
    public void removeCloseable(Closeable closeable) {
84
        debugger.removePropertyChangeListener(JPDADebugger.PROP_STATE, this);
85
    }
86
    
87
    @Override
88
    public void propertyChange(PropertyChangeEvent evt) {
89
        try {
90
            closeable.close();
91
        } catch (IOException ex) {}
92
    }
93
    
94
}
(-)a/debugger.jpda.jsui/src/org/netbeans/modules/debugger/jpda/jsui/vars/tooltip/ToolTipAnnotation.java (-11 / +34 lines)
Lines 42-48 Link Here
42
42
43
package org.netbeans.modules.debugger.jpda.jsui.vars.tooltip;
43
package org.netbeans.modules.debugger.jpda.jsui.vars.tooltip;
44
44
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
45
import java.util.concurrent.CancellationException;
47
import java.util.concurrent.CancellationException;
48
import javax.swing.SwingUtilities;
46
import org.netbeans.api.debugger.DebuggerEngine;
49
import org.netbeans.api.debugger.DebuggerEngine;
47
import org.netbeans.api.debugger.Session;
50
import org.netbeans.api.debugger.Session;
48
import org.netbeans.api.debugger.jpda.CallStackFrame;
51
import org.netbeans.api.debugger.jpda.CallStackFrame;
Lines 50-55 Link Here
50
import org.netbeans.api.debugger.jpda.JPDADebugger;
53
import org.netbeans.api.debugger.jpda.JPDADebugger;
51
import org.netbeans.api.debugger.jpda.ObjectVariable;
54
import org.netbeans.api.debugger.jpda.ObjectVariable;
52
import org.netbeans.api.debugger.jpda.Variable;
55
import org.netbeans.api.debugger.jpda.Variable;
56
import org.netbeans.editor.ext.ToolTipSupport;
53
import org.netbeans.modules.debugger.jpda.js.JSUtils;
57
import org.netbeans.modules.debugger.jpda.js.JSUtils;
54
import org.netbeans.modules.debugger.jpda.js.vars.DebuggerSupport;
58
import org.netbeans.modules.debugger.jpda.js.vars.DebuggerSupport;
55
import org.netbeans.modules.debugger.jpda.js.vars.JSVariable;
59
import org.netbeans.modules.debugger.jpda.js.vars.JSVariable;
Lines 60-69 Link Here
60
 *
64
 *
61
 * @author Martin
65
 * @author Martin
62
 */
66
 */
63
public final class ToolTipAnnotation extends AbstractJSToolTipAnnotation<JPDADebuggerTooltipSupport> {
67
public final class ToolTipAnnotation extends AbstractJSToolTipAnnotation {
64
    
68
    
65
    @Override
69
    @Override
66
    protected JPDADebuggerTooltipSupport getEngineDebugger(Session session, DebuggerEngine engine) {
70
    protected void handleToolTipClose(DebuggerEngine engine, ToolTipSupport tts) {
71
        JPDADebugger d = engine.lookupFirst(null, JPDADebugger.class);
72
        if (d == null) {
73
            return ;
74
        }
75
        PropertyChangeListener l = (PropertyChangeEvent evt) -> {
76
            int state = ((Integer) evt.getNewValue());
77
            if (JPDADebugger.STATE_DISCONNECTED == state ||
78
                    JPDADebugger.STATE_RUNNING == state) {
79
                SwingUtilities.invokeLater(() ->
80
                        tts.setToolTipVisible(false)
81
                );
82
            }
83
        };
84
        d.addPropertyChangeListener(JPDADebugger.PROP_STATE, l);
85
        tts.addPropertyChangeListener(pl -> {
86
            if (ToolTipSupport.PROP_STATUS.equals(pl.getPropertyName()) &&
87
                    !tts.isToolTipVisible()) {
88
                d.removePropertyChangeListener(JPDADebugger.PROP_STATE, l);
89
            }
90
        });
91
    }
92
    
93
    @Override
94
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine) throws CancellationException {
95
        Session session = engine.lookupFirst(null, Session.class);
67
        if (engine != session.getEngineForLanguage(JSUtils.JS_STRATUM)) {
96
        if (engine != session.getEngineForLanguage(JSUtils.JS_STRATUM)) {
68
            return null;
97
            return null;
69
        }
98
        }
Lines 75-100 Link Here
75
        if (frame == null) {
104
        if (frame == null) {
76
            return null;
105
            return null;
77
        }
106
        }
78
        return new JPDADebuggerTooltipSupport(d, frame);
79
    }
80
81
    @Override
82
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine, JPDADebuggerTooltipSupport dbg) throws CancellationException {
83
        String toolTipText;
107
        String toolTipText;
84
        CallStackFrame frame = dbg.getFrame();
85
        JSVariable jsresult = null;
108
        JSVariable jsresult = null;
86
        try {
109
        try {
87
            Variable result = DebuggerSupport.evaluate(dbg.getDebugger(), frame, expression);
110
            Variable result = DebuggerSupport.evaluate(d, frame, expression);
88
            if (result == null) {
111
            if (result == null) {
89
                throw new CancellationException();
112
                throw new CancellationException();
90
            }
113
            }
91
            if (result instanceof ObjectVariable) {
114
            if (result instanceof ObjectVariable) {
92
                jsresult = JSVariable.createIfScriptObject(dbg.getDebugger(), (ObjectVariable) result, expression);
115
                jsresult = JSVariable.createIfScriptObject(d, (ObjectVariable) result, expression);
93
            }
116
            }
94
            if (jsresult != null) {
117
            if (jsresult != null) {
95
                toolTipText = expression + " = " + jsresult.getValue();
118
                toolTipText = expression + " = " + jsresult.getValue();
96
            } else {
119
            } else {
97
                toolTipText = expression + " = " + DebuggerSupport.getVarValue(dbg.getDebugger(), result);
120
                toolTipText = expression + " = " + DebuggerSupport.getVarValue(d, result);
98
            }
121
            }
99
        } catch (InvalidExpressionException ex) {
122
        } catch (InvalidExpressionException ex) {
100
            toolTipText = expression + " = >" + ex.getMessage () + "<";
123
            toolTipText = expression + " = >" + ex.getMessage () + "<";
(-)a/debugger.jpda.jsui/src/org/netbeans/modules/debugger/jpda/jsui/vars/tooltip/ToolTipModel.java (-90 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2015 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2015 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.debugger.jpda.jsui.vars.tooltip;
44
45
import org.netbeans.modules.debugger.jpda.jsui.vars.models.VariablesJSTreeModel;
46
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractJSToolTipAnnotation;
47
import org.netbeans.spi.debugger.ContextProvider;
48
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
49
import org.netbeans.spi.viewmodel.TreeModel;
50
import static org.netbeans.spi.viewmodel.TreeModel.ROOT;
51
import org.netbeans.spi.viewmodel.TreeModelFilter;
52
import org.netbeans.spi.viewmodel.UnknownTypeException;
53
54
/**
55
 *
56
 * @author Martin
57
 */
58
@DebuggerServiceRegistration(path="netbeans-JPDASession/JS/ToolTipView",
59
                             types={ TreeModelFilter.class },
60
                             position=360)
61
public class ToolTipModel extends VariablesJSTreeModel implements TreeModelFilter {
62
63
    public ToolTipModel(ContextProvider lookupProvider) {
64
        super(lookupProvider);
65
    }
66
67
    @Override
68
    public Object[] getChildren(TreeModel original, Object parent, int from, int to) throws UnknownTypeException {
69
        if (parent == ROOT) {
70
            Object ttv = AbstractJSToolTipAnnotation.getTooltipVariable();
71
            if (ttv != null) {
72
                return new Object[] { ttv };
73
            } else {
74
                return new Object[] { };
75
            }
76
        } else {
77
            return super.getChildren(original, parent, from, to);
78
        }
79
    }
80
81
    @Override
82
    public int getChildrenCount(TreeModel original, Object node) throws UnknownTypeException {
83
        if (node == ROOT) {
84
            return 1;
85
        } else {
86
            return super.getChildrenCount(original, node);
87
        }
88
    }
89
90
}
(-)a/debugger.jpda.projectsui/nbproject/project.xml (-1 / +1 lines)
Lines 220-226 Link Here
220
                    <compile-dependency/>
220
                    <compile-dependency/>
221
                    <run-dependency>
221
                    <run-dependency>
222
                        <release-version>1</release-version>
222
                        <release-version>1</release-version>
223
                        <specification-version>2.34</specification-version>
223
                        <specification-version>2.54</specification-version>
224
                    </run-dependency>
224
                    </run-dependency>
225
                </dependency>
225
                </dependency>
226
                <dependency>
226
                <dependency>
(-)03b2f960a7c3 (+86 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.projectsui;
43
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
46
import javax.swing.SwingUtilities;
47
import org.netbeans.api.debugger.jpda.JPDADebugger;
48
import org.netbeans.editor.ext.ToolTipSupport;
49
50
/**
51
 *
52
 * @author martin
53
 */
54
final class DebuggerStateChangeListener implements PropertyChangeListener, Runnable {
55
56
    private final ToolTipSupport tts;
57
58
    private DebuggerStateChangeListener(ToolTipSupport tts) {
59
        this.tts = tts;
60
    }
61
62
    static void attach(JPDADebugger d, ToolTipSupport tts) {
63
        DebuggerStateChangeListener dscl = new DebuggerStateChangeListener(tts);
64
        d.addPropertyChangeListener(JPDADebugger.PROP_STATE, dscl);
65
        tts.addPropertyChangeListener(propListener -> {
66
            if (ToolTipSupport.PROP_STATUS.equals(propListener.getPropertyName()) &&
67
                    !tts.isToolTipVisible()) {
68
                d.removePropertyChangeListener(JPDADebugger.PROP_STATE, dscl);
69
            }
70
        });
71
    }
72
73
    @Override
74
    public void propertyChange(PropertyChangeEvent evt) {
75
        int state = ((Integer) evt.getNewValue());
76
        if (JPDADebugger.STATE_DISCONNECTED == state ||
77
            JPDADebugger.STATE_RUNNING == state) {
78
            SwingUtilities.invokeLater(this);
79
        }
80
    }
81
82
    @Override
83
    public void run() {
84
        tts.setToolTipVisible(false);
85
    }
86
}
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/PinWatchExpandAction.java (-64 / +7 lines)
Lines 41-81 Link Here
41
 */
41
 */
42
package org.netbeans.modules.debugger.jpda.projectsui;
42
package org.netbeans.modules.debugger.jpda.projectsui;
43
43
44
import java.awt.event.ActionEvent;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import java.lang.ref.Reference;
44
import java.lang.ref.Reference;
48
import java.lang.ref.WeakReference;
45
import java.lang.ref.WeakReference;
49
import javax.swing.AbstractAction;
50
import javax.swing.Action;
46
import javax.swing.Action;
51
import javax.swing.Icon;
52
import javax.swing.JEditorPane;
53
import javax.swing.UIManager;
54
import org.netbeans.api.debugger.jpda.JPDADebugger;
47
import org.netbeans.api.debugger.jpda.JPDADebugger;
55
import org.netbeans.api.debugger.jpda.ObjectVariable;
48
import org.netbeans.api.debugger.jpda.ObjectVariable;
56
import org.netbeans.editor.EditorUI;
57
import org.netbeans.editor.Utilities;
58
import org.netbeans.editor.ext.ToolTipSupport;
49
import org.netbeans.editor.ext.ToolTipSupport;
59
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
50
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
60
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
51
import org.netbeans.spi.debugger.ui.AbstractExpandToolTipAction;
61
52
62
/**
53
/**
63
 *
54
 *
64
 * @author martin
55
 * @author martin
65
 */
56
 */
66
@DebuggerServiceRegistration(path = "netbeans-JPDASession/PinWatchHeadActions", types = Action.class)
57
@DebuggerServiceRegistration(path = "netbeans-JPDASession/PinWatchHeadActions", types = Action.class)
67
public class PinWatchExpandAction extends AbstractAction {
58
public class PinWatchExpandAction extends AbstractExpandToolTipAction {
68
59
69
    private final Icon toExpandIcon = UIManager.getIcon ("Tree.collapsedIcon");    // NOI18N
70
    private final Icon toCollapsIcon = UIManager.getIcon ("Tree.expandedIcon");    // NOI18N
71
    private Reference<JPDADebugger> debuggerRef;
60
    private Reference<JPDADebugger> debuggerRef;
72
    private String expression;
61
    private String expression;
73
    private Reference<ObjectVariable> varRef;
62
    private Reference<ObjectVariable> varRef;
74
    private boolean expanded;
75
63
76
    public PinWatchExpandAction() {
64
    public PinWatchExpandAction() {
77
        putValue(Action.SMALL_ICON, toExpandIcon);
78
        putValue(Action.LARGE_ICON_KEY, toExpandIcon);
79
    }
65
    }
80
66
81
    @Override
67
    @Override
Lines 97-103 Link Here
97
                synchronized (this) {
83
                synchronized (this) {
98
                    if (varRef == null || varRef.get() != value) {
84
                    if (varRef == null || varRef.get() != value) {
99
                        varRef = new WeakReference<>((ObjectVariable) value);
85
                        varRef = new WeakReference<>((ObjectVariable) value);
100
                        expanded = false;
86
//                        expanded = false;
101
                    }
87
                    }
102
                }
88
                }
103
                break;
89
                break;
Lines 113-123 Link Here
113
    }
99
    }
114
100
115
    @Override
101
    @Override
116
    public void actionPerformed(ActionEvent e) {
102
    protected void openTooltipView() {
117
        JPDADebugger debugger = null;
103
        JPDADebugger debugger = null;
118
        String exp;
104
        String exp;
119
        ObjectVariable var = null;
105
        ObjectVariable var = null;
120
        boolean expand;
121
        synchronized (this) {
106
        synchronized (this) {
122
            if (debuggerRef != null) {
107
            if (debuggerRef != null) {
123
                debugger = debuggerRef.get();
108
                debugger = debuggerRef.get();
Lines 126-180 Link Here
126
            if (varRef != null) {
111
            if (varRef != null) {
127
                var = varRef.get();
112
                var = varRef.get();
128
            }
113
            }
129
            expanded = !expanded;
130
            expand = expanded;
131
        }
114
        }
132
        if (debugger != null && exp != null && var != null) {
115
        if (debugger != null && exp != null && var != null) {
133
            if (expand) {
116
            ToolTipSupport tts = openTooltipView(expression, var);
134
                displayExpanded(debugger, expression, var);
117
            if (tts != null) {
135
                putValue(Action.SMALL_ICON, toCollapsIcon);
118
                DebuggerStateChangeListener.attach(debugger, tts);
136
                putValue(Action.LARGE_ICON_KEY, toCollapsIcon);
137
            } else {
138
                collapse();
139
                putValue(Action.SMALL_ICON, toExpandIcon);
140
                putValue(Action.LARGE_ICON_KEY, toExpandIcon);
141
            }
119
            }
142
        }
120
        }
143
    }
121
    }
144
122
145
    private void displayExpanded(JPDADebugger debugger, String expression, ObjectVariable var) {
146
        ToolTipView toolTipView = ToolTipView.getToolTipView(debugger, expression, var);
147
        JEditorPane currentEditor = EditorContextDispatcher.getDefault().getMostRecentEditor();
148
        EditorUI eui = Utilities.getEditorUI(currentEditor);
149
        if (eui != null) {
150
            final ToolTipSupport toolTipSupport = eui.getToolTipSupport();
151
            toolTipView.setToolTipSupport(toolTipSupport);
152
            toolTipSupport.setToolTipVisible(true, false);
153
            toolTipSupport.setToolTip(toolTipView);
154
            toolTipSupport.addPropertyChangeListener(new PropertyChangeListener() {
155
                @Override
156
                public void propertyChange(PropertyChangeEvent evt) {
157
                    if (ToolTipSupport.PROP_STATUS.equals(evt.getPropertyName())) {
158
                        if (!toolTipSupport.isToolTipVisible()) {
159
                            synchronized (PinWatchExpandAction.this) {
160
                                expanded = false;
161
                            }
162
                            putValue(Action.SMALL_ICON, toExpandIcon);
163
                            putValue(Action.LARGE_ICON_KEY, toExpandIcon);
164
                            toolTipSupport.removePropertyChangeListener(this);
165
                        }
166
                    }
167
                }
168
            });
169
        }
170
    }
171
    
172
    private void collapse() {
173
        JEditorPane currentEditor = EditorContextDispatcher.getDefault().getMostRecentEditor();
174
        EditorUI eui = Utilities.getEditorUI(currentEditor);
175
        if (eui != null) {
176
            eui.getToolTipSupport().setToolTipVisible(false, false);
177
        }
178
    }
179
180
}
123
}
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/ToolTipAnnotation.java (-53 / +20 lines)
Lines 51-56 Link Here
51
import java.awt.Point;
51
import java.awt.Point;
52
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionEvent;
53
import java.awt.event.ActionListener;
53
import java.awt.event.ActionListener;
54
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeListener;
54
import java.io.IOException;
56
import java.io.IOException;
55
import java.util.Arrays;
57
import java.util.Arrays;
56
import java.util.Collections;
58
import java.util.Collections;
Lines 101-106 Link Here
101
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
103
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
102
import org.netbeans.spi.debugger.ui.EditorPin;
104
import org.netbeans.spi.debugger.ui.EditorPin;
103
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
105
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
106
import org.netbeans.spi.debugger.ui.ToolTipUI;
107
import org.netbeans.spi.debugger.ui.ViewFactory;
104
import org.openide.cookies.EditorCookie;
108
import org.openide.cookies.EditorCookie;
105
import org.openide.filesystems.FileObject;
109
import org.openide.filesystems.FileObject;
106
import org.openide.loaders.DataObject;
110
import org.openide.loaders.DataObject;
Lines 112-117 Link Here
112
import org.openide.text.NbDocument;
116
import org.openide.text.NbDocument;
113
import org.openide.util.Exceptions;
117
import org.openide.util.Exceptions;
114
import org.openide.util.RequestProcessor;
118
import org.openide.util.RequestProcessor;
119
import org.openide.util.WeakListeners;
115
120
116
121
117
public class ToolTipAnnotation extends Annotation implements Runnable {
122
public class ToolTipAnnotation extends Annotation implements Runnable {
Lines 341-400 Link Here
341
        SwingUtilities.invokeLater(new Runnable() {
346
        SwingUtilities.invokeLater(new Runnable() {
342
            @Override
347
            @Override
343
            public void run() {
348
            public void run() {
344
                boolean expandable = var != null;
349
                EditorUI eui = Utilities.getEditorUI(ep);
345
                final ToolTipView.ExpandableTooltip et = ToolTipView.createExpandableTooltip(toolTip, expandable);
350
                if (eui == null) {
346
                if (expandable) {
351
                    firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
347
                    et.addExpansionListener(new ActionListener() {
352
                    return ;
348
                        @Override
349
                        public void actionPerformed(ActionEvent e) {
350
                            et.setBorder(BorderFactory.createLineBorder(et.getForeground()));
351
                            et.removeAll();
352
                            et.setWidthCheck(false);
353
                            final ToolTipView ttView = ToolTipView.getToolTipView(d, expression, var);
354
                            et.add(ttView);
355
                            et.revalidate();
356
                            et.repaint();
357
                            SwingUtilities.invokeLater(new Runnable() {
358
                                public @Override void run() {
359
                                    EditorUI eui = Utilities.getEditorUI(ep);
360
                                    if (eui != null) {
361
                                        ttView.setToolTipSupport(eui.getToolTipSupport());
362
                                        eui.getToolTipSupport().setToolTip(et, PopupManager.ViewPortBounds, PopupManager.AbovePreferred, 0, 0, ToolTipSupport.FLAGS_HEAVYWEIGHT_TOOLTIP);
363
                                    } else {
364
                                        firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
365
                                    }
366
                                }
367
                            });
368
                        }
369
                    });
370
                }
353
                }
371
                et.addPinListener(new ActionListener() {
354
                ToolTipUI.Expandable expandable = (var != null) ?
372
                    @Override
355
                        new ToolTipUI.Expandable(expression, var) :
373
                    public void actionPerformed(ActionEvent e) {
356
                        null;
374
                        EditorUI eui = Utilities.getEditorUI(ep);
357
                ToolTipUI.Pinnable pinnable = new ToolTipUI.Pinnable(
375
                        Point location = et.getLocation();
358
                        expression,
376
                        location = eui.getStickyWindowSupport().convertPoint(location);
359
                        line.getLineNumber(),
377
                        eui.getToolTipSupport().setToolTipVisible(false);
360
                        "org.netbeans.modules.debugger.jpda.PIN_VALUE_PROVIDER");   // NOI18N
378
                        DebuggerManager dbMgr = DebuggerManager.getDebuggerManager();
361
                ToolTipUI toolTipUI = ViewFactory.getDefault().createToolTip(toolTip, expandable, pinnable);
379
                        Watch.Pin pin = new EditorPin(fo, line.getLineNumber(), location);
362
                ToolTipSupport tts = toolTipUI.show(ep);
380
                        final Watch w = dbMgr.createPinnedWatch(expression, pin);
363
                if (tts != null) {
381
                        SwingUtilities.invokeLater(new Runnable() {
364
                    DebuggerStateChangeListener.attach(d, tts);
382
                            @Override
383
                            public void run() {
384
                                try {
385
                                    PinWatchUISupport.getDefault().pin(w, "org.netbeans.modules.debugger.jpda.PIN_VALUE_PROVIDER"); // NOI18N
386
                                } catch (IllegalArgumentException ex) {
387
                                    Exceptions.printStackTrace(ex);
388
                                }
389
                            }
390
                        });
391
                    }
392
                });
393
                EditorUI eui = Utilities.getEditorUI(ep);
394
                if (eui != null) {
395
                    eui.getToolTipSupport().setToolTip(et);
396
                } else {
397
                    firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
398
                }
365
                }
399
            }
366
            }
400
        });
367
        });
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/ToolTipExpansionFilter.java (-81 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.debugger.jpda.projectsui;
43
44
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
45
import org.netbeans.spi.viewmodel.ModelListener;
46
import org.netbeans.spi.viewmodel.TreeExpansionModel;
47
import org.netbeans.spi.viewmodel.TreeExpansionModelFilter;
48
import org.netbeans.spi.viewmodel.UnknownTypeException;
49
50
/**
51
 * Assures that the variable in tooltip is expanded automatically.
52
 * 
53
 * @author Martin Entlicher
54
 */
55
@DebuggerServiceRegistration(path="netbeans-JPDASession/ToolTipView",
56
                             types=TreeExpansionModelFilter.class,
57
                             position=2000)
58
public class ToolTipExpansionFilter implements TreeExpansionModelFilter {
59
60
    @Override
61
    public boolean isExpanded(TreeExpansionModel original, Object node) throws UnknownTypeException {
62
        if (node == ToolTipView.getVariable()) {
63
            return true;
64
        } else {
65
            return original.isExpanded(node);
66
        }
67
    }
68
69
    @Override
70
    public void nodeExpanded(Object node) {}
71
72
    @Override
73
    public void nodeCollapsed(Object node) {}
74
75
    @Override
76
    public void addModelListener(ModelListener l) {}
77
78
    @Override
79
    public void removeModelListener(ModelListener l) {}
80
    
81
}
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/ToolTipNodeModelFilter.java (-137 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.debugger.jpda.projectsui;
44
45
import java.awt.datatransfer.Transferable;
46
import java.io.IOException;
47
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
48
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
49
import org.netbeans.spi.viewmodel.ExtendedNodeModelFilter;
50
import org.netbeans.spi.viewmodel.ModelListener;
51
import org.netbeans.spi.viewmodel.NodeModel;
52
import org.netbeans.spi.viewmodel.UnknownTypeException;
53
import org.openide.util.datatransfer.PasteType;
54
55
/**
56
 *
57
 * @author martin
58
 */
59
@DebuggerServiceRegistration(path="netbeans-JPDASession/ToolTipView",
60
                             types=ExtendedNodeModelFilter.class,
61
                             position=375)
62
public class ToolTipNodeModelFilter implements ExtendedNodeModelFilter {
63
64
    @Override
65
    public String getDisplayName(NodeModel original, Object node) throws UnknownTypeException {
66
        String dn;
67
        try {
68
            dn = original.getDisplayName(node);
69
        } catch (UnknownTypeException utex) {
70
            dn = "";
71
        }
72
        if (node == ToolTipView.getVariable() && dn.length() == 0) {
73
            return ToolTipView.getExpression();
74
        } else {
75
            return dn;
76
        }
77
    }
78
79
    @Override
80
    public String getIconBase(NodeModel original, Object node) throws UnknownTypeException {
81
        return original.getIconBase(node);
82
    }
83
84
    @Override
85
    public String getShortDescription(NodeModel original, Object node) throws UnknownTypeException {
86
        return original.getShortDescription(node);
87
    }
88
89
    @Override
90
    public void addModelListener(ModelListener l) {
91
    }
92
93
    @Override
94
    public void removeModelListener(ModelListener l) {
95
    }
96
97
    @Override
98
    public boolean canRename(ExtendedNodeModel original, Object node) throws UnknownTypeException {
99
        return original.canRename(node);
100
    }
101
102
    @Override
103
    public boolean canCopy(ExtendedNodeModel original, Object node) throws UnknownTypeException {
104
        return original.canCopy(node);
105
    }
106
107
    @Override
108
    public boolean canCut(ExtendedNodeModel original, Object node) throws UnknownTypeException {
109
        return original.canCut(node);
110
    }
111
112
    @Override
113
    public Transferable clipboardCopy(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException {
114
        return original.clipboardCopy(node);
115
    }
116
117
    @Override
118
    public Transferable clipboardCut(ExtendedNodeModel original, Object node) throws IOException, UnknownTypeException {
119
        return original.clipboardCut(node);
120
    }
121
122
    @Override
123
    public PasteType[] getPasteTypes(ExtendedNodeModel original, Object node, Transferable t) throws UnknownTypeException {
124
        return original.getPasteTypes(node, t);
125
    }
126
127
    @Override
128
    public void setName(ExtendedNodeModel original, Object node, String name) throws UnknownTypeException {
129
        original.setName(node, name);
130
    }
131
132
    @Override
133
    public String getIconBaseWithExtension(ExtendedNodeModel original, Object node) throws UnknownTypeException {
134
        return original.getIconBaseWithExtension(node);
135
    }
136
137
}
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/ToolTipTreeModelFilter.java (-98 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.debugger.jpda.projectsui;
44
45
import org.netbeans.api.debugger.jpda.ObjectVariable;
46
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
47
import org.netbeans.spi.viewmodel.ModelListener;
48
import org.netbeans.spi.viewmodel.TreeModel;
49
import org.netbeans.spi.viewmodel.TreeModelFilter;
50
import org.netbeans.spi.viewmodel.UnknownTypeException;
51
52
/**
53
 *
54
 * @author martin
55
 */
56
@DebuggerServiceRegistration(path="netbeans-JPDASession/ToolTipView",
57
                             types=TreeModelFilter.class,
58
                             position=370)
59
public class ToolTipTreeModelFilter implements TreeModelFilter {
60
61
    @Override
62
    public Object getRoot(TreeModel original) {
63
        return original.getRoot();
64
    }
65
66
    @Override
67
    public Object[] getChildren(TreeModel original, Object parent, int from, int to) throws UnknownTypeException {
68
        if (parent == TreeModel.ROOT) {
69
            ObjectVariable tooltipVar = ToolTipView.getVariable();
70
            if (tooltipVar != null) {
71
                return new Object[] { tooltipVar };
72
            } else {
73
                return new Object[] { };
74
            }
75
        } else {
76
            return original.getChildren(parent, from, to);
77
        }
78
    }
79
80
    @Override
81
    public int getChildrenCount(TreeModel original, Object node) throws UnknownTypeException {
82
        return Integer.MAX_VALUE;
83
    }
84
85
    @Override
86
    public boolean isLeaf(TreeModel original, Object node) throws UnknownTypeException {
87
        return original.isLeaf(node);
88
    }
89
90
    @Override
91
    public void addModelListener(ModelListener l) {
92
    }
93
94
    @Override
95
    public void removeModelListener(ModelListener l) {
96
    }
97
98
}
(-)a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/ToolTipView.java (-402 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.debugger.jpda.projectsui;
46
47
import java.awt.BorderLayout;
48
import java.awt.Color;
49
import java.awt.Dimension;
50
import java.awt.Font;
51
import java.awt.Insets;
52
import java.awt.Point;
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
55
import java.awt.event.KeyEvent;
56
import java.beans.PropertyChangeEvent;
57
import java.beans.PropertyChangeListener;
58
import javax.swing.AbstractAction;
59
import javax.swing.ActionMap;
60
import javax.swing.BorderFactory;
61
import javax.swing.BoxLayout;
62
import javax.swing.Icon;
63
import javax.swing.InputMap;
64
import javax.swing.JButton;
65
import javax.swing.JComponent;
66
import javax.swing.JPanel;
67
import javax.swing.JTextArea;
68
import javax.swing.KeyStroke;
69
import javax.swing.SwingUtilities;
70
import javax.swing.UIManager;
71
import javax.swing.text.BadLocationException;
72
import javax.swing.text.Document;
73
import javax.swing.text.Keymap;
74
import org.netbeans.api.debugger.jpda.JPDADebugger;
75
import org.netbeans.api.debugger.jpda.ObjectVariable;
76
import org.netbeans.editor.ext.ToolTipSupport;
77
import org.netbeans.spi.debugger.ui.ViewFactory;
78
import org.openide.util.ImageUtilities;
79
80
81
// <RAVE>
82
// Implement HelpCtx.Provider interface to provide help ids for help system
83
// public class CallStackView extends TopComponent {
84
// ====
85
public class ToolTipView extends JComponent implements org.openide.util.HelpCtx.Provider {
86
// </RAVE>
87
    
88
    public static final String TOOLTIP_VIEW_NAME = "ToolTipView";
89
90
    private static volatile String expression;
91
    private static volatile ObjectVariable variable;
92
93
    private transient JComponent contentComponent;
94
    private transient JPDADebugger debugger;
95
    private transient ToolTipSupport toolTipSupport;
96
    private transient DebuggerStateChangeListener debuggerStateChangeListener;
97
    private String name; // Store just the name persistently, we'll create the component from that
98
    
99
    private ToolTipView(JPDADebugger debugger, String expression, ObjectVariable v, String icon) {
100
        this.debugger = debugger;
101
        ToolTipView.expression = expression;
102
        variable = v;
103
        this.name = TOOLTIP_VIEW_NAME;
104
        JComponent c = ViewFactory.getDefault().createViewComponent(
105
                icon,
106
                ToolTipView.TOOLTIP_VIEW_NAME,
107
                "NetbeansDebuggerJPDAToolTipNode",
108
                null);
109
        setLayout (new BorderLayout ());
110
        add (c, BorderLayout.CENTER);  //NOI18N
111
        debuggerStateChangeListener = new DebuggerStateChangeListener();
112
        debugger.addPropertyChangeListener(JPDADebugger.PROP_STATE, debuggerStateChangeListener);
113
    }
114
115
    static String getExpression() {
116
        return expression;
117
    }
118
119
    static ObjectVariable getVariable() {
120
        return variable;
121
    }
122
123
    void setToolTipSupport(ToolTipSupport toolTipSupport) {
124
        this.toolTipSupport = toolTipSupport;
125
    }
126
    
127
    private void closeToolTip() {
128
        toolTipSupport.setToolTipVisible(false);
129
    }
130
131
    //protected void componentHidden () {
132
    @Override
133
    public void removeNotify() {
134
        super.removeNotify();//componentHidden ();
135
        variable = null;
136
        debugger.removePropertyChangeListener(JPDADebugger.PROP_STATE, debuggerStateChangeListener);
137
    }
138
    
139
    // <RAVE>
140
    // Implement getHelpCtx() with the correct help ID
141
    @Override
142
    public org.openide.util.HelpCtx getHelpCtx() {
143
        return new org.openide.util.HelpCtx("NetbeansDebuggerJPDAToolTipNode");
144
    }
145
    // </RAVE>
146
    
147
    @Override
148
    public boolean requestFocusInWindow () {
149
        super.requestFocusInWindow ();
150
        if (contentComponent == null) {
151
            return false;
152
        }
153
        return contentComponent.requestFocusInWindow ();
154
    }
155
156
    /*
157
    public void requestActive() {
158
        super.requestActive();
159
        if (contentComponent != null) {
160
            contentComponent.requestFocusInWindow ();
161
        }
162
    }
163
     */
164
165
    /*
166
    public String getName () {
167
        return NbBundle.getMessage (ToolTipView.class, displayNameResource);
168
    }
169
    
170
    public String getToolTipText () {
171
        return NbBundle.getMessage (ToolTipView.class, toolTipResource);// NOI18N
172
    }
173
     */
174
    
175
    private class DebuggerStateChangeListener implements PropertyChangeListener, Runnable {
176
177
        @Override
178
        public void propertyChange(PropertyChangeEvent evt) {
179
            int state = ((Integer) evt.getNewValue()).intValue();
180
            if (JPDADebugger.STATE_DISCONNECTED == state ||
181
                JPDADebugger.STATE_RUNNING == state) {
182
                SwingUtilities.invokeLater(this);
183
            }
184
        }
185
186
        @Override
187
        public void run() {
188
            closeToolTip();
189
        }
190
        
191
    }
192
    
193
    
194
    
195
    /** Creates the view. */
196
    public static synchronized ToolTipView getToolTipView(JPDADebugger debugger, String expression, ObjectVariable v) {
197
        return new ToolTipView(
198
                debugger,
199
                expression,
200
                v,
201
                "org/netbeans/modules/debugger/resources/localsView/local_variable_16.png"
202
        );
203
    }
204
    
205
    
206
    static ExpandableTooltip createExpandableTooltip(String toolTipText, boolean expandable) {
207
        return new ExpandableTooltip(toolTipText, expandable);
208
    }
209
210
    static class ExpandableTooltip extends JPanel {
211
212
        private static final String UI_PREFIX = "ToolTip"; // NOI18N
213
        
214
        private JButton expButton;
215
        private JButton pinButton;
216
        private JComponent textToolTip;
217
        private boolean widthCheck = true;
218
        private boolean sizeSet = false;
219
220
        public ExpandableTooltip(String toolTipText, boolean expandable) {
221
            Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
222
            Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
223
            Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N
224
225
            if (backColor != null) {
226
                setBackground(backColor);
227
            }
228
            setOpaque(true);
229
            setBorder(BorderFactory.createCompoundBorder(
230
                BorderFactory.createLineBorder(getForeground()),
231
                BorderFactory.createEmptyBorder(0, 3, 0, 3)
232
            ));
233
234
            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
235
            pinButton = new JButton(ImageUtilities.loadImageIcon("org/netbeans/editor/resources/pin.png", false));
236
            pinButton.setBorder(new javax.swing.border.EmptyBorder(0, 3, 0, 0));
237
            pinButton.setBorderPainted(false);
238
            pinButton.setContentAreaFilled(false);
239
            add(pinButton);
240
            if (expandable) {
241
                Icon expIcon = UIManager.getIcon ("Tree.collapsedIcon");    // NOI18N
242
                expButton = new JButton(expIcon);
243
                expButton.setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 5));
244
                expButton.setBorderPainted(false);
245
                expButton.setContentAreaFilled(false);
246
                add(expButton);
247
            }
248
            //JLabel l = new JLabel(toolTipText);
249
            // Multi-line tooltip:
250
            JTextArea l = createMultiLineToolTip(toolTipText, true);
251
            if (font != null) {
252
                l.setFont(font);
253
            }
254
            if (foreColor != null) {
255
                l.setForeground(foreColor);
256
            }
257
            if (backColor != null) {
258
                l.setBackground(backColor);
259
            }
260
            l.setBorder(new javax.swing.border.EmptyBorder(0, 3, 0, 3));
261
            textToolTip = l;
262
            add(l);
263
            InputMap im = new InputMap();
264
            im.setParent(getInputMap());
265
            setInputMap(WHEN_FOCUSED, im);
266
            ActionMap am = new ActionMap();
267
            am.setParent(getActionMap());
268
            setActionMap(am);
269
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "expand");     // NOI18N
270
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "pin");        // NOI18N
271
            if (expandable) {
272
                am.put("expand", new AbstractAction() {                         // NOI18N
273
                    @Override
274
                    public void actionPerformed(ActionEvent e) {
275
                        expButton.doClick();
276
                    }
277
                });
278
            }
279
            am.put("pin", new AbstractAction() {                                // NOI18N
280
                @Override
281
                public void actionPerformed(ActionEvent e) {
282
                    SwingUtilities.invokeLater(() -> pinButton.doClick());
283
                }
284
            });
285
        }
286
287
        void addExpansionListener(ActionListener treeExpansionListener) {
288
            expButton.addActionListener(treeExpansionListener);
289
        }
290
        
291
        void addPinListener(ActionListener treeExpansionListener) {
292
            pinButton.addActionListener(treeExpansionListener);
293
        }
294
295
        void setWidthCheck(boolean widthCheck) {
296
            this.widthCheck = widthCheck;
297
        }
298
299
        @Override
300
        public Dimension getPreferredSize() {
301
            if (!sizeSet) {
302
                // Be big enough initially.
303
                return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
304
            }
305
            Dimension preferredSize = super.getPreferredSize();
306
            // Let the width be as long as it can be
307
            return new Dimension(Integer.MAX_VALUE, preferredSize.height);
308
        }
309
        
310
        @Override
311
        public void setSize(int width, int height) {
312
            Dimension prefSize = getPreferredSize();
313
            Dimension button1Size = (expButton != null) ? expButton.getPreferredSize() : new Dimension(0, 0);
314
            Dimension button2Size = pinButton.getPreferredSize();
315
            if (widthCheck) {
316
                Insets insets = getInsets();
317
                int textWidth = width - insets.left - button1Size.width - button2Size.width - insets.right;
318
                height = Math.max(Math.max(height, button1Size.height), button2Size.height);
319
                textToolTip.setSize(textWidth, height);
320
                Dimension textPreferredSize = textToolTip.getPreferredSize();
321
                super.setSize(
322
                        insets.left + button1Size.width + button2Size.width + textPreferredSize.width + insets.right,
323
                        insets.top + Math.max(Math.max(button1Size.height, textPreferredSize.height), button2Size.height) + insets.bottom);
324
            } else {
325
                if (height >= prefSize.height) { // enough height
326
                    height = prefSize.height;
327
                }
328
                super.setSize(width, height);
329
            }
330
            sizeSet = true;
331
        }
332
        
333
        private static JTextArea createMultiLineToolTip(String toolTipText, boolean wrapLines) {
334
            JTextArea ta = new TextToolTip(wrapLines);
335
            ta.setText(toolTipText);
336
            return ta;
337
        }
338
339
        private static class TextToolTip extends JTextArea {
340
            
341
            private static final String ELIPSIS = "..."; //NOI18N
342
            
343
            private final boolean wrapLines;
344
            
345
            public TextToolTip(boolean wrapLines) {
346
                this.wrapLines = wrapLines;
347
                setLineWrap(false); // It's necessary to have a big width of preferred size first.
348
            }
349
            
350
            public @Override void setSize(int width, int height) {
351
                Dimension prefSize = getPreferredSize();
352
                if (width >= prefSize.width) {
353
                    width = prefSize.width;
354
                } else { // smaller available width
355
                    // Set line wrapping and do super.setSize() to determine
356
                    // the real height (it will change due to line wrapping)
357
                    if (wrapLines) {
358
                        setLineWrap(true);
359
                        setWrapStyleWord(true);
360
                    }
361
                    
362
                    super.setSize(width, Integer.MAX_VALUE); // the height is unimportant
363
                    prefSize = getPreferredSize(); // re-read new pref width
364
                }
365
                if (height >= prefSize.height) { // enough height
366
                    height = prefSize.height;
367
                } else { // smaller available height
368
                    // Check how much can be displayed - cannot rely on line count
369
                    // because line wrapping may display single physical line
370
                    // into several visual lines
371
                    // Before using viewToModel() a setSize() must be called
372
                    // because otherwise the viewToModel() would return -1.
373
                    super.setSize(width, Integer.MAX_VALUE);
374
                    int offset = viewToModel(new Point(0, height));
375
                    Document doc = getDocument();
376
                    try {
377
                        if (offset > ELIPSIS.length()) {
378
                            offset -= ELIPSIS.length();
379
                            doc.remove(offset, doc.getLength() - offset);
380
                            doc.insertString(offset, ELIPSIS, null);
381
                        }
382
                    } catch (BadLocationException ble) {
383
                        // "..." will likely not be displayed but otherwise should be ok
384
                    }
385
                    // Recalculate the prefSize as it may be smaller
386
                    // than the present preferred height
387
                    height = Math.min(height, getPreferredSize().height);
388
                }
389
                super.setSize(width, height);
390
            }
391
            
392
            @Override
393
            public void setKeymap(Keymap map) {
394
                //#181722: keymaps are shared among components with the same UI
395
                //a default action will be set to the Keymap of this component below,
396
                //so it is necessary to use a Keymap that is not shared with other JTextAreas
397
                super.setKeymap(addKeymap(null, map));
398
            }
399
        }
400
    }
401
402
}
(-)a/javascript.v8debug.ui/nbproject/project.xml (-2 / +11 lines)
Lines 86-91 Link Here
86
                    </run-dependency>
86
                    </run-dependency>
87
                </dependency>
87
                </dependency>
88
                <dependency>
88
                <dependency>
89
                    <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
90
                    <build-prerequisite/>
91
                    <compile-dependency/>
92
                    <run-dependency>
93
                        <release-version>3</release-version>
94
                        <specification-version>4.7</specification-version>
95
                    </run-dependency>
96
                </dependency>
97
                <dependency>
89
                    <code-name-base>org.netbeans.modules.javascript.v8debug</code-name-base>
98
                    <code-name-base>org.netbeans.modules.javascript.v8debug</code-name-base>
90
                    <build-prerequisite/>
99
                    <build-prerequisite/>
91
                    <compile-dependency/>
100
                    <compile-dependency/>
Lines 109-115 Link Here
109
                    <compile-dependency/>
118
                    <compile-dependency/>
110
                    <run-dependency>
119
                    <run-dependency>
111
                        <release-version>1</release-version>
120
                        <release-version>1</release-version>
112
                        <specification-version>1.2</specification-version>
121
                        <specification-version>1.3</specification-version>
113
                    </run-dependency>
122
                    </run-dependency>
114
                </dependency>
123
                </dependency>
115
                <dependency>
124
                <dependency>
Lines 135-141 Link Here
135
                    <compile-dependency/>
144
                    <compile-dependency/>
136
                    <run-dependency>
145
                    <run-dependency>
137
                        <release-version>1</release-version>
146
                        <release-version>1</release-version>
138
                        <specification-version>2.49</specification-version>
147
                        <specification-version>2.54</specification-version>
139
                    </run-dependency>
148
                    </run-dependency>
140
                </dependency>
149
                </dependency>
141
                <dependency>
150
                <dependency>
(-)a/javascript.v8debug.ui/src/org/netbeans/modules/javascript/v8debug/ui/vars/models/PinWatchValueProvider.java (-11 / +8 lines)
Lines 41-55 Link Here
41
 */
41
 */
42
package org.netbeans.modules.javascript.v8debug.ui.vars.models;
42
package org.netbeans.modules.javascript.v8debug.ui.vars.models;
43
43
44
import java.awt.event.ActionEvent;
45
import java.util.HashMap;
44
import java.util.HashMap;
46
import java.util.Map;
45
import java.util.Map;
47
import javax.swing.AbstractAction;
48
import javax.swing.Action;
46
import javax.swing.Action;
49
import javax.swing.Icon;
50
import javax.swing.JEditorPane;
51
import javax.swing.UIManager;
52
import org.netbeans.api.debugger.Watch;
47
import org.netbeans.api.debugger.Watch;
48
import org.netbeans.editor.ext.ToolTipSupport;
53
import org.netbeans.lib.v8debug.V8Command;
49
import org.netbeans.lib.v8debug.V8Command;
54
import org.netbeans.lib.v8debug.V8Request;
50
import org.netbeans.lib.v8debug.V8Request;
55
import org.netbeans.lib.v8debug.commands.Evaluate;
51
import org.netbeans.lib.v8debug.commands.Evaluate;
Lines 57-70 Link Here
57
import org.netbeans.modules.javascript.v8debug.V8Debugger;
53
import org.netbeans.modules.javascript.v8debug.V8Debugger;
58
import org.netbeans.modules.javascript.v8debug.V8DebuggerEngineProvider;
54
import org.netbeans.modules.javascript.v8debug.V8DebuggerEngineProvider;
59
import org.netbeans.modules.javascript.v8debug.frames.CallFrame;
55
import org.netbeans.modules.javascript.v8debug.frames.CallFrame;
60
import org.netbeans.modules.javascript.v8debug.ui.vars.tooltip.V8DebuggerTooltipSupport;
56
import org.netbeans.modules.javascript.v8debug.ui.vars.tooltip.ToolTipAnnotation;
61
import org.netbeans.modules.javascript.v8debug.vars.V8Evaluator;
57
import org.netbeans.modules.javascript.v8debug.vars.V8Evaluator;
62
import org.netbeans.modules.javascript.v8debug.vars.Variable;
58
import org.netbeans.modules.javascript.v8debug.vars.Variable;
63
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractExpandTooltipAction;
64
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractJSToolTipAnnotation;
65
import org.netbeans.spi.debugger.ContextProvider;
59
import org.netbeans.spi.debugger.ContextProvider;
66
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
60
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
67
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
61
import org.netbeans.spi.debugger.ui.AbstractExpandToolTipAction;
68
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
62
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
69
import org.openide.util.RequestProcessor;
63
import org.openide.util.RequestProcessor;
70
64
Lines 229-235 Link Here
229
        }
223
        }
230
    }
224
    }
231
225
232
    private class ExpandAction extends AbstractExpandTooltipAction {
226
    private class ExpandAction extends AbstractExpandToolTipAction {
233
227
234
        private final Variable var;
228
        private final Variable var;
235
229
Lines 239-245 Link Here
239
233
240
        @Override
234
        @Override
241
        protected void openTooltipView() {
235
        protected void openTooltipView() {
242
            openTooltipView(new V8DebuggerTooltipSupport(dbg, dbg.getCurrentFrame()), var.getName(), var);
236
            ToolTipSupport tts = openTooltipView(var.getName(), var);
237
            if (tts != null) {
238
                ToolTipAnnotation.handleToolTipClose(dbg, tts);
239
            }
243
        }
240
        }
244
241
245
    }
242
    }
(-)a/javascript.v8debug.ui/src/org/netbeans/modules/javascript/v8debug/ui/vars/models/VariablesModel.java (-2 / +7 lines)
Lines 76-81 Link Here
76
import org.netbeans.modules.javascript2.debug.ui.models.ViewModelSupport;
76
import org.netbeans.modules.javascript2.debug.ui.models.ViewModelSupport;
77
import org.netbeans.spi.debugger.ContextProvider;
77
import org.netbeans.spi.debugger.ContextProvider;
78
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
78
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
79
import org.netbeans.spi.debugger.DebuggerServiceRegistrations;
79
import org.netbeans.spi.debugger.ui.Constants;
80
import org.netbeans.spi.debugger.ui.Constants;
80
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
81
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
81
import org.netbeans.spi.viewmodel.ModelEvent;
82
import org.netbeans.spi.viewmodel.ModelEvent;
Lines 92-99 Link Here
92
 *
93
 *
93
 * @author Martin Entlicher
94
 * @author Martin Entlicher
94
 */
95
 */
95
@DebuggerServiceRegistration(path=V8DebuggerEngineProvider.ENGINE_NAME+"/LocalsView",
96
@DebuggerServiceRegistrations({
96
                             types={ TreeModel.class, ExtendedNodeModel.class, TableModel.class })
97
  @DebuggerServiceRegistration(path=V8DebuggerEngineProvider.ENGINE_NAME+"/LocalsView",
98
                               types={ TreeModel.class, ExtendedNodeModel.class, TableModel.class }),
99
  @DebuggerServiceRegistration(path=V8DebuggerEngineProvider.ENGINE_NAME+"/ToolTipView",
100
                               types={ TreeModel.class, ExtendedNodeModel.class, TableModel.class })
101
})
97
public class VariablesModel extends ViewModelSupport implements TreeModel,
102
public class VariablesModel extends ViewModelSupport implements TreeModel,
98
                                                                ExtendedNodeModel,
103
                                                                ExtendedNodeModel,
99
                                                                TableModel,
104
                                                                TableModel,
(-)a/javascript.v8debug.ui/src/org/netbeans/modules/javascript/v8debug/ui/vars/tooltip/ToolTipAnnotation.java (-11 / +50 lines)
Lines 43-50 Link Here
43
package org.netbeans.modules.javascript.v8debug.ui.vars.tooltip;
43
package org.netbeans.modules.javascript.v8debug.ui.vars.tooltip;
44
44
45
import java.util.concurrent.CancellationException;
45
import java.util.concurrent.CancellationException;
46
import javax.swing.SwingUtilities;
46
import org.netbeans.api.debugger.DebuggerEngine;
47
import org.netbeans.api.debugger.DebuggerEngine;
47
import org.netbeans.api.debugger.Session;
48
import org.netbeans.api.debugger.Session;
49
import org.netbeans.editor.ext.ToolTipSupport;
48
import org.netbeans.lib.v8debug.V8Frame;
50
import org.netbeans.lib.v8debug.V8Frame;
49
import org.netbeans.lib.v8debug.vars.V8Object;
51
import org.netbeans.lib.v8debug.vars.V8Object;
50
import org.netbeans.lib.v8debug.vars.V8Value;
52
import org.netbeans.lib.v8debug.vars.V8Value;
Lines 61-84 Link Here
61
 *
63
 *
62
 * @author Martin Entlicher
64
 * @author Martin Entlicher
63
 */
65
 */
64
public class ToolTipAnnotation extends AbstractJSToolTipAnnotation<V8DebuggerTooltipSupport> {
66
public class ToolTipAnnotation extends AbstractJSToolTipAnnotation {
65
67
66
    @Override
68
    @Override
67
    protected V8DebuggerTooltipSupport getEngineDebugger(Session session, DebuggerEngine engine) {
69
    protected void handleToolTipClose(DebuggerEngine engine, final ToolTipSupport tts) {
70
        V8Debugger debugger = engine.lookupFirst(null, V8Debugger.class);
71
        if (debugger == null) {
72
            return ;
73
        }
74
        handleToolTipClose(debugger, tts);
75
    }
76
    
77
    public static void handleToolTipClose(V8Debugger debugger, final ToolTipSupport tts) {
78
        V8Debugger.Listener listener = new V8Debugger.Listener() {
79
            @Override
80
            public void notifySuspended(boolean suspended) {
81
                if (!suspended) {
82
                    doClose();
83
                }
84
            }
85
86
            @Override
87
            public void notifyCurrentFrame(CallFrame cf) {
88
                doClose();
89
            }
90
91
            @Override
92
            public void notifyFinished() {
93
                doClose();
94
            }
95
            
96
            private void doClose() {
97
                SwingUtilities.invokeLater(() ->
98
                    tts.setToolTipVisible(false)
99
                );
100
            }
101
        };
102
        debugger.addListener(listener);
103
        tts.addPropertyChangeListener(pl -> {
104
            if (ToolTipSupport.PROP_STATUS.equals(pl.getPropertyName()) &&
105
                    !tts.isToolTipVisible()) {
106
                debugger.removeListener(listener);
107
            }
108
        });
109
    }
110
    
111
    @Override
112
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine) throws CancellationException {
113
        String toolTipText;
114
        Variable var = null;
68
        V8Debugger debugger = engine.lookupFirst(null, V8Debugger.class);
115
        V8Debugger debugger = engine.lookupFirst(null, V8Debugger.class);
69
        if (debugger == null || !debugger.isSuspended()) {
116
        if (debugger == null || !debugger.isSuspended()) {
70
            return null;
117
            return null;
71
        }
118
        }
72
        CallFrame currentFrame = debugger.getCurrentFrame();
73
        return new V8DebuggerTooltipSupport(debugger, currentFrame);
74
    }
75
76
    @Override
77
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine, V8DebuggerTooltipSupport dbg) throws CancellationException {
78
        String toolTipText;
79
        Variable var = null;
80
        try {
119
        try {
81
            V8Value value = V8Evaluator.evaluate(dbg.getDebugger(), expression);
120
            V8Value value = V8Evaluator.evaluate(debugger, expression);
82
            if (value == null) {
121
            if (value == null) {
83
                throw new CancellationException();
122
                throw new CancellationException();
84
            }
123
            }
(-)a/javascript.v8debug.ui/src/org/netbeans/modules/javascript/v8debug/ui/vars/tooltip/ToolTipModel.java (-107 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.javascript.v8debug.ui.vars.tooltip;
43
44
import org.netbeans.modules.javascript.v8debug.V8DebuggerEngineProvider;
45
import org.netbeans.modules.javascript.v8debug.ui.vars.models.VariablesModel;
46
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractJSToolTipAnnotation;
47
import org.netbeans.spi.debugger.ContextProvider;
48
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
49
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
50
import org.netbeans.spi.viewmodel.TableModel;
51
import org.netbeans.spi.viewmodel.TreeExpansionModel;
52
import org.netbeans.spi.viewmodel.TreeExpansionModelFilter;
53
import org.netbeans.spi.viewmodel.TreeModel;
54
import org.netbeans.spi.viewmodel.UnknownTypeException;
55
56
/**
57
 *
58
 * @author Martin
59
 */
60
@DebuggerServiceRegistration(path=V8DebuggerEngineProvider.ENGINE_NAME+"/ToolTipView",
61
                             types={ TreeModel.class, ExtendedNodeModel.class,
62
                                     TableModel.class, TreeExpansionModelFilter.class })
63
public class ToolTipModel extends VariablesModel implements TreeExpansionModelFilter {
64
    
65
    public ToolTipModel(ContextProvider contextProvider) {
66
        super(contextProvider);
67
    }
68
69
    @Override
70
    public int getChildrenCount(Object parent) throws UnknownTypeException {
71
        if (parent == ROOT) {
72
            return 1;
73
        } else {
74
            return super.getChildrenCount(parent);
75
        }
76
    }
77
78
    @Override
79
    public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException {
80
        if (parent == ROOT) {
81
            Object ttv = AbstractJSToolTipAnnotation.getTooltipVariable();
82
            if (ttv != null) {
83
                return new Object[] { ttv };
84
            } else {
85
                return new Object[] { };
86
            }
87
        } else {
88
            return super.getChildren(parent, from, to);
89
        }
90
    }
91
92
    @Override
93
    public boolean isExpanded(TreeExpansionModel original, Object node) throws UnknownTypeException {
94
        if (node == AbstractJSToolTipAnnotation.getTooltipVariable()) {
95
            return true;
96
        } else {
97
            return original.isExpanded(node);
98
        }
99
    }
100
101
    @Override
102
    public void nodeExpanded(Object node) {}
103
104
    @Override
105
    public void nodeCollapsed(Object node) {}
106
    
107
}
(-)a/javascript.v8debug.ui/src/org/netbeans/modules/javascript/v8debug/ui/vars/tooltip/V8DebuggerTooltipSupport.java (-118 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.javascript.v8debug.ui.vars.tooltip;
44
45
import java.io.Closeable;
46
import java.io.IOException;
47
import org.netbeans.modules.javascript.v8debug.V8Debugger;
48
import org.netbeans.modules.javascript.v8debug.frames.CallFrame;
49
import org.netbeans.modules.javascript2.debug.ui.tooltip.DebuggerTooltipSupport;
50
51
/**
52
 *
53
 * @author Martin Entlicher
54
 */
55
public class V8DebuggerTooltipSupport implements DebuggerTooltipSupport {
56
    
57
    private final V8Debugger debugger;
58
    private final CallFrame currentFrame;
59
    private V8Debugger.Listener closeableListener;
60
61
    public V8DebuggerTooltipSupport(V8Debugger debugger, CallFrame currentFrame) {
62
        this.debugger = debugger;
63
        this.currentFrame = currentFrame;
64
    }
65
66
    public V8Debugger getDebugger() {
67
        return debugger;
68
    }
69
70
    public CallFrame getCurrentFrame() {
71
        return currentFrame;
72
    }
73
74
    @Override
75
    public void addCloseable(Closeable closeable) {
76
        closeableListener = new TooltipCloseableListener(closeable);
77
        debugger.addListener(closeableListener);
78
    }
79
80
    @Override
81
    public void removeCloseable(Closeable closeable) {
82
        debugger.removeListener(closeableListener);
83
    }
84
    
85
    private static final class TooltipCloseableListener implements V8Debugger.Listener {
86
        
87
        private final Closeable closeable;
88
        
89
        public TooltipCloseableListener(Closeable closeable) {
90
            this.closeable = closeable;
91
        }
92
93
        @Override
94
        public void notifySuspended(boolean suspended) {
95
            if (!suspended) {
96
                doClose();
97
            }
98
        }
99
100
        @Override
101
        public void notifyCurrentFrame(CallFrame cf) {
102
            doClose();
103
        }
104
        
105
        @Override
106
        public void notifyFinished() {
107
            doClose();
108
        }
109
110
        private void doClose() {
111
            try {
112
                closeable.close();
113
            } catch (IOException ex) {}
114
        }
115
        
116
    }
117
    
118
}
(-)a/javascript2.debug.ui/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.javascript2.debug.ui/1
2
OpenIDE-Module: org.netbeans.modules.javascript2.debug.ui/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javascript2/debug/ui/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javascript2/debug/ui/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.2
4
OpenIDE-Module-Specification-Version: 1.3
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
6
(-)a/javascript2.debug.ui/nbproject/project.xml (-1 / +1 lines)
Lines 109-115 Link Here
109
                    <compile-dependency/>
109
                    <compile-dependency/>
110
                    <run-dependency>
110
                    <run-dependency>
111
                        <release-version>1</release-version>
111
                        <release-version>1</release-version>
112
                        <specification-version>2.13</specification-version>
112
                        <specification-version>2.54</specification-version>
113
                    </run-dependency>
113
                    </run-dependency>
114
                </dependency>
114
                </dependency>
115
                <dependency>
115
                <dependency>
(-)a/javascript2.debug.ui/src/org/netbeans/modules/javascript2/debug/ui/tooltip/AbstractExpandTooltipAction.java (-121 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.javascript2.debug.ui.tooltip;
43
44
import java.awt.event.ActionEvent;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import javax.swing.AbstractAction;
48
import javax.swing.Action;
49
import javax.swing.Icon;
50
import javax.swing.JEditorPane;
51
import javax.swing.UIManager;
52
import org.netbeans.editor.EditorUI;
53
import org.netbeans.editor.Utilities;
54
import org.netbeans.editor.ext.ToolTipSupport;
55
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
56
57
/**
58
 *
59
 * @author Martin Entlicher
60
 */
61
public abstract class AbstractExpandTooltipAction extends AbstractAction {
62
    
63
    private final Icon toExpandIcon = UIManager.getIcon ("Tree.collapsedIcon");    // NOI18N
64
    private final Icon toCollapsIcon = UIManager.getIcon ("Tree.expandedIcon");    // NOI18N
65
    private boolean expanded;
66
    
67
    protected AbstractExpandTooltipAction() {
68
        putValue(Action.SMALL_ICON, toExpandIcon);
69
        putValue(Action.LARGE_ICON_KEY, toExpandIcon);
70
    }
71
    
72
    protected abstract void openTooltipView();
73
    
74
    protected final void openTooltipView(DebuggerTooltipSupport dbg, String expression, Object var) {
75
        ToolTipView toolTipView = ToolTipView.createToolTipView(dbg, expression, var);
76
        JEditorPane currentEditor = EditorContextDispatcher.getDefault().getMostRecentEditor();
77
        EditorUI eui = Utilities.getEditorUI(currentEditor);
78
        if (eui != null) {
79
            final ToolTipSupport toolTipSupport = eui.getToolTipSupport();
80
            toolTipView.setToolTipSupport(toolTipSupport);
81
            toolTipSupport.setToolTipVisible(true, false);
82
            toolTipSupport.setToolTip(toolTipView);
83
            toolTipSupport.addPropertyChangeListener(new PropertyChangeListener() {
84
                @Override
85
                public void propertyChange(PropertyChangeEvent evt) {
86
                    if (ToolTipSupport.PROP_STATUS.equals(evt.getPropertyName())) {
87
                        if (!toolTipSupport.isToolTipVisible()) {
88
                            expanded = false;
89
                            putValue(Action.SMALL_ICON, toExpandIcon);
90
                            putValue(Action.LARGE_ICON_KEY, toExpandIcon);
91
                            toolTipSupport.removePropertyChangeListener(this);
92
                        }
93
                    }
94
                }
95
            });
96
        }
97
        
98
    }
99
    
100
    @Override
101
    public final void actionPerformed(ActionEvent e) {
102
        expanded = !expanded;
103
        if (expanded) {
104
            openTooltipView();
105
            putValue(Action.SMALL_ICON, toCollapsIcon);
106
            putValue(Action.LARGE_ICON_KEY, toCollapsIcon);
107
        } else {
108
            collapse();
109
            putValue(Action.SMALL_ICON, toExpandIcon);
110
            putValue(Action.LARGE_ICON_KEY, toExpandIcon);
111
        }
112
    }
113
114
    private void collapse() {
115
        JEditorPane currentEditor = EditorContextDispatcher.getDefault().getMostRecentEditor();
116
        EditorUI eui = Utilities.getEditorUI(currentEditor);
117
        if (eui != null) {
118
            eui.getToolTipSupport().setToolTipVisible(false, false);
119
        }
120
    }
121
}
(-)a/javascript2.debug.ui/src/org/netbeans/modules/javascript2/debug/ui/tooltip/AbstractJSToolTipAnnotation.java (-88 / +26 lines)
Lines 42-56 Link Here
42
42
43
package org.netbeans.modules.javascript2.debug.ui.tooltip;
43
package org.netbeans.modules.javascript2.debug.ui.tooltip;
44
44
45
import java.awt.Point;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
48
import java.io.IOException;
45
import java.io.IOException;
49
import java.util.Arrays;
46
import java.util.Arrays;
50
import java.util.HashSet;
47
import java.util.HashSet;
51
import java.util.Set;
48
import java.util.Set;
52
import java.util.concurrent.CancellationException;
49
import java.util.concurrent.CancellationException;
53
import javax.swing.BorderFactory;
54
import javax.swing.JEditorPane;
50
import javax.swing.JEditorPane;
55
import javax.swing.SwingUtilities;
51
import javax.swing.SwingUtilities;
56
import javax.swing.text.BadLocationException;
52
import javax.swing.text.BadLocationException;
Lines 59-72 Link Here
59
import org.netbeans.api.debugger.DebuggerEngine;
55
import org.netbeans.api.debugger.DebuggerEngine;
60
import org.netbeans.api.debugger.DebuggerManager;
56
import org.netbeans.api.debugger.DebuggerManager;
61
import org.netbeans.api.debugger.Session;
57
import org.netbeans.api.debugger.Session;
62
import org.netbeans.api.debugger.Watch;
63
import org.netbeans.editor.EditorUI;
58
import org.netbeans.editor.EditorUI;
64
import org.netbeans.editor.PopupManager;
65
import org.netbeans.editor.Utilities;
59
import org.netbeans.editor.Utilities;
66
import org.netbeans.editor.ext.ToolTipSupport;
60
import org.netbeans.editor.ext.ToolTipSupport;
67
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
61
import org.netbeans.spi.debugger.ui.EditorContextDispatcher;
68
import org.netbeans.spi.debugger.ui.EditorPin;
62
import org.netbeans.spi.debugger.ui.ToolTipUI;
69
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
63
import org.netbeans.spi.debugger.ui.ViewFactory;
70
import org.openide.cookies.EditorCookie;
64
import org.openide.cookies.EditorCookie;
71
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
72
import org.openide.loaders.DataObject;
66
import org.openide.loaders.DataObject;
Lines 75-81 Link Here
75
import org.openide.text.DataEditorSupport;
69
import org.openide.text.DataEditorSupport;
76
import org.openide.text.Line;
70
import org.openide.text.Line;
77
import org.openide.text.NbDocument;
71
import org.openide.text.NbDocument;
78
import org.openide.util.Exceptions;
79
import org.openide.util.Pair;
72
import org.openide.util.Pair;
80
import org.openide.util.RequestProcessor;
73
import org.openide.util.RequestProcessor;
81
74
Lines 83-89 Link Here
83
 *
76
 *
84
 * @author Martin Entlicher
77
 * @author Martin Entlicher
85
 */
78
 */
86
public abstract class AbstractJSToolTipAnnotation<Debugger extends DebuggerTooltipSupport> extends Annotation {
79
public abstract class AbstractJSToolTipAnnotation extends Annotation {
87
    
80
    
88
    private static final Set<String> JS_KEYWORDS = new HashSet<>(Arrays.asList(new String[] {
81
    private static final Set<String> JS_KEYWORDS = new HashSet<>(Arrays.asList(new String[] {
89
        "break",    "case",     "catch",    "class",    "continue",
82
        "break",    "case",     "catch",    "class",    "continue",
Lines 100-120 Link Here
100
    
93
    
101
    private static final RequestProcessor RP = new RequestProcessor(AbstractJSToolTipAnnotation.class);
94
    private static final RequestProcessor RP = new RequestProcessor(AbstractJSToolTipAnnotation.class);
102
    
95
    
103
    public static Object getTooltipVariable() {
104
        return ToolTipView.getVariable();
105
    }
106
107
    public static void openTooltipView(DebuggerTooltipSupport dbg, String expression, Object var) {
108
        ToolTipView toolTipView = ToolTipView.createToolTipView(dbg, expression, var);
109
        JEditorPane currentEditor = EditorContextDispatcher.getDefault().getMostRecentEditor();
110
        EditorUI eui = Utilities.getEditorUI(currentEditor);
111
        if (eui != null) {
112
            toolTipView.setToolTipSupport(eui.getToolTipSupport());
113
            eui.getToolTipSupport().setToolTipVisible(true, false);
114
            eui.getToolTipSupport().setToolTip(toolTipView);
115
        }
116
    }
117
118
    @Override
96
    @Override
119
    public String getShortDescription () {
97
    public String getShortDescription () {
120
        final Session session = DebuggerManager.getDebuggerManager ().getCurrentSession();
98
        final Session session = DebuggerManager.getDebuggerManager ().getCurrentSession();
Lines 125-134 Link Here
125
        if (engine == null) {
103
        if (engine == null) {
126
            return null;
104
            return null;
127
        }
105
        }
128
        final Debugger dbg = getEngineDebugger(session, engine);
129
        if (dbg == null) {
130
            return null;
131
        }
132
106
133
        final Line.Part lp = (Line.Part) getAttachedAnnotatable();
107
        final Line.Part lp = (Line.Part) getAttachedAnnotatable();
134
        if (lp == null) {
108
        if (lp == null) {
Lines 149-155 Link Here
149
123
150
            @Override
124
            @Override
151
            public void run() {
125
            public void run() {
152
                evaluate(session, engine, dbg, lp, ec);
126
                evaluate(session, engine/*, dbg*/, lp, ec);
153
            }
127
            }
154
        };
128
        };
155
        RequestProcessor rp = engine.lookupFirst(null, RequestProcessor.class);
129
        RequestProcessor rp = engine.lookupFirst(null, RequestProcessor.class);
Lines 161-176 Link Here
161
        return null;
135
        return null;
162
    }
136
    }
163
    
137
    
164
    protected abstract Debugger getEngineDebugger(Session session, DebuggerEngine engine);
138
    protected abstract void handleToolTipClose(DebuggerEngine engine, ToolTipSupport tts);
165
    
139
    
166
    protected abstract Pair<String, Object> evaluate(String expression, DebuggerEngine engine, Debugger dbg) throws CancellationException;
140
    protected abstract Pair<String, Object> evaluate(String expression, DebuggerEngine engine) throws CancellationException;
167
141
168
    @Override
142
    @Override
169
    public String getAnnotationType() {
143
    public String getAnnotationType() {
170
        return null;
144
        return null;
171
    }
145
    }
172
146
173
    private void evaluate(Session session, DebuggerEngine engine, final Debugger dbg,
147
    private void evaluate(Session session, final DebuggerEngine engine, //final Debugger dbg,
174
                          Line.Part lp, EditorCookie ec) {
148
                          Line.Part lp, EditorCookie ec) {
175
        final Line line = lp.getLine();
149
        final Line line = lp.getLine();
176
        if (line == null) {
150
        if (line == null) {
Lines 209-278 Link Here
209
        
183
        
210
        Pair<String, Object> toolTipTextAndVar;
184
        Pair<String, Object> toolTipTextAndVar;
211
        try {
185
        try {
212
            toolTipTextAndVar = evaluate(expression, engine, dbg);
186
            toolTipTextAndVar = evaluate(expression, engine);
213
        } catch (CancellationException ex) {
187
        } catch (CancellationException ex) {
214
            return ;
188
            return ;
215
        }
189
        }
190
        if (toolTipTextAndVar == null) {
191
            return ;
192
        }
216
        final String toolTip = truncateLongText(toolTipTextAndVar.first());
193
        final String toolTip = truncateLongText(toolTipTextAndVar.first());
217
        final Object var = toolTipTextAndVar.second();
194
        final Object var = toolTipTextAndVar.second();
218
        final boolean expandable = var != null;
219
        SwingUtilities.invokeLater(new Runnable() {
195
        SwingUtilities.invokeLater(new Runnable() {
220
            @Override
196
            @Override
221
            public void run() {
197
            public void run() {
222
                final ToolTipView.ExpandableTooltip et = ToolTipView.createExpandableTooltip(toolTip, expandable);
198
                EditorUI eui = Utilities.getEditorUI(ep);
223
                if (expandable) {
199
                if (eui == null) {
224
                    et.addExpansionListener(new ActionListener() {
200
                    firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
225
                        @Override
201
                    return ;
226
                        public void actionPerformed(ActionEvent e) {
227
                            et.setBorder(BorderFactory.createLineBorder(et.getForeground()));
228
                            et.removeAll();
229
                            et.setWidthCheck(false);
230
                            final ToolTipView ttView = ToolTipView.createToolTipView(dbg, expression, var);
231
                            et.add(ttView);
232
                            et.revalidate();
233
                            et.repaint();
234
                            SwingUtilities.invokeLater(new Runnable() {
235
                                public @Override void run() {
236
                                    EditorUI eui = Utilities.getEditorUI(ep);
237
                                    if (eui != null) {
238
                                        ttView.setToolTipSupport(eui.getToolTipSupport());
239
                                        eui.getToolTipSupport().setToolTip(et, PopupManager.ViewPortBounds, PopupManager.AbovePreferred, 0, 0, ToolTipSupport.FLAGS_HEAVYWEIGHT_TOOLTIP);
240
                                    } else {
241
                                        firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
242
                                    }
243
                                }
244
                            });
245
                        }
246
                    });
247
                }
202
                }
248
                et.addPinListener(new ActionListener() {
203
                ToolTipUI.Expandable expandable = (var != null) ?
249
                    @Override
204
                        new ToolTipUI.Expandable(expression, var) :
250
                    public void actionPerformed(ActionEvent e) {
205
                        null;
251
                        EditorUI eui = Utilities.getEditorUI(ep);
206
                ToolTipUI.Pinnable pinnable = new ToolTipUI.Pinnable(
252
                        Point location = et.getLocation();
207
                        expression,
253
                        location = eui.getStickyWindowSupport().convertPoint(location);
208
                        line.getLineNumber(),
254
                        eui.getToolTipSupport().setToolTipVisible(false);
209
                        "org.netbeans.modules.javascript2.debug.PIN_VALUE_PROVIDER"); // NOI18N
255
                        DebuggerManager dbMgr = DebuggerManager.getDebuggerManager();
210
                ToolTipUI toolTipUI = ViewFactory.getDefault().createToolTip(toolTip, expandable, pinnable);
256
                        Watch.Pin pin = new EditorPin(fo, line.getLineNumber(), location);
211
                ToolTipSupport tts = toolTipUI.show(ep);
257
                        final Watch w = dbMgr.createPinnedWatch(expression, pin);
212
                if (tts != null) {
258
                        SwingUtilities.invokeLater(new Runnable() {
213
                    handleToolTipClose(engine, tts);
259
                            @Override
260
                            public void run() {
261
                                String valueProviderId = "org.netbeans.modules.javascript2.debug.PIN_VALUE_PROVIDER"; // NOI18N
262
                                try {
263
                                    PinWatchUISupport.getDefault().pin(w, valueProviderId);
264
                                } catch (IllegalArgumentException ex) {
265
                                    Exceptions.printStackTrace(ex);
266
                                }
267
                            }
268
                        });
269
                    }
270
                });
271
                EditorUI eui = Utilities.getEditorUI(ep);
272
                if (eui != null) {
273
                    eui.getToolTipSupport().setToolTip(et);
274
                } else {
275
                    firePropertyChange (PROP_SHORT_DESCRIPTION, null, toolTip);
276
                }
214
                }
277
            }
215
            }
278
        });
216
        });
(-)a/javascript2.debug.ui/src/org/netbeans/modules/javascript2/debug/ui/tooltip/DebuggerTooltipSupport.java (-69 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.javascript2.debug.ui.tooltip;
44
45
import java.io.Closeable;
46
47
/**
48
 * An abstract debugger tool-tip support.
49
 * 
50
 * @author Martin Entlicher
51
 */
52
public interface DebuggerTooltipSupport {
53
    
54
    /**
55
     * Add a closeable tool-tip.
56
     * The debugger should call it when the tool-tip should close -
57
     * e.g. when debugger resumes or finishes.
58
     * @param closeable To be called to close the tool-tip.
59
     */
60
    void addCloseable(Closeable closeable);
61
    
62
    /**
63
     * Clean-up the closeable.
64
     * Called when the closeable no longer lives.
65
     * @param closeable 
66
     */
67
    void removeCloseable(Closeable closeable);
68
    
69
}
(-)a/javascript2.debug.ui/src/org/netbeans/modules/javascript2/debug/ui/tooltip/ToolTipView.java (-366 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.javascript2.debug.ui.tooltip;
46
47
import java.awt.BorderLayout;
48
import java.awt.Color;
49
import java.awt.Dimension;
50
import java.awt.Font;
51
import java.awt.Insets;
52
import java.awt.Point;
53
import java.awt.event.ActionListener;
54
import java.io.Closeable;
55
import java.io.IOException;
56
import java.util.List;
57
import javax.swing.BorderFactory;
58
import javax.swing.BoxLayout;
59
import javax.swing.Icon;
60
import javax.swing.JButton;
61
import javax.swing.JComponent;
62
import javax.swing.JPanel;
63
import javax.swing.JTextArea;
64
import javax.swing.SwingUtilities;
65
import javax.swing.UIManager;
66
import javax.swing.text.BadLocationException;
67
import javax.swing.text.Document;
68
import javax.swing.text.Keymap;
69
import org.netbeans.editor.ext.ToolTipSupport;
70
import org.netbeans.spi.debugger.ui.ViewFactory;
71
import org.openide.util.ImageUtilities;
72
73
// <RAVE>
74
// Implement HelpCtx.Provider interface to provide help ids for help system
75
// public class CallStackView extends TopComponent {
76
// ====
77
final class ToolTipView extends JComponent implements org.openide.util.HelpCtx.Provider {
78
// </RAVE>
79
    
80
    public static final String TOOLTIP_VIEW_NAME = "ToolTipView";
81
82
    private static volatile String expression;
83
    private static volatile Object variable;
84
85
    private transient JComponent contentComponent;
86
    private final DebuggerTooltipSupport dbgts;
87
    private final DebuggerStateChangeListener debuggerStateChangeListener;
88
    private ToolTipSupport toolTipSupport;
89
    private String name; // Store just the name persistently, we'll create the component from that
90
    
91
    private ToolTipView(DebuggerTooltipSupport dbgts, String expression, Object v, String icon) {
92
        this.dbgts = dbgts;
93
        ToolTipView.expression = expression;
94
        variable = v;
95
        this.name = TOOLTIP_VIEW_NAME;
96
        JComponent c = ViewFactory.getDefault().createViewComponent(
97
                icon,
98
                ToolTipView.TOOLTIP_VIEW_NAME,
99
                "NetbeansDebuggerJSToolTipNode",
100
                null);
101
        setLayout (new BorderLayout ());
102
        add (c, BorderLayout.CENTER);  //NOI18N
103
        debuggerStateChangeListener = new DebuggerStateChangeListener();
104
        dbgts.addCloseable(debuggerStateChangeListener);
105
    }
106
107
    static String getExpression() {
108
        return expression;
109
    }
110
111
    static Object getVariable() {
112
        return variable;
113
    }
114
115
    void setToolTipSupport(ToolTipSupport toolTipSupport) {
116
        this.toolTipSupport = toolTipSupport;
117
    }
118
    
119
    private void closeToolTip() {
120
        if (!SwingUtilities.isEventDispatchThread()) {
121
            SwingUtilities.invokeLater(new Runnable() {
122
                @Override
123
                public void run() {
124
                    toolTipSupport.setToolTipVisible(false);
125
                }
126
            });
127
        } else {
128
            toolTipSupport.setToolTipVisible(false);
129
        }
130
    }
131
    
132
    //protected void componentHidden () {
133
    @Override
134
    public void removeNotify() {
135
        super.removeNotify();//componentHidden ();
136
        variable = null;
137
        dbgts.removeCloseable(debuggerStateChangeListener);
138
    }
139
    
140
    // <RAVE>
141
    // Implement getHelpCtx() with the correct help ID
142
    @Override
143
    public org.openide.util.HelpCtx getHelpCtx() {
144
        return new org.openide.util.HelpCtx("NetbeansDebuggerJSToolTipNode");
145
    }
146
    // </RAVE>
147
    
148
    @Override
149
    public boolean requestFocusInWindow () {
150
        super.requestFocusInWindow ();
151
        if (contentComponent == null) return false;
152
        return contentComponent.requestFocusInWindow ();
153
    }
154
155
    /*
156
    public void requestActive() {
157
        super.requestActive();
158
        if (contentComponent != null) {
159
            contentComponent.requestFocusInWindow ();
160
        }
161
    }
162
     */
163
164
    /*
165
    public String getName () {
166
        return NbBundle.getMessage (ToolTipView.class, displayNameResource);
167
    }
168
    
169
    public String getToolTipText () {
170
        return NbBundle.getMessage (ToolTipView.class, toolTipResource);// NOI18N
171
    }
172
     */
173
    
174
175
    /** Creates the view. */
176
    public static synchronized ToolTipView createToolTipView(DebuggerTooltipSupport dbg, String expression, Object variable) {
177
        return new ToolTipView(
178
                dbg,
179
                expression,
180
                variable,
181
                "org/netbeans/modules/debugger/resources/localsView/local_variable_16.png"
182
        );
183
    }
184
    
185
    
186
    static ExpandableTooltip createExpandableTooltip(String toolTipText, boolean expandable) {
187
        return new ExpandableTooltip(toolTipText, expandable);
188
    }
189
190
    static class ExpandableTooltip extends JPanel {
191
192
        private static final String UI_PREFIX = "ToolTip"; // NOI18N
193
        
194
        private JButton expButton;
195
        private JButton pinButton;
196
        private JComponent textToolTip;
197
        private boolean widthCheck = true;
198
        private boolean sizeSet = false;
199
200
        public ExpandableTooltip(String toolTipText, boolean expandable) {
201
            Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
202
            Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
203
            Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N
204
205
            if (backColor != null) {
206
                setBackground(backColor);
207
            }
208
            setOpaque(true);
209
            setBorder(BorderFactory.createCompoundBorder(
210
                BorderFactory.createLineBorder(getForeground()),
211
                BorderFactory.createEmptyBorder(0, 3, 0, 3)
212
            ));
213
214
            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
215
            pinButton = new JButton(ImageUtilities.loadImageIcon("org/netbeans/editor/resources/pin.png", false));
216
            pinButton.setBorder(new javax.swing.border.EmptyBorder(0, 3, 0, 0));
217
            pinButton.setBorderPainted(false);
218
            pinButton.setContentAreaFilled(false);
219
            add(pinButton);
220
            if (expandable) {
221
                Icon expIcon = UIManager.getIcon ("Tree.collapsedIcon");    // NOI18N
222
                expButton = new JButton(expIcon);
223
                expButton.setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 5));
224
                expButton.setBorderPainted(false);
225
                expButton.setContentAreaFilled(false);
226
                add(expButton);
227
            }
228
            //JLabel l = new JLabel(toolTipText);
229
            // Multi-line tooltip:
230
            JTextArea l = createMultiLineToolTip(toolTipText, true);
231
            if (font != null) {
232
                l.setFont(font);
233
            }
234
            if (foreColor != null) {
235
                l.setForeground(foreColor);
236
            }
237
            if (backColor != null) {
238
                l.setBackground(backColor);
239
            }
240
            textToolTip = l;
241
            add(l);
242
        }
243
244
        void addExpansionListener(ActionListener treeExpansionListener) {
245
            expButton.addActionListener(treeExpansionListener);
246
        }
247
248
        void addPinListener(ActionListener treeExpansionListener) {
249
            pinButton.addActionListener(treeExpansionListener);
250
        }
251
252
        void setWidthCheck(boolean widthCheck) {
253
            this.widthCheck = widthCheck;
254
        }
255
256
        @Override
257
        public Dimension getPreferredSize() {
258
            if (!sizeSet) {
259
                // Be big enough initially.
260
                return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
261
            }
262
            return super.getPreferredSize();
263
        }
264
        
265
        @Override
266
        public void setSize(int width, int height) {
267
            Dimension prefSize = getPreferredSize();
268
            Dimension button1Size = (expButton != null) ? expButton.getPreferredSize() : new Dimension(0, 0);
269
            Dimension button2Size = pinButton.getPreferredSize();
270
            if (widthCheck) {
271
                Insets insets = getInsets();
272
                int textWidth = width - insets.left - button1Size.width - button2Size.width - insets.right;
273
                height = Math.max(Math.max(height, button1Size.height), button2Size.height);
274
                textToolTip.setSize(textWidth, height);
275
                Dimension textPreferredSize = textToolTip.getPreferredSize();
276
                super.setSize(
277
                        insets.left + button1Size.width + button2Size.width + textPreferredSize.width + insets.right,
278
                        insets.top + Math.max(Math.max(button1Size.height, textPreferredSize.height), button2Size.height) + insets.bottom);
279
            } else {
280
                if (height >= prefSize.height) { // enough height
281
                    height = prefSize.height;
282
                }
283
                super.setSize(width, height);
284
            }
285
            sizeSet = true;
286
        }
287
        
288
        private static JTextArea createMultiLineToolTip(String toolTipText, boolean wrapLines) {
289
            JTextArea ta = new TextToolTip(wrapLines);
290
            ta.setText(toolTipText);
291
            return ta;
292
        }
293
294
        private static class TextToolTip extends JTextArea {
295
            
296
            private static final String ELIPSIS = "..."; //NOI18N
297
            
298
            private final boolean wrapLines;
299
            
300
            public TextToolTip(boolean wrapLines) {
301
                this.wrapLines = wrapLines;
302
                setLineWrap(false); // It's necessary to have a big width of preferred size first.
303
            }
304
            
305
            public @Override void setSize(int width, int height) {
306
                Dimension prefSize = getPreferredSize();
307
                if (width >= prefSize.width) {
308
                    width = prefSize.width;
309
                } else { // smaller available width
310
                    // Set line wrapping and do super.setSize() to determine
311
                    // the real height (it will change due to line wrapping)
312
                    if (wrapLines) {
313
                        setLineWrap(true);
314
                        setWrapStyleWord(true);
315
                    }
316
                    
317
                    super.setSize(width, Integer.MAX_VALUE); // the height is unimportant
318
                    prefSize = getPreferredSize(); // re-read new pref width
319
                }
320
                if (height >= prefSize.height) { // enough height
321
                    height = prefSize.height;
322
                } else { // smaller available height
323
                    // Check how much can be displayed - cannot rely on line count
324
                    // because line wrapping may display single physical line
325
                    // into several visual lines
326
                    // Before using viewToModel() a setSize() must be called
327
                    // because otherwise the viewToModel() would return -1.
328
                    super.setSize(width, Integer.MAX_VALUE);
329
                    int offset = viewToModel(new Point(0, height));
330
                    Document doc = getDocument();
331
                    try {
332
                        if (offset > ELIPSIS.length()) {
333
                            offset -= ELIPSIS.length();
334
                            doc.remove(offset, doc.getLength() - offset);
335
                            doc.insertString(offset, ELIPSIS, null);
336
                        }
337
                    } catch (BadLocationException ble) {
338
                        // "..." will likely not be displayed but otherwise should be ok
339
                    }
340
                    // Recalculate the prefSize as it may be smaller
341
                    // than the present preferred height
342
                    height = Math.min(height, getPreferredSize().height);
343
                }
344
                super.setSize(width, height);
345
            }
346
            
347
            @Override
348
            public void setKeymap(Keymap map) {
349
                //#181722: keymaps are shared among components with the same UI
350
                //a default action will be set to the Keymap of this component below,
351
                //so it is necessary to use a Keymap that is not shared with other JTextAreas
352
                super.setKeymap(addKeymap(null, map));
353
            }
354
        }
355
    }
356
    
357
    private class DebuggerStateChangeListener implements Closeable {
358
359
        @Override
360
        public void close() {
361
            closeToolTip();
362
        }
363
        
364
    }
365
366
}
(-)a/web.javascript.debugger/nbproject/project.xml (-2 / +2 lines)
Lines 74-80 Link Here
74
                    <compile-dependency/>
74
                    <compile-dependency/>
75
                    <run-dependency>
75
                    <run-dependency>
76
                        <release-version>1</release-version>
76
                        <release-version>1</release-version>
77
                        <specification-version>1.2</specification-version>
77
                        <specification-version>1.3</specification-version>
78
                    </run-dependency>
78
                    </run-dependency>
79
                </dependency>
79
                </dependency>
80
                <dependency>
80
                <dependency>
Lines 160-166 Link Here
160
                    <compile-dependency/>
160
                    <compile-dependency/>
161
                    <run-dependency>
161
                    <run-dependency>
162
                        <release-version>1</release-version>
162
                        <release-version>1</release-version>
163
                        <specification-version>2.49</specification-version>
163
                        <specification-version>2.54</specification-version>
164
                    </run-dependency>
164
                    </run-dependency>
165
                </dependency>
165
                </dependency>
166
                <dependency>
166
                <dependency>
(-)a/web.javascript.debugger/src/org/netbeans/modules/web/javascript/debugger/annotation/PinWatchValueProvider.java (-10 / +7 lines)
Lines 41-57 Link Here
41
 */
41
 */
42
package org.netbeans.modules.web.javascript.debugger.annotation;
42
package org.netbeans.modules.web.javascript.debugger.annotation;
43
43
44
import java.awt.event.ActionEvent;
45
import java.util.HashMap;
44
import java.util.HashMap;
46
import java.util.List;
45
import java.util.List;
47
import java.util.Map;
46
import java.util.Map;
48
import javax.swing.AbstractAction;
49
import javax.swing.Action;
47
import javax.swing.Action;
50
import javax.swing.Icon;
51
import javax.swing.UIManager;
52
import org.netbeans.api.debugger.Watch;
48
import org.netbeans.api.debugger.Watch;
53
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractExpandTooltipAction;
49
import org.netbeans.editor.ext.ToolTipSupport;
54
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractJSToolTipAnnotation;
55
import org.netbeans.modules.web.javascript.debugger.eval.Evaluator;
50
import org.netbeans.modules.web.javascript.debugger.eval.Evaluator;
56
import org.netbeans.modules.web.javascript.debugger.locals.VariablesModel;
51
import org.netbeans.modules.web.javascript.debugger.locals.VariablesModel;
57
import org.netbeans.modules.web.webkit.debugging.api.Debugger;
52
import org.netbeans.modules.web.webkit.debugging.api.Debugger;
Lines 60-65 Link Here
60
import org.netbeans.modules.web.webkit.debugging.api.debugger.RemoteObject.Type;
55
import org.netbeans.modules.web.webkit.debugging.api.debugger.RemoteObject.Type;
61
import org.netbeans.spi.debugger.ContextProvider;
56
import org.netbeans.spi.debugger.ContextProvider;
62
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
57
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
58
import org.netbeans.spi.debugger.ui.AbstractExpandToolTipAction;
63
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
59
import org.netbeans.spi.debugger.ui.PinWatchUISupport;
64
import org.openide.util.RequestProcessor;
60
import org.openide.util.RequestProcessor;
65
61
Lines 233-239 Link Here
233
        }
229
        }
234
    }
230
    }
235
231
236
    private class ExpandAction extends AbstractExpandTooltipAction {
232
    private class ExpandAction extends AbstractExpandToolTipAction {
237
233
238
        private final VariablesModel.ScopedRemoteObject sr;
234
        private final VariablesModel.ScopedRemoteObject sr;
239
        private final String expression;
235
        private final String expression;
Lines 245-253 Link Here
245
241
246
        @Override
242
        @Override
247
        protected void openTooltipView() {
243
        protected void openTooltipView() {
248
            openTooltipView(
244
            ToolTipSupport tts = openTooltipView(expression, sr);
249
                    new WebJSDebuggerTooltipSupport(dbg, dbg.getCurrentCallFrame()),
245
            if (tts != null) {
250
                    expression, sr);
246
                ToolTipAnnotation.handleToolTipClose(dbg, tts);
247
            }
251
        }
248
        }
252
249
253
    }
250
    }
(-)a/web.javascript.debugger/src/org/netbeans/modules/web/javascript/debugger/annotation/ToolTipAnnotation.java (-8 / +47 lines)
Lines 96-117 Link Here
96
    "# {0} - variable name",
96
    "# {0} - variable name",
97
    "var.undefined={0} is not defined"
97
    "var.undefined={0} is not defined"
98
})
98
})
99
public class ToolTipAnnotation extends AbstractJSToolTipAnnotation<WebJSDebuggerTooltipSupport>
99
public class ToolTipAnnotation extends AbstractJSToolTipAnnotation
100
{
100
{
101
    
101
    
102
    @Override
102
    @Override
103
    protected WebJSDebuggerTooltipSupport getEngineDebugger(Session session, DebuggerEngine engine) {
103
    protected void handleToolTipClose(DebuggerEngine engine, ToolTipSupport tts) {
104
        Debugger d = engine.lookupFirst(null, Debugger.class);
105
        if (d == null || !d.isSuspended()) {
106
            return ;
107
        }
108
        handleToolTipClose(d, tts);
109
    }
110
    
111
    static void handleToolTipClose(Debugger d, final ToolTipSupport tts) {
112
        Debugger.Listener dl = new Debugger.Listener() {
113
            @Override
114
            public void paused(List<CallFrame> callStack, String reason) {}
115
116
            @Override
117
            public void resumed() {
118
                doClose();
119
            }
120
121
            @Override
122
            public void reset() {
123
                doClose();
124
            }
125
126
            @Override
127
            public void enabled(boolean enabled) {
128
                if (!enabled) {
129
                    doClose();
130
                }
131
            }
132
            
133
            private void doClose() {
134
                tts.setToolTipVisible(false);
135
            }
136
        };
137
        d.addListener(dl);
138
        tts.addPropertyChangeListener(pl -> {
139
            if (ToolTipSupport.PROP_STATUS.equals(pl.getPropertyName()) &&
140
                    !tts.isToolTipVisible()) {
141
                d.removeListener(dl);
142
            }
143
        });
144
    }
145
    
146
    @Override
147
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine) throws CancellationException {
104
        Debugger d = engine.lookupFirst(null, Debugger.class);
148
        Debugger d = engine.lookupFirst(null, Debugger.class);
105
        if (d == null || !d.isSuspended()) {
149
        if (d == null || !d.isSuspended()) {
106
            return null;
150
            return null;
107
        }
151
        }
108
        CallFrame currentCallFrame = d.getCurrentCallFrame();
152
        CallFrame currentCallFrame = d.getCurrentCallFrame();
109
        return new WebJSDebuggerTooltipSupport(d, currentCallFrame);
153
        VariablesModel.ScopedRemoteObject sv = Evaluator.evaluateExpression(currentCallFrame, expression, true);
110
    }
111
112
    @Override
113
    protected Pair<String, Object> evaluate(String expression, DebuggerEngine engine, WebJSDebuggerTooltipSupport dbg) throws CancellationException {
114
        VariablesModel.ScopedRemoteObject sv = Evaluator.evaluateExpression(dbg.getFrame(), expression, true);
115
        Object tooltipVariable = null;
154
        Object tooltipVariable = null;
116
        String tooltipText;
155
        String tooltipText;
117
        if (sv != null) {
156
        if (sv != null) {
(-)a/web.javascript.debugger/src/org/netbeans/modules/web/javascript/debugger/annotation/ToolTipModel.java (-104 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.web.javascript.debugger.annotation;
43
44
import org.netbeans.modules.javascript2.debug.ui.tooltip.AbstractJSToolTipAnnotation;
45
import org.netbeans.modules.web.javascript.debugger.locals.VariablesModel;
46
import org.netbeans.spi.debugger.ContextProvider;
47
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
48
import org.netbeans.spi.viewmodel.ExtendedNodeModel;
49
import org.netbeans.spi.viewmodel.TableModel;
50
import org.netbeans.spi.viewmodel.TreeExpansionModel;
51
import org.netbeans.spi.viewmodel.TreeExpansionModelFilter;
52
import org.netbeans.spi.viewmodel.TreeModel;
53
import org.netbeans.spi.viewmodel.UnknownTypeException;
54
55
/**
56
 *
57
 * @author Martin
58
 */
59
@DebuggerServiceRegistration(path="javascript-debuggerengine/ToolTipView", types={ TreeModel.class, ExtendedNodeModel.class, TableModel.class, TreeExpansionModelFilter.class })
60
public class ToolTipModel extends VariablesModel implements TreeExpansionModelFilter {
61
    
62
    public ToolTipModel(ContextProvider contextProvider) {
63
        super(contextProvider);
64
    }
65
66
    @Override
67
    public int getChildrenCount(Object parent) throws UnknownTypeException {
68
        if (parent == ROOT) {
69
            return 1;
70
        } else {
71
            return super.getChildrenCount(parent);
72
        }
73
    }
74
75
    @Override
76
    public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException {
77
        if (parent == ROOT) {
78
            Object ttv = AbstractJSToolTipAnnotation.getTooltipVariable();
79
            if (ttv != null) {
80
                return new Object[] { ttv };
81
            } else {
82
                return new Object[] { };
83
            }
84
        } else {
85
            return super.getChildren(parent, from, to);
86
        }
87
    }
88
89
    @Override
90
    public boolean isExpanded(TreeExpansionModel original, Object node) throws UnknownTypeException {
91
        if (node == AbstractJSToolTipAnnotation.getTooltipVariable()) {
92
            return true;
93
        } else {
94
            return original.isExpanded(node);
95
        }
96
    }
97
98
    @Override
99
    public void nodeExpanded(Object node) {}
100
101
    @Override
102
    public void nodeCollapsed(Object node) {}
103
    
104
}
(-)a/web.javascript.debugger/src/org/netbeans/modules/web/javascript/debugger/annotation/WebJSDebuggerTooltipSupport.java (-123 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.web.javascript.debugger.annotation;
44
45
import java.io.Closeable;
46
import java.io.IOException;
47
import java.util.List;
48
import org.netbeans.modules.javascript2.debug.ui.tooltip.DebuggerTooltipSupport;
49
import org.netbeans.modules.web.webkit.debugging.api.Debugger;
50
import org.netbeans.modules.web.webkit.debugging.api.debugger.CallFrame;
51
import org.openide.util.Exceptions;
52
53
/**
54
 *
55
 * @author Martin Entlicher
56
 */
57
public class WebJSDebuggerTooltipSupport implements DebuggerTooltipSupport {
58
    
59
    private final Debugger debugger;
60
    private final CallFrame frame;
61
    private Debugger.Listener closeableListener;
62
    
63
    public WebJSDebuggerTooltipSupport(Debugger debugger, CallFrame frame) {
64
        this.debugger = debugger;
65
        this.frame = frame;
66
    }
67
68
    public Debugger getDebugger() {
69
        return debugger;
70
    }
71
72
    public CallFrame getFrame() {
73
        return frame;
74
    }
75
76
    @Override
77
    public void addCloseable(final Closeable closeable) {
78
        closeableListener = new CloseableDebuggerListener(closeable);
79
        debugger.addListener(closeableListener);
80
    }
81
82
    @Override
83
    public void removeCloseable(Closeable closeable) {
84
        debugger.removeListener(closeableListener);
85
    }
86
    
87
    private static class CloseableDebuggerListener implements Debugger.Listener {
88
        
89
        private final Closeable closeable;
90
        
91
        public CloseableDebuggerListener(Closeable closeable) {
92
            this.closeable = closeable;
93
        }
94
95
        @Override
96
        public void paused(List<CallFrame> callStack, String reason) {}
97
98
        @Override
99
        public void resumed() {
100
            doClose();
101
        }
102
103
        @Override
104
        public void reset() {
105
            doClose();
106
        }
107
108
        @Override
109
        public void enabled(boolean enabled) {
110
            if (!enabled) {
111
                doClose();
112
            }
113
        }
114
        
115
        private void doClose() {
116
            try {
117
                closeable.close();
118
            } catch (IOException ex) {}
119
        }
120
        
121
    }
122
    
123
}

Return to bug 262312