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

(-)a/spi.debugger.ui/manifest.mf (-1 / +1 lines)
Lines 2-7 Link Here
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
2
OpenIDE-Module: org.netbeans.spi.debugger.ui/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/debugger/ui/Bundle.properties
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/debugger/resources/mf-layer.xml
5
OpenIDE-Module-Specification-Version: 2.41
5
OpenIDE-Module-Specification-Version: 2.42
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
6
OpenIDE-Module-Provides: org.netbeans.spi.debugger.ui
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
7
OpenIDE-Module-Install: org/netbeans/modules/debugger/ui/DebuggerModule.class
(-)a/spi.debugger.ui/nbproject/project.xml (+8 lines)
Lines 137-142 Link Here
137
                    </run-dependency>
137
                    </run-dependency>
138
                </dependency>
138
                </dependency>
139
                <dependency>
139
                <dependency>
140
                    <code-name-base>org.openide.explorer</code-name-base>
141
                    <build-prerequisite/>
142
                    <compile-dependency/>
143
                    <run-dependency>
144
                        <specification-version>6.55</specification-version>
145
                    </run-dependency>
146
                </dependency>
147
                <dependency>
140
                    <code-name-base>org.openide.filesystems</code-name-base>
148
                    <code-name-base>org.openide.filesystems</code-name-base>
141
                    <build-prerequisite/>
149
                    <build-prerequisite/>
142
                    <compile-dependency/>
150
                    <compile-dependency/>
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/registry/DebuggerProcessor.java (-1 / +11 lines)
Lines 67-72 Link Here
67
import org.netbeans.spi.debugger.ui.BreakpointType;
67
import org.netbeans.spi.debugger.ui.BreakpointType;
68
import org.netbeans.spi.debugger.ui.ColumnModelRegistration;
68
import org.netbeans.spi.debugger.ui.ColumnModelRegistration;
69
import org.netbeans.spi.debugger.ui.ColumnModelRegistrations;
69
import org.netbeans.spi.debugger.ui.ColumnModelRegistrations;
70
import org.netbeans.spi.debugger.ui.DebuggingView;
70
import org.netbeans.spi.viewmodel.ColumnModel;
71
import org.netbeans.spi.viewmodel.ColumnModel;
71
import org.openide.filesystems.annotations.LayerBuilder;
72
import org.openide.filesystems.annotations.LayerBuilder;
72
73
Lines 86-92 Link Here
86
        return new HashSet<String>(Arrays.asList(
87
        return new HashSet<String>(Arrays.asList(
87
            AttachType.Registration.class.getCanonicalName(),
88
            AttachType.Registration.class.getCanonicalName(),
88
            BreakpointType.Registration.class.getCanonicalName(),
89
            BreakpointType.Registration.class.getCanonicalName(),
89
            ColumnModelRegistration.class.getCanonicalName()
90
            ColumnModelRegistration.class.getCanonicalName(),
91
            ColumnModelRegistrations.class.getCanonicalName(),
92
            DebuggingView.DVSupport.Registration.class.getCanonicalName()
90
        ));
93
        ));
91
    }
94
    }
92
95
Lines 137-142 Link Here
137
            }
140
            }
138
            cnt++;
141
            cnt++;
139
        }
142
        }
143
        for (Element e : env.getElementsAnnotatedWith(DebuggingView.DVSupport.Registration.class)) {
144
            DebuggingView.DVSupport.Registration reg = e.getAnnotation(DebuggingView.DVSupport.Registration.class);
145
            final String path = reg.path();
146
            final int position = reg.position();
147
            handleProviderRegistration(e, DebuggingView.DVSupport.class, path, position);
148
            cnt++;
149
        }
140
        return cnt == annotations.size();
150
        return cnt == annotations.size();
141
    }
151
    }
142
152
(-)a/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/views/debugging/Bundle.properties (+110 lines)
Line 0 Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
3
# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
7
#
8
# The contents of this file are subject to the terms of either the GNU
9
# General Public License Version 2 only ("GPL") or the Common
10
# Development and Distribution License("CDDL") (collectively, the
11
# "License"). You may not use this file except in compliance with the
12
# License. You can obtain a copy of the License at
13
# http://www.netbeans.org/cddl-gplv2.html
14
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
# specific language governing permissions and limitations under the
16
# License.  When distributing the software, include this License Header
17
# Notice in each file and include the License file at
18
# nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
19
# particular file as subject to the "Classpath" exception as provided
20
# by Oracle in the GPL Version 2 section of the License file that
21
# accompanied this code. If applicable, add the following below the
22
# License Header, with the fields enclosed by brackets [] replaced by
23
# your own identifying information:
24
# "Portions Copyrighted [year] [name of copyright owner]"
25
#
26
# Contributor(s):
27
#
28
# The Original Software is NetBeans. The Initial Developer of the Original
29
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
30
# Microsystems, Inc. All Rights Reserved.
31
#
32
# If you wish your version of this file to be governed by only the CDDL
33
# or only the GPL Version 2, indicate your decision by adding
34
# "[Contributor] elects to include this software in this distribution
35
# under the [CDDL or GPL Version 2] license." If you do not indicate a
36
# single choice of license, a recipient has the option to distribute
37
# your version of this file under either the CDDL, the GPL Version 2 or
38
# to extend the choice of license to its licensees as provided above.
39
# However, if you add GPL Version 2 code and therefore, elected the GPL
40
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
42
43
#DebuggingView
44
CTL_Debugging_view=Debugging
45
CTL_Debugging_tooltip=Debugging View
46
LBL_No_Session_Running=no session running
47
48
LBL_THREAD_GROUPS_TIP=Show thread groups
49
LBL_SUSPEND_TABLE_TIP=Show suspend/resume table
50
LBL_SYSTEM_THREADS_TIP=Show system threads
51
LBL_SUPSENDED_THREADS_ONLY_TIP=Show Less (suspended and current threads only)
52
LBL_MONITORS_TIP=Show monitors
53
LBL_QUALIFIED_NAMES_TIP=Show qualified names
54
LBL_SUSPEND_SORT_TIP=Sort by suspended/resumed state
55
LBL_ALPHABETIC_SORT_TIP=Sort by name
56
LBL_NATURAL_SORT_TIP=Sort by default
57
58
LBL_THREAD_GROUPS=Show Thread &Groups
59
LBL_SUSPEND_TABLE=Show Suspend/Resume &Table
60
LBL_SYSTEM_THREADS=Show &System Threads
61
LBL_SUPSENDED_THREADS_ONLY=Show &Less
62
LBL_MONITORS=Show &Monitors
63
LBL_QUALIFIED_NAMES=Show Qualified &Names
64
LBL_SUSPEND_SORT=Sort by S&tate
65
LBL_ALPHABETIC_SORT=Sort by &Name
66
LBL_NATURAL_SORT=&Default Sorting
67
68
LBL_FilterSubmenu=&Options
69
70
LBL_CURRENT_BAR_TIP=Current thread (selected for stepping and evaluation)
71
LBL_CURRENT_DEADLOCKED_TIP=Current thread in deadlock
72
LBL_BREAKPOINT_HIT_TIP=New breakpoint hit
73
LBL_DEADLOCKED_THREAD_TIP=Thread in deadlock
74
75
LBL_SUSPEND_THREAD=Suspend thread {0}
76
LBL_RESUME_THREAD=Resume thread {0}
77
78
#InfoPanel
79
LBL_OneNewHit=New Breakpoint Hit
80
LBL_NewHits=New Breakpoint Hits ({0})
81
82
#Threads History action
83
CTL_ThreadsHistoryAction=Threads History
84
CTL_THREADS_CHOOSER=Current Thread Chooser
85
86
InfoPanel.hitsLabel.text=New Breakpoint Hit
87
InfoPanel.infoIcon.text=
88
InfoPanel.infoIcon1.text=
89
InfoPanel.deadlocksLabel.text=Deadlock detected
90
InfoPanel.infoIcon2.text=
91
InfoPanel.debuggerDeadlocksLabelThread.text=Step is blocked by suspended thread ''{0}''.
92
InfoPanel.debuggerDeadlocksLabel.Method.text=Method invocation is blocked by other suspended threads.
93
InfoPanel.debuggerDeadlocksLabelThread.Method.text=Method invocation is blocked by suspended thread ''{0}''.
94
InfoPanel.debuggerDeadlocksLabel.text=Step is blocked by other suspended threads.
95
InfoPanel.debuggerDeadlocksLabel.tooltip=Blocking threads are: {0}.
96
InfoPanel.resumeDebuggerDeadlockLabelThread.text=Resume this thread to proceed?
97
InfoPanel.resumeDebuggerDeadlockLabel.text=Resume these threads to proceed?
98
InfoPanel.resumeDebuggerDeadlockButton.text=Resume
99
InfoPanel.resumeDebuggerDeadlockButton.tooltip=Resume threads {0} to complete the step.
100
InfoPanel.resumeDebuggerDeadlockButton.Method.tooltip=Resume threads {0} to complete the method evaluation.
101
InfoPanel.resumeDebuggerDeadlockButtonThread.tooltip=Resume thread ''{0}'' to complete the step.
102
InfoPanel.resumeDebuggerDeadlockButtonThread.Method.tooltip=Resume thread ''{0}'' to complete the method evaluation.
103
DebuggingView.sessionComboBox.AccessibleContext.accessibleName=Sessions
104
DebuggingView.sessionComboBox.AccessibleContext.accessibleDescription=List of running sessions.
105
DebuggingView.treeView.AccessibleContext.accessibleName=Debugging Tree
106
DebuggingView.treeView.AccessibleContext.accessibleDescription=Tree structure of threads in debugged VM.
107
InfoPanel.infoIcon3.text=
108
InfoPanel.stepBrkpLabel.text=Step interrupted by a breakpoint in another thread ''{0}''.
109
InfoPanel.stepBrkpIgnoreButton.text=Ignore Breakpoint
110
InfoPanel.stepBrkpIgnoreButton.tooltip=Ignore this breakpoint and complete the step.
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/ClickableIcon.java (-17 / +15 lines)
Lines 40-46 Link Here
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
41
 */
42
42
43
package org.netbeans.modules.debugger.jpda.ui.debugging;
43
package org.netbeans.modules.debugger.ui.views.debugging;
44
44
45
import java.awt.Container;
45
import java.awt.Container;
46
import java.awt.Dimension;
46
import java.awt.Dimension;
Lines 51-58 Link Here
51
import javax.swing.JLabel;
51
import javax.swing.JLabel;
52
import javax.swing.SwingConstants;
52
import javax.swing.SwingConstants;
53
import org.netbeans.api.debugger.Session;
53
import org.netbeans.api.debugger.Session;
54
import org.netbeans.api.debugger.jpda.JPDADebugger;
54
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
55
import org.netbeans.api.debugger.jpda.JPDAThread;
56
import org.openide.util.Exceptions;
55
import org.openide.util.Exceptions;
57
import org.openide.util.NbBundle;
56
import org.openide.util.NbBundle;
58
import org.openide.util.RequestProcessor;
57
import org.openide.util.RequestProcessor;
Lines 79-89 Link Here
79
    
78
    
80
    private int state;
79
    private int state;
81
    private boolean isThreadSupended;
80
    private boolean isThreadSupended;
82
    private JPDAThread jpdaThread;
81
    private DVThread dvThread;
83
    private DebugTreeView tree;
82
    private DebugTreeView tree;
84
    
83
    
85
    ClickableIcon(ImageIcon normalR, ImageIcon focusedR, ImageIcon pressedR,
84
    ClickableIcon(ImageIcon normalR, ImageIcon focusedR, ImageIcon pressedR,
86
            ImageIcon normalS, ImageIcon focusedS, ImageIcon pressedS, JPDAThread jpdaThread, DebugTreeView tree) {
85
            ImageIcon normalS, ImageIcon focusedS, ImageIcon pressedS, DVThread dvThread, DebugTreeView tree) {
87
        this.tree = tree;
86
        this.tree = tree;
88
        this.resumeIcon = normalR;
87
        this.resumeIcon = normalR;
89
        this.focusedResumeIcon = focusedR;
88
        this.focusedResumeIcon = focusedR;
Lines 93-100 Link Here
93
        this.focusedSuspendIcon = focusedS;
92
        this.focusedSuspendIcon = focusedS;
94
        this.pressedSuspendIcon = pressedS;
93
        this.pressedSuspendIcon = pressedS;
95
        
94
        
96
        isThreadSupended = jpdaThread.isSuspended();
95
        isThreadSupended = dvThread.isSuspended();
97
        this.jpdaThread = jpdaThread;
96
        this.dvThread = dvThread;
98
        
97
        
99
        setHorizontalAlignment(SwingConstants.CENTER);
98
        setHorizontalAlignment(SwingConstants.CENTER);
100
        setVerticalAlignment(SwingConstants.CENTER);
99
        setVerticalAlignment(SwingConstants.CENTER);
Lines 115-127 Link Here
115
        addMouseListener(this);
114
        addMouseListener(this);
116
    }
115
    }
117
    
116
    
118
    void changeThread(JPDAThread newThread, Container container, int sx, int sy, int width, int height) {
117
    void changeThread(DVThread newThread, Container container, int sx, int sy, int width, int height) {
119
        boolean suspended = newThread.isSuspended();
118
        boolean suspended = newThread.isSuspended();
120
        if (jpdaThread == newThread && suspended == isThreadSupended) {
119
        if (dvThread == newThread && suspended == isThreadSupended) {
121
            return;
120
            return;
122
        }
121
        }
123
        isThreadSupended = newThread.isSuspended();
122
        isThreadSupended = newThread.isSuspended();
124
        this.jpdaThread = newThread;
123
        this.dvThread = newThread;
125
        Point point = container.getMousePosition(true);
124
        Point point = container.getMousePosition(true);
126
        state = point != null && sx <= point.x && point.x < sx + width && sy <= point.y && point.y < sy + height
125
        state = point != null && sx <= point.x && point.x < sx + width && sy <= point.y && point.y < sy + height
127
                ? STATE_FOCUSED : STATE_NORMAL;
126
                ? STATE_FOCUSED : STATE_NORMAL;
Lines 131-141 Link Here
131
    
130
    
132
    private void setFocusedThread() {
131
    private void setFocusedThread() {
133
        if (state != STATE_NORMAL) {
132
        if (state != STATE_NORMAL) {
134
            if (tree != null && tree.threadFocuseGained(jpdaThread)) {
133
            if (tree != null && tree.threadFocuseGained(dvThread)) {
135
                getParent().repaint();
134
                getParent().repaint();
136
            }
135
            }
137
        } else {
136
        } else {
138
            if (tree != null && tree.threadFocuseLost(jpdaThread)) {
137
            if (tree != null && tree.threadFocuseLost(dvThread)) {
139
                getParent().repaint();
138
                getParent().repaint();
140
            }
139
            }
141
        }
140
        }
Lines 160-166 Link Here
160
    private void changeIcon() {
159
    private void changeIcon() {
161
        setIcon(computeIcon());
160
        setIcon(computeIcon());
162
        String key = isThreadSupended ? "LBL_RESUME_THREAD" : "LBL_SUSPEND_THREAD"; // NOI18N
161
        String key = isThreadSupended ? "LBL_RESUME_THREAD" : "LBL_SUSPEND_THREAD"; // NOI18N
163
        String text = NbBundle.getMessage(ClickableIcon.class, key, jpdaThread.getName());
162
        String text = NbBundle.getMessage(ClickableIcon.class, key, dvThread.getName());
164
        setToolTipText(text);
163
        setToolTipText(text);
165
    }
164
    }
166
    
165
    
Lines 168-175 Link Here
168
        final boolean suspended = isThreadSupended;
167
        final boolean suspended = isThreadSupended;
169
        RequestProcessor rp;
168
        RequestProcessor rp;
170
        try {
169
        try {
171
            JPDADebugger debugger = (JPDADebugger) jpdaThread.getClass().getMethod("getDebugger").invoke(jpdaThread);
170
            Session s = dvThread.getDVSupport().getSession();
172
            Session s = (Session) debugger.getClass().getMethod("getSession").invoke(debugger);
173
            rp = s.lookupFirst(null, RequestProcessor.class);
171
            rp = s.lookupFirst(null, RequestProcessor.class);
174
        } catch (Exception e) {
172
        } catch (Exception e) {
175
            Exceptions.printStackTrace(e);
173
            Exceptions.printStackTrace(e);
Lines 182-190 Link Here
182
        rp.post(new Runnable() {
180
        rp.post(new Runnable() {
183
            public void run() {
181
            public void run() {
184
                if (suspended) {
182
                if (suspended) {
185
                    jpdaThread.resume();
183
                    dvThread.resume();
186
                } else {
184
                } else {
187
                    jpdaThread.suspend();
185
                    dvThread.suspend();
188
                }
186
                }
189
            }
187
            }
190
        });
188
        });
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/DebugTreeView.java (-31 / +37 lines)
Lines 40-46 Link Here
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
41
 */
42
42
43
package org.netbeans.modules.debugger.jpda.ui.debugging;
43
package org.netbeans.modules.debugger.ui.views.debugging;
44
44
45
import java.awt.Color;
45
import java.awt.Color;
46
import java.awt.Component;
46
import java.awt.Component;
Lines 63-73 Link Here
63
import javax.swing.tree.RowMapper;
63
import javax.swing.tree.RowMapper;
64
import javax.swing.tree.TreeNode;
64
import javax.swing.tree.TreeNode;
65
import javax.swing.tree.TreePath;
65
import javax.swing.tree.TreePath;
66
import org.netbeans.api.debugger.DebuggerEngine;
67
import org.netbeans.api.debugger.DebuggerManager;
66
68
67
import org.netbeans.api.debugger.jpda.JPDADebugger;
69
import org.netbeans.spi.debugger.ui.DebuggingView;
68
import org.netbeans.api.debugger.jpda.JPDAThread;
70
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
69
import org.netbeans.api.debugger.jpda.JPDAThreadGroup;
71
import org.netbeans.spi.debugger.ui.DebuggingView.DVThreadGroup;
70
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingTreeModel;
71
import org.netbeans.spi.viewmodel.TreeExpansionModel;
72
import org.netbeans.spi.viewmodel.TreeExpansionModel;
72
73
73
import org.openide.explorer.view.BeanTreeView;
74
import org.openide.explorer.view.BeanTreeView;
Lines 88-94 Link Here
88
    private final Color highlightColor;
89
    private final Color highlightColor;
89
    private final Color currentThreadColor;
90
    private final Color currentThreadColor;
90
    
91
    
91
    private JPDAThread focusedThread;
92
    private DVThread focusedThread;
92
    
93
    
93
    DebugTreeView() {
94
    DebugTreeView() {
94
        super();
95
        super();
Lines 96-102 Link Here
96
        if (c == null) {
97
        if (c == null) {
97
            c = new Color(233, 255, 230);
98
            c = new Color(233, 255, 230);
98
            Color tbc = tree.getBackground();
99
            Color tbc = tree.getBackground();
99
            int dl = Math.abs(DebuggingView.luminance(c) - DebuggingView.luminance(tbc));
100
            int dl = Math.abs(DebuggingViewComponent.luminance(c) - DebuggingViewComponent.luminance(tbc));
100
            if (dl > 125) {
101
            if (dl > 125) {
101
                c = new Color(30, 80, 28);
102
                c = new Color(30, 80, 28);
102
            }
103
            }
Lines 106-112 Link Here
106
        if (c == null) {
107
        if (c == null) {
107
            c = new Color(233, 239, 248);
108
            c = new Color(233, 239, 248);
108
            Color tbc = tree.getBackground();
109
            Color tbc = tree.getBackground();
109
            int dl = Math.abs(DebuggingView.luminance(c) - DebuggingView.luminance(tbc));
110
            int dl = Math.abs(DebuggingViewComponent.luminance(c) - DebuggingViewComponent.luminance(tbc));
110
            if (dl > 125) {
111
            if (dl > 125) {
111
                c = new Color(40, 60, 38);
112
                c = new Color(40, 60, 38);
112
            }
113
            }
Lines 191-203 Link Here
191
        }
192
        }
192
    }
193
    }
193
194
194
    public Object getJPDAObject(TreePath path) {
195
    /**
196
     * Get the DVThread or DVThreadGroup instance on the given path.
197
     * @param path
198
     * @return an instance of DVThread or DVThreadGroup
199
     */
200
    public Object getThreadObject(TreePath path) {
195
        Node node = Visualizer.findNode(path.getLastPathComponent());
201
        Node node = Visualizer.findNode(path.getLastPathComponent());
196
        JPDAThread jpdaThread = node.getLookup().lookup(JPDAThread.class);
202
        DVThread jpdaThread = node.getLookup().lookup(DVThread.class);
197
        if (jpdaThread != null) {
203
        if (jpdaThread != null) {
198
            return jpdaThread;
204
            return jpdaThread;
199
        }
205
        }
200
        JPDAThreadGroup jpdaThreadGroup = node.getLookup().lookup(JPDAThreadGroup.class);
206
        DVThreadGroup jpdaThreadGroup = node.getLookup().lookup(DVThreadGroup.class);
201
        return jpdaThreadGroup;
207
        return jpdaThreadGroup;
202
    }
208
    }
203
209
Lines 273-292 Link Here
273
        }
279
        }
274
280
275
        Color origColor = g.getColor();
281
        Color origColor = g.getColor();
276
        ThreadsListener threadsListener = ThreadsListener.getDefault();
282
        DVThread currentThread = getCurrentThread();
277
        JPDADebugger debugger = threadsListener != null ? threadsListener.getDebugger() : null;
278
        JPDAThread currentThread = (debugger != null) ? debugger.getCurrentThread() : null;
279
        if (currentThread != null && !currentThread.isSuspended() &&
280
                !DebuggingTreeModel.isMethodInvoking(currentThread)) {
281
            currentThread = null;
282
        }
283
        boolean isHighlighted = false;
283
        boolean isHighlighted = false;
284
        boolean isCurrent = false;
284
        boolean isCurrent = false;
285
        Iterator<TreePath> iter = paths.iterator();
285
        Iterator<TreePath> iter = paths.iterator();
286
        int firstGroupNumber = clipY / rowHeight;
286
        int firstGroupNumber = clipY / rowHeight;
287
        for (int x = 0; x <= firstGroupNumber && iter.hasNext(); x++) {
287
        for (int x = 0; x <= firstGroupNumber && iter.hasNext(); x++) {
288
            Node node = Visualizer.findNode(iter.next().getLastPathComponent());
288
            Node node = Visualizer.findNode(iter.next().getLastPathComponent());
289
            JPDAThread thread = node.getLookup().lookup(JPDAThread.class);
289
            DVThread thread = node.getLookup().lookup(DVThread.class);
290
            isHighlighted = focusedThread != null && thread == focusedThread;
290
            isHighlighted = focusedThread != null && thread == focusedThread;
291
            if (thread != null) {
291
            if (thread != null) {
292
                isCurrent = currentThread == thread;
292
                isCurrent = currentThread == thread;
Lines 306-312 Link Here
306
            sy += rowHeight;
306
            sy += rowHeight;
307
            if (iter.hasNext()) {
307
            if (iter.hasNext()) {
308
                Node node = Visualizer.findNode(iter.next().getLastPathComponent());
308
                Node node = Visualizer.findNode(iter.next().getLastPathComponent());
309
                JPDAThread thread = node.getLookup().lookup(JPDAThread.class);
309
                DVThread thread = node.getLookup().lookup(DVThread.class);
310
                isHighlighted = focusedThread != null && thread == focusedThread;
310
                isHighlighted = focusedThread != null && thread == focusedThread;
311
                if (thread != null) {
311
                if (thread != null) {
312
                    isCurrent = currentThread == thread;
312
                    isCurrent = currentThread == thread;
Lines 322-329 Link Here
322
//        }
322
//        }
323
        g.setColor(origColor);
323
        g.setColor(origColor);
324
    }
324
    }
325
    
326
    private DVThread getCurrentThread() {
327
        DVThread currentThread = null;
328
        DebuggerEngine currentEngine = DebuggerManager.getDebuggerManager().getCurrentEngine();
329
        if (currentEngine != null) {
330
            DebuggingView.DVSupport dvSupport = currentEngine.lookupFirst(null, DebuggingView.DVSupport.class);
331
            if (dvSupport != null) {
332
                currentThread = dvSupport.getCurrentThread();
333
            }
334
        }
335
        return currentThread;
336
    }
325
337
326
    boolean threadFocuseGained(JPDAThread jpdaThread) {
338
    boolean threadFocuseGained(DVThread jpdaThread) {
327
        if (jpdaThread != null && focusedThread != jpdaThread) {
339
        if (jpdaThread != null && focusedThread != jpdaThread) {
328
            focusedThread = jpdaThread;
340
            focusedThread = jpdaThread;
329
            repaint();
341
            repaint();
Lines 332-338 Link Here
332
        return false;
344
        return false;
333
    }
345
    }
334
346
335
    boolean threadFocuseLost(JPDAThread jpdaThread) {
347
    boolean threadFocuseLost(DVThread jpdaThread) {
336
        if (jpdaThread != null && focusedThread == jpdaThread) {
348
        if (jpdaThread != null && focusedThread == jpdaThread) {
337
            focusedThread = null;
349
            focusedThread = null;
338
            repaint();
350
            repaint();
Lines 357-377 Link Here
357
            }
369
            }
358
            if (value instanceof Node) {
370
            if (value instanceof Node) {
359
                Node node = (Node) value;
371
                Node node = (Node) value;
360
                JPDAThread thread;
372
                DVThread thread;
361
                do {
373
                do {
362
                    thread = node.getLookup().lookup(JPDAThread.class);
374
                    thread = node.getLookup().lookup(DVThread.class);
363
                    if (thread == null) {
375
                    if (thread == null) {
364
                        node = node.getParentNode();
376
                        node = node.getParentNode();
365
                    }
377
                    }
366
                } while (thread == null && node != null);
378
                } while (thread == null && node != null);
367
                if (thread != null) {
379
                if (thread != null) {
368
                    ThreadsListener threadsListener = ThreadsListener.getDefault();
380
                    DVThread currentThread = getCurrentThread();
369
                    JPDADebugger debugger = threadsListener != null ? threadsListener.getDebugger() : null;
370
                    JPDAThread currentThread = (debugger != null) ? debugger.getCurrentThread() : null;
371
                    if (currentThread != null && !currentThread.isSuspended() &&
372
                            !DebuggingTreeModel.isMethodInvoking(currentThread)) {
373
                        currentThread = null;
374
                    }
375
                    boolean isHighlighted = focusedThread != null && thread == focusedThread && node == value;
381
                    boolean isHighlighted = focusedThread != null && thread == focusedThread && node == value;
376
                    boolean isCurrent = currentThread == thread;
382
                    boolean isCurrent = currentThread == thread;
377
                    if (isHighlighted || isCurrent) {
383
                    if (isHighlighted || isCurrent) {
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/DebuggingView.form (-3 / +3 lines)
Lines 1-4 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
Lines 29-38 Link Here
29
      </Properties>
29
      </Properties>
30
      <AccessibilityProperties>
30
      <AccessibilityProperties>
31
        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
31
        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
32
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/debugging/Bundle.properties" key="DebuggingView.sessionComboBox.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
32
          <ResourceString bundle="org/netbeans/modules/debugger/ui/views/debugging/Bundle.properties" key="DebuggingViewComponent.sessionComboBox.AccessibleContext.accessibleName" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
33
        </Property>
33
        </Property>
34
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
34
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
35
          <ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/debugging/Bundle.properties" key="DebuggingView.sessionComboBox.AccessibleContext.accessibleDescription" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
35
          <ResourceString bundle="org/netbeans/modules/debugger/ui/views/debugging/Bundle.properties" key="DebuggingViewComponent.sessionComboBox.AccessibleContext.accessibleDescription" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
36
        </Property>
36
        </Property>
37
      </AccessibilityProperties>
37
      </AccessibilityProperties>
38
      <Constraints>
38
      <Constraints>
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/DebuggingView.java (-66 / +69 lines)
Lines 40-46 Link Here
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
41
 */
42
42
43
package org.netbeans.modules.debugger.jpda.ui.debugging;
43
package org.netbeans.modules.debugger.ui.views.debugging;
44
44
45
import java.awt.BorderLayout;
45
import java.awt.BorderLayout;
46
import java.awt.Color;
46
import java.awt.Color;
Lines 98-109 Link Here
98
import org.netbeans.api.debugger.DebuggerEngine;
98
import org.netbeans.api.debugger.DebuggerEngine;
99
import org.netbeans.api.debugger.DebuggerManager;
99
import org.netbeans.api.debugger.DebuggerManager;
100
import org.netbeans.api.debugger.Session;
100
import org.netbeans.api.debugger.Session;
101
import org.netbeans.api.debugger.jpda.DeadlockDetector.Deadlock;
101
import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport;
102
import org.netbeans.api.debugger.jpda.JPDADebugger;
102
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
103
import org.netbeans.api.debugger.jpda.JPDAThread;
103
import org.netbeans.spi.debugger.ui.DebuggingView.DVThreadGroup;
104
import org.netbeans.api.debugger.jpda.JPDAThreadGroup;
104
import org.netbeans.spi.debugger.ui.DebuggingView.Deadlock;
105
import org.netbeans.api.debugger.jpda.ThreadsCollector;
106
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingTreeModel;
107
import org.netbeans.spi.debugger.ui.ViewFactory;
105
import org.netbeans.spi.debugger.ui.ViewFactory;
108
import org.netbeans.spi.debugger.ui.ViewLifecycle;
106
import org.netbeans.spi.debugger.ui.ViewLifecycle;
109
107
Lines 126-132 Link Here
126
 *
124
 *
127
 * @author  Dan
125
 * @author  Dan
128
 */
126
 */
129
public class DebuggingView extends TopComponent implements org.openide.util.HelpCtx.Provider,
127
public class DebuggingViewComponent extends TopComponent implements org.openide.util.HelpCtx.Provider,
130
       ExplorerManager.Provider, PropertyChangeListener, TreeExpansionListener, TreeModelListener,
128
       ExplorerManager.Provider, PropertyChangeListener, TreeExpansionListener, TreeModelListener,
131
       AdjustmentListener, ChangeListener, MouseWheelListener, TreeSelectionListener,
129
       AdjustmentListener, ChangeListener, MouseWheelListener, TreeSelectionListener,
132
       ViewLifecycle.ModelUpdateListener {
130
       ViewLifecycle.ModelUpdateListener {
Lines 159-169 Link Here
159
    private DebugTreeView treeView;
157
    private DebugTreeView treeView;
160
    private TapPanel tapPanel;
158
    private TapPanel tapPanel;
161
    private InfoPanel infoPanel;
159
    private InfoPanel infoPanel;
162
    private JPDADebugger debugger;
160
    private DVSupport debugger;
163
    private Session session;
161
    private Session session;
164
    private JPDADebugger previousDebugger;
162
    private DVSupport previousDebugger;
165
    private Reference<JPDAThread> threadMadeCurrentRef;
163
    private Reference<DVThread> threadMadeCurrentRef;
166
    private Reference<JPDAThread> threadToScrollRef;
164
    private Reference<DVThread> threadToScrollRef;
167
165
168
    private ViewRefresher viewRefresher = new ViewRefresher();
166
    private ViewRefresher viewRefresher = new ViewRefresher();
169
    private BarsPanel leftPanel;
167
    private BarsPanel leftPanel;
Lines 216-225 Link Here
216
     *
214
     *
217
     * @see  #getInstance
215
     * @see  #getInstance
218
     */
216
     */
219
    private static Reference<DebuggingView> instance = null;
217
    private static Reference<DebuggingViewComponent> instance = null;
220
    
218
    
221
    /** Creates new form DebuggingView */
219
    /** Creates new form DebuggingView */
222
    public DebuggingView() {
220
    public DebuggingViewComponent() {
223
        setIcon(ImageUtilities.loadImage ("org/netbeans/modules/debugger/jpda/resources/debugging.png")); // NOI18N
221
        setIcon(ImageUtilities.loadImage ("org/netbeans/modules/debugger/jpda/resources/debugging.png")); // NOI18N
224
        // Remember the location of the component when closed.
222
        // Remember the location of the component when closed.
225
        putClientProperty("KeepNonPersistentTCInModelWhenClosed", Boolean.TRUE);    // NOI18N
223
        putClientProperty("KeepNonPersistentTCInModelWhenClosed", Boolean.TRUE);    // NOI18N
Lines 296-303 Link Here
296
        gridBagConstraints.gridy = 0;
294
        gridBagConstraints.gridy = 0;
297
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
295
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
298
        add(sessionComboBox, gridBagConstraints);
296
        add(sessionComboBox, gridBagConstraints);
299
        sessionComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DebuggingView.class, "DebuggingView.sessionComboBox.AccessibleContext.accessibleName")); // NOI18N
297
        sessionComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingViewComponent.sessionComboBox.AccessibleContext.accessibleName")); // NOI18N
300
        sessionComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DebuggingView.class, "DebuggingView.sessionComboBox.AccessibleContext.accessibleDescription")); // NOI18N
298
        sessionComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingViewComponent.sessionComboBox.AccessibleContext.accessibleDescription")); // NOI18N
301
299
302
        mainScrollPane.setBorder(null);
300
        mainScrollPane.setBorder(null);
303
        mainScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
301
        mainScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
Lines 378-387 Link Here
378
            threadsListener = ThreadsListener.getDefault();
376
            threadsListener = ThreadsListener.getDefault();
379
        }
377
        }
380
        if (engine != null) {
378
        if (engine != null) {
381
            final JPDADebugger deb = engine.lookupFirst(null, JPDADebugger.class);
379
            final DVSupport deb = engine.lookupFirst(null, DVSupport.class);
382
            if (deb != null) {
380
            if (deb != null) {
383
                if (threadsListener != null) {
381
                if (threadsListener != null) {
384
                    threadsListener.setDebuggingView(this);
382
                    threadsListener.setDebuggingView(deb, this);
385
                }
383
                }
386
            }
384
            }
387
            synchronized (lock) {
385
            synchronized (lock) {
Lines 405-410 Link Here
405
                    }
403
                    }
406
                });
404
                });
407
            }
405
            }
406
            FiltersDescriptor.getInstance().setUpFilters(deb);
408
        } else {
407
        } else {
409
            synchronized (lock) {
408
            synchronized (lock) {
410
                if (previousDebugger != null) {
409
                if (previousDebugger != null) {
Lines 422-427 Link Here
422
                    }
421
                    }
423
                });
422
                });
424
            }
423
            }
424
            FiltersDescriptor.getInstance().setUpFilters(null);
425
        }
425
        }
426
        SwingUtilities.invokeLater(new Runnable() {
426
        SwingUtilities.invokeLater(new Runnable() {
427
            @Override
427
            @Override
Lines 461-469 Link Here
461
        return manager;
461
        return manager;
462
    }
462
    }
463
463
464
    public static DebuggingView getInstance() {
464
    public static DebuggingViewComponent getInstance() {
465
        DebuggingView view;
465
        DebuggingViewComponent view;
466
        view = (DebuggingView) WindowManager.getDefault().findTopComponent(ID);
466
        view = (DebuggingViewComponent) WindowManager.getDefault().findTopComponent(ID);
467
        if (view == null) {
467
        if (view == null) {
468
            view = getDefault();
468
            view = getDefault();
469
        }
469
        }
Lines 488-503 Link Here
488
     *
488
     *
489
     * @return  singleton - instance of this class
489
     * @return  singleton - instance of this class
490
     */
490
     */
491
    public static synchronized DebuggingView getDefault() {
491
    public static synchronized DebuggingViewComponent getDefault() {
492
        DebuggingView view;
492
        DebuggingViewComponent view;
493
        if (instance == null) {
493
        if (instance == null) {
494
            view = new DebuggingView();
494
            view = new DebuggingViewComponent();
495
            instance = new WeakReference<DebuggingView>(view);
495
            instance = new WeakReference<DebuggingViewComponent>(view);
496
        } else {
496
        } else {
497
            view = instance.get();
497
            view = instance.get();
498
            if (view == null) {
498
            if (view == null) {
499
                view = new DebuggingView();
499
                view = new DebuggingViewComponent();
500
                instance = new WeakReference<DebuggingView>(view);
500
                instance = new WeakReference<DebuggingViewComponent>(view);
501
            }
501
            }
502
        }
502
        }
503
        return view;
503
        return view;
Lines 556-567 Link Here
556
    
556
    
557
    @Override
557
    @Override
558
    public String getName() {
558
    public String getName() {
559
        return NbBundle.getMessage (DebuggingView.class, "CTL_Debugging_view"); // NOI18N
559
        return NbBundle.getMessage (DebuggingViewComponent.class, "CTL_Debugging_view"); // NOI18N
560
    }
560
    }
561
    
561
    
562
    @Override
562
    @Override
563
    public String getToolTipText() {
563
    public String getToolTipText() {
564
        return NbBundle.getMessage (DebuggingView.class, "CTL_Debugging_tooltip"); // NOI18N
564
        return NbBundle.getMessage (DebuggingViewComponent.class, "CTL_Debugging_tooltip"); // NOI18N
565
    }
565
    }
566
566
567
    @Override
567
    @Override
Lines 570-582 Link Here
570
        if (ExplorerManager.PROP_ROOT_CONTEXT.equals(propertyName) || 
570
        if (ExplorerManager.PROP_ROOT_CONTEXT.equals(propertyName) || 
571
                ExplorerManager.PROP_NODE_CHANGE.equals(propertyName)) {
571
                ExplorerManager.PROP_NODE_CHANGE.equals(propertyName)) {
572
            refreshView();
572
            refreshView();
573
        } else if (JPDADebugger.PROP_CURRENT_THREAD.equals(propertyName)) {
573
        } else if (DVSupport.PROP_CURRENT_THREAD.equals(propertyName)) {
574
            JPDAThread currentThread;
574
            DVThread currentThread;
575
            synchronized (lock) {
575
            synchronized (lock) {
576
                currentThread = (debugger != null) ? debugger.getCurrentThread() : null;
576
                currentThread = (debugger != null) ? debugger.getCurrentThread() : null;
577
            }
577
            }
578
            if (currentThread != null) {
578
            if (currentThread != null) {
579
                JPDAThread thread = threadMadeCurrentRef != null ? threadMadeCurrentRef.get() : null;
579
                DVThread thread = threadMadeCurrentRef != null ? threadMadeCurrentRef.get() : null;
580
                if (thread == currentThread) {
580
                if (thread == currentThread) {
581
                    threadToScrollRef = new WeakReference(thread);
581
                    threadToScrollRef = new WeakReference(thread);
582
                }
582
                }
Lines 597-608 Link Here
597
        }
597
        }
598
    }
598
    }
599
599
600
    private static boolean isJPDASession(Session s) {
600
    private static boolean isDebuggingSession(Session s) {
601
        DebuggerEngine engine = s.getCurrentEngine ();
601
        DebuggerEngine engine = s.getCurrentEngine ();
602
        if (engine == null) {
602
        if (engine == null) {
603
            return false;
603
            return false;
604
        }
604
        }
605
        return engine.lookupFirst(null, JPDADebugger.class) != null;
605
        return engine.lookupFirst(null, DVSupport.class) != null;
606
    }
606
    }
607
    
607
    
608
    void updateSessionsComboBox() {
608
    void updateSessionsComboBox() {
Lines 616-622 Link Here
616
                DebuggerManager dm = DebuggerManager.getDebuggerManager();
616
                DebuggerManager dm = DebuggerManager.getDebuggerManager();
617
                Session[] sessions = dm.getSessions();
617
                Session[] sessions = dm.getSessions();
618
                for (int x = 0; x < sessions.length; x++) {
618
                for (int x = 0; x < sessions.length; x++) {
619
                    if (isJPDASession(sessions[x])) {
619
                    if (isDebuggingSession(sessions[x])) {
620
                        sessionComboBox.addItem(new SessionItem(sessions[x]));
620
                        sessionComboBox.addItem(new SessionItem(sessions[x]));
621
                    }
621
                    }
622
                }
622
                }
Lines 631-637 Link Here
631
        });
631
        });
632
    }
632
    }
633
633
634
    void makeThreadCurrent(JPDAThread thread) {
634
    void makeThreadCurrent(DVThread thread) {
635
        threadMadeCurrentRef = new WeakReference(thread);
635
        threadMadeCurrentRef = new WeakReference(thread);
636
        thread.makeCurrent();
636
        thread.makeCurrent();
637
    }
637
    }
Lines 643-650 Link Here
643
            treeView.setRootVisible(false);
643
            treeView.setRootVisible(false);
644
            treeView.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
644
            treeView.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
645
            treeView.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
645
            treeView.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
646
            treeView.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DebuggingView.class, "DebuggingView.treeView.AccessibleContext.accessibleName")); // NOI18N
646
            treeView.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingView.treeView.AccessibleContext.accessibleName")); // NOI18N
647
            treeView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DebuggingView.class, "DebuggingView.treeView.AccessibleContext.accessibleDescription")); // NOI18N
647
            treeView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DebuggingViewComponent.class, "DebuggingView.treeView.AccessibleContext.accessibleDescription")); // NOI18N
648
            treeView.getTree().addMouseWheelListener(this);
648
            treeView.getTree().addMouseWheelListener(this);
649
            treeView.addTreeExpansionListener(this);
649
            treeView.addTreeExpansionListener(this);
650
            TreeModel model = treeView.getTree().getModel();
650
            TreeModel model = treeView.getTree().getModel();
Lines 723-741 Link Here
723
            @Override
723
            @Override
724
            public void run() {
724
            public void run() {
725
                refreshScheduled.set(false);
725
                refreshScheduled.set(false);
726
                JPDAThread currentThread;
726
                DVThread currentThread = null;
727
                ThreadsCollector tc;
727
                Set<Deadlock> deadlocks = null;
728
                synchronized (DebuggingView.this.lock) {
728
                DVSupport supp;
729
                    currentThread = debugger != null ? debugger.getCurrentThread() : null;
729
                synchronized (DebuggingViewComponent.this.lock) {
730
                    tc = debugger != null ? debugger.getThreadsCollector() : null;
730
                    supp = debugger;
731
                }
732
                if (supp != null) {
733
                    currentThread = supp.getCurrentThread();
734
                    deadlocks = supp.getDeadlocks();
731
                }
735
                }
732
                // collect all deadlocked threads
736
                // collect all deadlocked threads
733
                Set<Deadlock> deadlocks = tc != null ? tc.getDeadlockDetector().getDeadlocks() : null;
737
                Set<DVThread> deadlockedThreads;
734
                Set<JPDAThread> deadlockedThreads;
735
                if (deadlocks == null) {
738
                if (deadlocks == null) {
736
                    deadlockedThreads = Collections.EMPTY_SET;
739
                    deadlockedThreads = Collections.EMPTY_SET;
737
                } else {
740
                } else {
738
                    deadlockedThreads = new HashSet<JPDAThread>();
741
                    deadlockedThreads = new HashSet<DVThread>();
739
                    for (Deadlock deadlock : deadlocks) {
742
                    for (Deadlock deadlock : deadlocks) {
740
                        deadlockedThreads.addAll(deadlock.getThreads());
743
                        deadlockedThreads.addAll(deadlock.getThreads());
741
                    }
744
                    }
Lines 870-879 Link Here
870
873
871
    private final class ViewRefresher implements Runnable {
874
    private final class ViewRefresher implements Runnable {
872
        
875
        
873
        private JPDAThread currentThread;
876
        private DVThread currentThread;
874
        private Set<JPDAThread> deadlockedThreads;
877
        private Set<DVThread> deadlockedThreads;
875
        
878
        
876
        void setup(JPDAThread currentThread, Set<JPDAThread> deadlockedThreads) {
879
        void setup(DVThread currentThread, Set<DVThread> deadlockedThreads) {
877
            this.currentThread = currentThread;
880
            this.currentThread = currentThread;
878
            this.deadlockedThreads = deadlockedThreads;
881
            this.deadlockedThreads = deadlockedThreads;
879
        }
882
        }
Lines 886-892 Link Here
886
            int sx = (rightPanel.getWidth() - ClickableIcon.CLICKABLE_ICON_WIDTH) / 2;
889
            int sx = (rightPanel.getWidth() - ClickableIcon.CLICKABLE_ICON_WIDTH) / 2;
887
            int sy = 0;
890
            int sy = 0;
888
891
889
            JPDAThread threadToScroll = threadToScrollRef != null ? threadToScrollRef.get() : null;
892
            DVThread threadToScroll = threadToScrollRef != null ? threadToScrollRef.get() : null;
890
            threadToScrollRef = null;
893
            threadToScrollRef = null;
891
            int scrollStart = -1, scrollEnd = -1;
894
            int scrollStart = -1, scrollEnd = -1;
892
            boolean pathToScrollSearching = false;
895
            boolean pathToScrollSearching = false;
Lines 904-911 Link Here
904
            if (tView != null) {
907
            if (tView != null) {
905
                for (TreePath path : tView.getVisiblePaths()) {
908
                for (TreePath path : tView.getVisiblePaths()) {
906
                    Node node = Visualizer.findNode(path.getLastPathComponent());
909
                    Node node = Visualizer.findNode(path.getLastPathComponent());
907
                    JPDAThread jpdaThread = node.getLookup().lookup(JPDAThread.class);
910
                    DVThread jpdaThread = node.getLookup().lookup(DVThread.class);
908
                    JPDAThreadGroup jpdaThreadGroup = node.getLookup().lookup(JPDAThreadGroup.class);
911
                    DVThreadGroup jpdaThreadGroup = node.getLookup().lookup(DVThreadGroup.class);
909
912
910
                    JTree tree = tView.getTree();
913
                    JTree tree = tView.getTree();
911
                    Rectangle rect = tree.getRowBounds(tree.getRowForPath(path));
914
                    Rectangle rect = tree.getRowBounds(tree.getRowForPath(path));
Lines 922-929 Link Here
922
                        }
925
                        }
923
                        leftBarHeight = 0;
926
                        leftBarHeight = 0;
924
                        if (jpdaThread != null) {
927
                        if (jpdaThread != null) {
925
                            isCurrent = jpdaThread == currentThread && (jpdaThread.isSuspended() ||
928
                            isCurrent = jpdaThread == currentThread;/* && (jpdaThread.isSuspended() ||
926
                                    DebuggingTreeModel.isMethodInvoking(jpdaThread));
929
                                    DebuggingTreeModel.isMethodInvoking(jpdaThread));*/
927
                            isAtBreakpoint = threadsListener.isBreakpointHit(jpdaThread);
930
                            isAtBreakpoint = threadsListener.isBreakpointHit(jpdaThread);
928
                            isInDeadlock = deadlockedThreads.contains(jpdaThread);
931
                            isInDeadlock = deadlockedThreads.contains(jpdaThread);
929
                        } else {
932
                        } else {
Lines 975-987 Link Here
975
            }
978
            }
976
        }
979
        }
977
980
978
        private void addPanels(Object jpdaObject, boolean current, boolean atBreakpoint,
981
        private void addPanels(Object dvObject, boolean current, boolean atBreakpoint,
979
                boolean inDeadlock, int height, int sx, int sy, int rowHeight) {
982
                boolean inDeadlock, int height, int sx, int sy, int rowHeight) {
980
            if (current || atBreakpoint || inDeadlock) {
983
            if (current || atBreakpoint || inDeadlock) {
981
                leftPanel.addBar(current, atBreakpoint, inDeadlock, height, sy);
984
                leftPanel.addBar(current, atBreakpoint, inDeadlock, height, sy);
982
            }
985
            }
983
            if (jpdaObject instanceof JPDAThread) {
986
            if (dvObject instanceof DVThread) {
984
                rightPanel.addIcon(sx, sy, rowHeight, (JPDAThread)jpdaObject);
987
                rightPanel.addIcon(sx, sy, rowHeight, (DVThread) dvObject);
985
            }
988
            }
986
        }
989
        }
987
    }
990
    }
Lines 1007-1023 Link Here
1007
            Color secondaryColor = null;
1010
            Color secondaryColor = null;
1008
            if (inDeadlock) {
1011
            if (inDeadlock) {
1009
                color = deadlockColor;
1012
                color = deadlockColor;
1010
                toolTipText = NbBundle.getMessage(DebuggingView.class, "LBL_DEADLOCKED_THREAD_TIP");
1013
                toolTipText = NbBundle.getMessage(DebuggingViewComponent.class, "LBL_DEADLOCKED_THREAD_TIP");
1011
            } else if (isCurrent) {
1014
            } else if (isCurrent) {
1012
                color = greenBarColor;
1015
                color = greenBarColor;
1013
                toolTipText = NbBundle.getMessage(DebuggingView.class, "LBL_CURRENT_BAR_TIP");
1016
                toolTipText = NbBundle.getMessage(DebuggingViewComponent.class, "LBL_CURRENT_BAR_TIP");
1014
            } else if (atBreakpoint) {
1017
            } else if (atBreakpoint) {
1015
                color = hitsBarColor;
1018
                color = hitsBarColor;
1016
                toolTipText = NbBundle.getMessage(DebuggingView.class, "LBL_BREAKPOINT_HIT_TIP");
1019
                toolTipText = NbBundle.getMessage(DebuggingViewComponent.class, "LBL_BREAKPOINT_HIT_TIP");
1017
            }
1020
            }
1018
            if (isCurrent && inDeadlock) {
1021
            if (isCurrent && inDeadlock) {
1019
                secondaryColor = greenBarColor;
1022
                secondaryColor = greenBarColor;
1020
                toolTipText = NbBundle.getMessage(DebuggingView.class, "LBL_CURRENT_DEADLOCKED_TIP");
1023
                toolTipText = NbBundle.getMessage(DebuggingViewComponent.class, "LBL_CURRENT_DEADLOCKED_TIP");
1021
            }
1024
            }
1022
            Bar bar = new Bar(sy, height, color, secondaryColor, toolTipText);
1025
            Bar bar = new Bar(sy, height, color, secondaryColor, toolTipText);
1023
            bars.add(bar);
1026
            bars.add(bar);
Lines 1123-1134 Link Here
1123
            }
1126
            }
1124
        }
1127
        }
1125
        
1128
        
1126
        public void addIcon(int sx, int sy, int rowHeight, JPDAThread jpdaThread) {
1129
        public void addIcon(int sx, int sy, int rowHeight, DVThread dvThread) {
1127
            int height = sy - endSY + rowHeight;
1130
            int height = sy - endSY + rowHeight;
1128
            IconItem item;
1131
            IconItem item;
1129
            if (counter < icons.size()) {
1132
            if (counter < icons.size()) {
1130
                item = icons.get(counter);
1133
                item = icons.get(counter);
1131
                item.icon.changeThread(jpdaThread, DebuggingView.this, sx, sy,
1134
                item.icon.changeThread(dvThread, DebuggingViewComponent.this, sx, sy,
1132
                        ClickableIcon.CLICKABLE_ICON_WIDTH, height);
1135
                        ClickableIcon.CLICKABLE_ICON_WIDTH, height);
1133
                item.panel.setPreferredSize(new Dimension(ClickableIcon.CLICKABLE_ICON_WIDTH, height));
1136
                item.panel.setPreferredSize(new Dimension(ClickableIcon.CLICKABLE_ICON_WIDTH, height));
1134
                item.height = height;
1137
                item.height = height;
Lines 1139-1145 Link Here
1139
                panel.setPreferredSize(new Dimension(ClickableIcon.CLICKABLE_ICON_WIDTH, height));
1142
                panel.setPreferredSize(new Dimension(ClickableIcon.CLICKABLE_ICON_WIDTH, height));
1140
            
1143
            
1141
                ClickableIcon icon = new ClickableIcon(resumeIcon, focusedResumeIcon, pressedResumeIcon,
1144
                ClickableIcon icon = new ClickableIcon(resumeIcon, focusedResumeIcon, pressedResumeIcon,
1142
                        suspendIcon, focusedSuspendIcon, pressedSuspendIcon, jpdaThread, treeView);
1145
                        suspendIcon, focusedSuspendIcon, pressedSuspendIcon, dvThread, treeView);
1143
                icon.setBackground(treeBackgroundColor);
1146
                icon.setBackground(treeBackgroundColor);
1144
                
1147
                
1145
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
1148
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
Lines 1154-1160 Link Here
1154
                gridBagConstraints.insets = new Insets(insetTop, 0, insetBottom, 0);
1157
                gridBagConstraints.insets = new Insets(insetTop, 0, insetBottom, 0);
1155
                
1158
                
1156
                panel.add(icon, gridBagConstraints);
1159
                panel.add(icon, gridBagConstraints);
1157
                icon.initializeState(DebuggingView.this, sx, sy, ClickableIcon.CLICKABLE_ICON_WIDTH, height);
1160
                icon.initializeState(DebuggingViewComponent.this, sx, sy, ClickableIcon.CLICKABLE_ICON_WIDTH, height);
1158
                
1161
                
1159
                item = new IconItem(height, icon, panel);
1162
                item = new IconItem(height, icon, panel);
1160
                icons.add(item);
1163
                icons.add(item);
Lines 1249-1255 Link Here
1249
            if (session != null) {
1252
            if (session != null) {
1250
                return session.getName();
1253
                return session.getName();
1251
            } else {
1254
            } else {
1252
                return '<' + NbBundle.getMessage(DebuggingView.class, "LBL_No_Session_Running") + '>';
1255
                return '<' + NbBundle.getMessage(DebuggingViewComponent.class, "LBL_No_Session_Running") + '>';
1253
            }
1256
            }
1254
        }
1257
        }
1255
        
1258
        
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/FiltersDescriptor.java (-39 / +252 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.HierarchyEvent;
48
import java.awt.event.HierarchyEvent;
Lines 52-57 Link Here
52
import java.util.ArrayList;
52
import java.util.ArrayList;
53
import java.util.Collections;
53
import java.util.Collections;
54
import java.util.List;
54
import java.util.List;
55
import java.util.prefs.AbstractPreferences;
56
import java.util.prefs.BackingStoreException;
55
import java.util.prefs.PreferenceChangeEvent;
57
import java.util.prefs.PreferenceChangeEvent;
56
import java.util.prefs.PreferenceChangeListener;
58
import java.util.prefs.PreferenceChangeListener;
57
import java.util.prefs.Preferences;
59
import java.util.prefs.Preferences;
Lines 66-77 Link Here
66
import javax.swing.JMenu;
68
import javax.swing.JMenu;
67
import javax.swing.JMenuItem;
69
import javax.swing.JMenuItem;
68
import javax.swing.JRadioButtonMenuItem;
70
import javax.swing.JRadioButtonMenuItem;
71
import org.netbeans.spi.debugger.ui.DebuggingView.DVFilter;
72
import org.netbeans.spi.debugger.ui.DebuggingView.DVFilter.Group;
73
import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport;
69
import org.openide.util.NbBundle;
74
import org.openide.util.NbBundle;
70
import org.openide.util.NbPreferences;
75
import org.openide.util.NbPreferences;
71
76
72
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingMonitorModel;
73
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingNodeModel;
74
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingTreeModel;
75
import org.openide.awt.Mnemonics;
77
import org.openide.awt.Mnemonics;
76
import org.openide.util.ImageUtilities;
78
import org.openide.util.ImageUtilities;
77
import org.openide.util.WeakListeners;
79
import org.openide.util.WeakListeners;
Lines 89-118 Link Here
89
    public static final String SHOW_SUSPEND_TABLE = "show_suspend_table";
91
    public static final String SHOW_SUSPEND_TABLE = "show_suspend_table";
90
    public static final String SHOW_THREAD_GROUPS = "thread_group";
92
    public static final String SHOW_THREAD_GROUPS = "thread_group";
91
    public static final String SHOW_SUSPENDED_THREADS_ONLY = "suspended_threads_only";
93
    public static final String SHOW_SUSPENDED_THREADS_ONLY = "suspended_threads_only";
94
    
95
    public static final String PREF_SORT_ALPHABET = "sort.alphabet";
96
    public static final String PREF_SORT_NATURAL = "sort.natural";
97
    public static final String PREF_SORT_SUSPEND = "sort.suspend";
98
    public static final String PREF_SHOW_MONITORS = "show.monitors"; // NOI18N
99
    public static final String PREF_SHOW_SYSTEM_THREADS = "show.systemThreads";
100
    public static final String PREF_SHOW_THREAD_GROUPS = "show.threadGroups";
101
    public static final String PREF_SHOW_SUSPENDED_THREADS_ONLY = "show.suspendedThreadsOnly";
102
    public static final String PREF_SHOW_SUSPEND_TABLE = "show_suspend_table";
103
    public static final String PREF_SHOW_PACKAGE_NAMES = "show.packageNames";
104
    
92
105
93
    private static FiltersDescriptor instance;
106
    private static FiltersDescriptor instance;
94
107
95
    /** List of <Item> describing filters properties */
108
    /** List of <Item> describing filters properties */
96
    private List<Item> filters;
109
    private List<DVFilter> filters;
97
110
98
    private Action[] filterActions;
111
    private Action[] filterActions;
112
    
113
    private FiltersAccessor filtersAccessor;
99
114
100
    /** Creates a new instance of FiltersDescriptor */
115
    /** Creates a new instance of FiltersDescriptor */
101
    private FiltersDescriptor() {
116
    private FiltersDescriptor() {
102
        filters = new ArrayList<Item>();
117
        filters = Collections.emptyList();
103
    }
118
    }
104
119
105
    public synchronized static FiltersDescriptor getInstance() {
120
    public synchronized static FiltersDescriptor getInstance() {
106
        if (instance == null) {
121
        if (instance == null) {
107
            instance = createDebuggingViewFilters();
122
            instance = new FiltersDescriptor();
123
            //instance = createDebuggingViewFilters();
108
        }
124
        }
109
        return instance;
125
        return instance;
110
    }
126
    }
111
    
127
    
128
    void setUpFilters(DVSupport dvs) {
129
        List<DVFilter> fs;
130
        if (dvs != null) {
131
            fs = filtersAccessor.getFilters(dvs);
132
        } else {
133
            fs = Collections.emptyList();
134
        }
135
        synchronized (this) {
136
            this.filters = fs;
137
            this.filterActions = null;
138
        }
139
    }
140
    
112
    public synchronized Action[] getFilterActions() {
141
    public synchronized Action[] getFilterActions() {
113
        if (filterActions == null) {
142
        if (filterActions == null) {
143
            if (filters.isEmpty()) {
144
                filterActions = new Action[] {};
145
                return filterActions;
146
            }
114
            List<Action> list = new ArrayList<Action>();
147
            List<Action> list = new ArrayList<Action>();
115
            for (Item item : filters) {
148
            for (DVFilter item : filters) {
116
                if (item.getGroup() != null) {
149
                if (item.getGroup() != null) {
117
                    SortAction action = new SortAction(item);
150
                    SortAction action = new SortAction(item);
118
                    list.add(action);
151
                    list.add(action);
Lines 134-156 Link Here
134
    }
167
    }
135
    
168
    
136
    public String getName(int index) {
169
    public String getName(int index) {
137
        return filters.get(index).name;
170
        return filters.get(index).getName();
138
    }
171
    }
139
    
172
    
140
    public String getDisplayName(int index) {
173
    public String getDisplayName(int index) {
141
        return filters.get(index).displayName;
174
        return filters.get(index).getDisplayName();
142
    }
175
    }
143
    
176
    
144
    public String getTooltip(int index) {
177
    public String getTooltip(int index) {
145
        return filters.get(index).tooltip;
178
        return filters.get(index).getTooltip();
146
    }
179
    }
147
    
180
    
148
    public Icon getSelectedIcon(int index) {
181
    public Icon getSelectedIcon(int index) {
149
        return filters.get(index).selectedIcon;
182
        return filters.get(index).getIcon();
150
    }
183
    }
151
    
184
    
152
    public boolean isSelected(int index) {
185
    public boolean isSelected(int index) {
153
        return filters.get(index).isSelected;
186
        return filters.get(index).isSelected();
154
    }
187
    }
155
188
156
    public void setSelected(int index, boolean selected) {
189
    public void setSelected(int index, boolean selected) {
Lines 158-164 Link Here
158
    }
191
    }
159
    
192
    
160
    public void setSelected(String filterName, boolean selected) {
193
    public void setSelected(String filterName, boolean selected) {
161
        for (Item item : filters) {
194
        for (DVFilter item : filters) {
162
            if (item.getName().equals(filterName)) {
195
            if (item.getName().equals(filterName)) {
163
                item.setSelected(selected);
196
                item.setSelected(selected);
164
                break;
197
                break;
Lines 167-177 Link Here
167
    }
200
    }
168
    
201
    
169
    public void connectToggleButton(int index, JToggleButton button) {
202
    public void connectToggleButton(int index, JToggleButton button) {
170
        filters.get(index).setToggleButton(button);
203
        FilterImpl impl = FiltersDescriptor.getInstance().filtersAccessor.getImpl(filters.get(index));
204
        impl.setToggleButton(button);
171
    }
205
    }
172
    
206
    
173
    // **************************************************************************
207
    // **************************************************************************
174
    
208
    
209
    /*
175
    private static FiltersDescriptor createDebuggingViewFilters() {
210
    private static FiltersDescriptor createDebuggingViewFilters() {
176
        FiltersDescriptor desc = new FiltersDescriptor();
211
        FiltersDescriptor desc = new FiltersDescriptor();
177
        desc.addItem(new Item(SHOW_SUSPENDED_THREADS_ONLY, getString("LBL_SUPSENDED_THREADS_ONLY"), getString("LBL_SUPSENDED_THREADS_ONLY_TIP"),
212
        desc.addItem(new Item(SHOW_SUSPENDED_THREADS_ONLY, getString("LBL_SUPSENDED_THREADS_ONLY"), getString("LBL_SUPSENDED_THREADS_ONLY_TIP"),
Lines 212-223 Link Here
212
        group.setItems(groupMembers);
247
        group.setItems(groupMembers);
213
        return desc;
248
        return desc;
214
    }
249
    }
250
    */
215
251
216
    // **************************************************************************
252
    // **************************************************************************
217
    
253
    
218
    private void addItem (Item newItem) {
254
    /*private void addItem (Item newItem) {
219
        filters.add(newItem);
255
        filters.add(newItem);
220
    }
256
    }*/
221
    
257
    
222
    private static Icon loadIcon(String iconName) {
258
    private static Icon loadIcon(String iconName) {
223
        return ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/jpda/resources/" + iconName, false);
259
        return ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/jpda/resources/" + iconName, false);
Lines 226-253 Link Here
226
    private static String getString(String label) {
262
    private static String getString(String label) {
227
        return NbBundle.getMessage(FiltersDescriptor.class, label);
263
        return NbBundle.getMessage(FiltersDescriptor.class, label);
228
    }
264
    }
265
266
    public void setFiltersAccessor(FiltersAccessor filtersAccessor) {
267
        this.filtersAccessor = filtersAccessor;
268
    }
269
    
270
    public static interface FiltersAccessor {
271
        public List<DVFilter> getFilters(DVSupport dvs);
272
        public FilterImpl getImpl(DVFilter filter);
273
    }
229
    
274
    
230
    // **************************************************************************
275
    // **************************************************************************
231
    //     filter Item
276
    //     filter Item
232
    // **************************************************************************
277
    // **************************************************************************
233
    static class Item {
278
    public static class FilterImpl {
234
        String name;
279
        private String name;
235
        String displayName;
280
        private String displayName;
236
        String tooltip;
281
        private String tooltip;
237
        Icon selectedIcon;
282
        private Icon selectedIcon;
238
        PreferenceChangeListener pchl;
283
        private Preferences prefs;
284
        private String prefKey;
285
        private PreferenceChangeListener pchl;
239
        
286
        
240
        private boolean isSelected;
287
        private boolean isSelected;
241
        private Group group;
288
        private Group group;
242
        private Reference<JToggleButton> toggleButtonRef;
289
        private Reference<JToggleButton> toggleButtonRef;
243
        
290
        
244
        Item (String name, String displayName, String tooltip,
291
        public static FilterImpl createDefault(DVFilter.DefaultFilter df) {
245
                boolean isSelected, Icon selectedIcon) {
292
            FilterImpl fimpl;
293
            switch (df) {
294
                case showMonitors:
295
                    fimpl = new FilterImpl(SHOW_MONITORS, getString("LBL_MONITORS"),
296
                                           getString("LBL_MONITORS_TIP"),
297
                                           loadIcon("monitor_acquired_16.png"),
298
                                           getDefaultPreferences(),
299
                                           PREF_SHOW_MONITORS, false);
300
                    break;
301
                case showQualifiedNames:
302
                    fimpl = new FilterImpl(SHOW_QUALIFIED_NAMES,
303
                                           getString("LBL_QUALIFIED_NAMES"),
304
                                           getString("LBL_QUALIFIED_NAMES_TIP"),
305
                                           loadIcon("show_fqn_option_16.png"),
306
                                           getDefaultPreferences(),
307
                                           PREF_SHOW_PACKAGE_NAMES, false);
308
                    break;
309
                case showSuspendTable:
310
                    fimpl = new FilterImpl(SHOW_SUSPEND_TABLE,
311
                                           getString("LBL_SUSPEND_TABLE"),
312
                                           getString("LBL_SUSPEND_TABLE_TIP"),
313
                                           loadIcon("show_suspend_table_option_16.png"),
314
                                           getDefaultPreferences(),
315
                                           PREF_SHOW_SUSPEND_TABLE, true);
316
                    break;
317
                case showSuspendedThreadsOnly:
318
                    fimpl = new FilterImpl(SHOW_SUSPENDED_THREADS_ONLY,
319
                                           getString("LBL_SUPSENDED_THREADS_ONLY"),
320
                                           getString("LBL_SUPSENDED_THREADS_ONLY_TIP"),
321
                                           loadIcon("show_suspended_threads_option_16.png"),
322
                                           getDefaultPreferences(),
323
                                           PREF_SHOW_SUSPENDED_THREADS_ONLY, false);
324
                    break;
325
                case showSystemThreads:
326
                    fimpl = new FilterImpl(SHOW_SYSTEM_THREADS,
327
                                           getString("LBL_SYSTEM_THREADS"),
328
                                           getString("LBL_SYSTEM_THREADS_TIP"),
329
                                           loadIcon("show_system_threads_option_16.png"),
330
                                           getDefaultPreferences(),
331
                                           PREF_SHOW_SYSTEM_THREADS, false);
332
                    break;
333
                case showThreadGroups:
334
                    fimpl = new FilterImpl(SHOW_THREAD_GROUPS,
335
                                           getString("LBL_THREAD_GROUPS"),
336
                                           getString("LBL_THREAD_GROUPS_TIP"),
337
                                           loadIcon("thread_group_mixed_16.png"),
338
                                           getDefaultPreferences(),
339
                                           PREF_SHOW_THREAD_GROUPS, false);
340
                    break;
341
                case sortAlphabetic:
342
                    fimpl = new FilterImpl(ALPHABETIC_SORT,
343
                                           getString("LBL_ALPHABETIC_SORT"),
344
                                           getString("LBL_ALPHABETIC_SORT_TIP"),
345
                                           loadIcon("alphabetic_sort_order_16.png"),
346
                                           getDefaultPreferences(),
347
                                           PREF_SORT_ALPHABET, false);
348
                    break;
349
                case sortNatural:
350
                    fimpl = new FilterImpl(NATURAL_SORT,
351
                                           getString("LBL_NATURAL_SORT"),
352
                                           getString("LBL_NATURAL_SORT_TIP"),
353
                                           loadIcon("natural_sort_order_16.png"),
354
                                           getDefaultPreferences(),
355
                                           PREF_SORT_NATURAL, true);
356
                    break;
357
                case sortSuspend:
358
                    fimpl = new FilterImpl(SUSPEND_SORT,
359
                                           getString("LBL_SUSPEND_SORT"),
360
                                           getString("LBL_SUSPEND_SORT_TIP"),
361
                                           loadIcon("suspend_property_sort_order_16.png"),
362
                                           getDefaultPreferences(),
363
                                           PREF_SORT_SUSPEND, false);
364
                    break;
365
                default:
366
                    throw new IllegalArgumentException(df.name());
367
            }
368
            return fimpl;
369
        }
370
        
371
        public FilterImpl (String name, String displayName, String tooltip,
372
                           Icon selectedIcon, Preferences prefs, String prefKey,
373
                           boolean isSelectedDefault) {
246
            this.name = name;
374
            this.name = name;
247
            this.displayName = displayName;
375
            this.displayName = displayName;
248
            this.tooltip = tooltip;
376
            this.tooltip = tooltip;
249
            this.selectedIcon = selectedIcon;
377
            this.selectedIcon = selectedIcon;
250
            this.isSelected = isSelected;
378
            this.isSelected = isSelectedDefault;
379
            this.prefs= prefs;
380
            this.prefKey = prefKey;
251
            
381
            
252
            readValue();
382
            readValue();
253
        }
383
        }
Lines 267-276 Link Here
267
        public String getDisplayName() {
397
        public String getDisplayName() {
268
            return displayName;
398
            return displayName;
269
        }
399
        }
400
        
401
        public String getTooltip() {
402
            return tooltip;
403
        }
270
404
271
        public Icon getIcon() {
405
        public Icon getIcon() {
272
            return selectedIcon;
406
            return selectedIcon;
273
        }
407
        }
408
        
409
        public Preferences getPreferences() {
410
            return prefs;
411
        }
412
        
413
        public String getPrefKey() {
414
            return prefKey;
415
        }
274
416
275
        public boolean isSelected() {
417
        public boolean isSelected() {
276
            return isSelected;
418
            return isSelected;
Lines 291-298 Link Here
291
                toggleButton.setSelected(state);
433
                toggleButton.setSelected(state);
292
            }
434
            }
293
            if (state && group != null) {
435
            if (state && group != null) {
294
                for (Item item : group.getItems()) {
436
                for (DVFilter item : group.getItems()) {
295
                    if (item != this && item.isSelected()) {
437
                    FilterImpl impl = FiltersDescriptor.getInstance().filtersAccessor.getImpl(item);
438
                    if (impl != this && item.isSelected()) {
296
                        item.setSelected(false);
439
                        item.setSelected(false);
297
                    } // if
440
                    } // if
298
                } // for
441
                } // for
Lines 307-315 Link Here
307
        }
450
        }
308
451
309
        private void readValue() {
452
        private void readValue() {
453
            isSelected = prefs.getBoolean(prefKey, isSelected);
454
            /*
455
            Preferences origPrefs = NbPreferences.root().node("org/netbeans/modules/debugger/jpda/ui").node("debugging");
310
            Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
456
            Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
311
            if (name.equals(SHOW_SYSTEM_THREADS)) {
457
            if (name.equals(SHOW_SYSTEM_THREADS)) {
312
                isSelected = preferences.getBoolean(DebuggingTreeModel.SHOW_SYSTEM_THREADS, false);
458
                isSelected = origPrefs.getBoolean(DebuggingTreeModel.SHOW_SYSTEM_THREADS, false);
459
                isSelected = preferences.getBoolean(DebuggingTreeModel.SHOW_SYSTEM_THREADS, isSelected);
313
            } else if (name.equals(SHOW_THREAD_GROUPS)) {
460
            } else if (name.equals(SHOW_THREAD_GROUPS)) {
314
                isSelected = preferences.getBoolean(DebuggingTreeModel.SHOW_THREAD_GROUPS, false);
461
                isSelected = preferences.getBoolean(DebuggingTreeModel.SHOW_THREAD_GROUPS, false);
315
            } else if (name.equals(ALPHABETIC_SORT)) {
462
            } else if (name.equals(ALPHABETIC_SORT)) {
Lines 329-335 Link Here
329
                isSelected = preferences.getBoolean(SHOW_SUSPEND_TABLE, true);
476
                isSelected = preferences.getBoolean(SHOW_SUSPEND_TABLE, true);
330
            } else {
477
            } else {
331
                isSelected = false;
478
                isSelected = false;
332
            }
479
            }*/
333
            if (pchl == null) {
480
            if (pchl == null) {
334
                pchl = new PreferenceChangeListener() {
481
                pchl = new PreferenceChangeListener() {
335
                    @Override
482
                    @Override
Lines 341-351 Link Here
341
                        }
488
                        }
342
                    }
489
                    }
343
                };
490
                };
344
                preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, pchl, preferences));
491
                prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, pchl, prefs));
345
            }
492
            }
346
        }
493
        }
347
494
348
        private void writeValue() {
495
        private void writeValue() {
496
            prefs.putBoolean(prefKey, isSelected);
497
            /*
349
            String keyName = null;
498
            String keyName = null;
350
            Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
499
            Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N
351
            if (name.equals(SHOW_SYSTEM_THREADS)) {
500
            if (name.equals(SHOW_SYSTEM_THREADS)) {
Lines 367-373 Link Here
367
            }
516
            }
368
            if (keyName != null) {
517
            if (keyName != null) {
369
                preferences.putBoolean(keyName, isSelected);
518
                preferences.putBoolean(keyName, isSelected);
370
            }
519
            }*/
520
        }
521
        
522
        private static Preferences getDefaultPreferences() {
523
            final Preferences origPrefs = NbPreferences.root().node("org/netbeans/modules/debugger/jpda/ui").node("debugging");
524
            final Preferences preferences = NbPreferences.forModule(FilterImpl.class).node("debugging"); // NOI18N
525
            return new AbstractPreferences(null, "debugging") {
526
                
527
                @Override
528
                protected void putSpi(String key, String value) {
529
                    preferences.put(key, value);
530
                }
531
                
532
                @Override
533
                protected String getSpi(String key) {
534
                    String value = origPrefs.get(key, null);
535
                    if (value == null) {
536
                        value = preferences.get(key, null);
537
                    }
538
                    return value;
539
                }
540
                
541
                @Override
542
                protected void removeSpi(String key) {}
543
                
544
                @Override
545
                protected void removeNodeSpi() throws BackingStoreException {}
546
                
547
                @Override
548
                protected String[] keysSpi() throws BackingStoreException {
549
                    return preferences.keys();
550
                }
551
                
552
                @Override
553
                protected String[] childrenNamesSpi() throws BackingStoreException {
554
                    return preferences.childrenNames();
555
                }
556
                
557
                @Override
558
                protected AbstractPreferences childSpi(String name) {
559
                    return null;
560
                }
561
                
562
                @Override
563
                protected void syncSpi() throws BackingStoreException {
564
                    origPrefs.sync();
565
                    preferences.sync();
566
                }
567
                
568
                @Override
569
                protected void flushSpi() throws BackingStoreException {
570
                    preferences.flush();
571
                }
572
573
                @Override
574
                public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
575
                    preferences.addPreferenceChangeListener(pcl);
576
                }
577
578
                @Override
579
                public void removePreferenceChangeListener(PreferenceChangeListener pcl) {
580
                    preferences.removePreferenceChangeListener(pcl);
581
                }
582
                
583
            };
371
        }
584
        }
372
        
585
        
373
    }
586
    }
Lines 375-381 Link Here
375
    // **************************************************************************
588
    // **************************************************************************
376
    //     Group of Items
589
    //     Group of Items
377
    // **************************************************************************
590
    // **************************************************************************
378
    static class Group {
591
    /*static class Group {
379
        List<Item> items = Collections.EMPTY_LIST;
592
        List<Item> items = Collections.EMPTY_LIST;
380
        
593
        
381
        public void setItems(List<Item> items) {
594
        public void setItems(List<Item> items) {
Lines 389-395 Link Here
389
            return items;
602
            return items;
390
        }
603
        }
391
        
604
        
392
    }
605
    }*/
393
    
606
    
394
    // **************************************************************************
607
    // **************************************************************************
395
    //     Filter Actions Support
608
    //     Filter Actions Support
Lines 397-406 Link Here
397
    
610
    
398
    private static final class SortAction extends AbstractAction implements Presenter.Popup {
611
    private static final class SortAction extends AbstractAction implements Presenter.Popup {
399
    
612
    
400
        private Item filterItem;
613
        private DVFilter filterItem;
401
614
402
        /** Creates a new instance of SortByNameAction */
615
        /** Creates a new instance of SortByNameAction */
403
        SortAction (Item item) {
616
        SortAction (DVFilter item) {
404
            this.filterItem = item;
617
            this.filterItem = item;
405
            String displayName = item.getDisplayName();
618
            String displayName = item.getDisplayName();
406
            int i = Mnemonics.findMnemonicAmpersand(displayName);
619
            int i = Mnemonics.findMnemonicAmpersand(displayName);
Lines 421-432 Link Here
421
            Mnemonics.setLocalizedText(menuItem, filterItem.getDisplayName());
634
            Mnemonics.setLocalizedText(menuItem, filterItem.getDisplayName());
422
            menuItem.setAction(this);
635
            menuItem.setAction(this);
423
            menuItem.addHierarchyListener(new ParentChangeListener(menuItem));
636
            menuItem.addHierarchyListener(new ParentChangeListener(menuItem));
424
            menuItem.setSelected(filterItem.isSelected);
637
            menuItem.setSelected(filterItem.isSelected());
425
            return menuItem;
638
            return menuItem;
426
        }
639
        }
427
640
428
        public void actionPerformed(ActionEvent e) {
641
        public void actionPerformed(ActionEvent e) {
429
            filterItem.setSelected(!filterItem.isSelected);
642
            filterItem.setSelected(!filterItem.isSelected());
430
        }
643
        }
431
644
432
        private class ParentChangeListener implements HierarchyListener {
645
        private class ParentChangeListener implements HierarchyListener {
Lines 483-489 Link Here
483
            Mnemonics.setLocalizedText(menu, NbBundle.getMessage(FiltersDescriptor.class, "LBL_FilterSubmenu"));
696
            Mnemonics.setLocalizedText(menu, NbBundle.getMessage(FiltersDescriptor.class, "LBL_FilterSubmenu"));
484
            JMenuItem menuItem;
697
            JMenuItem menuItem;
485
            String filterName;
698
            String filterName;
486
            for (Item item : filtersDesc.filters) {
699
            for (DVFilter item : filtersDesc.filters) {
487
                if (item.getGroup() != null) {
700
                if (item.getGroup() != null) {
488
                    continue;
701
                    continue;
489
                }
702
                }
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/InfoPanel.java (-75 / +47 lines)
Lines 40-46 Link Here
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
41
 */
42
42
43
package org.netbeans.modules.debugger.jpda.ui.debugging;
43
package org.netbeans.modules.debugger.ui.views.debugging;
44
44
45
import java.awt.BorderLayout;
45
import java.awt.BorderLayout;
46
import java.awt.Color;
46
import java.awt.Color;
Lines 71-82 Link Here
71
import javax.swing.Timer;
71
import javax.swing.Timer;
72
import javax.swing.UIManager;
72
import javax.swing.UIManager;
73
import javax.swing.border.EmptyBorder;
73
import javax.swing.border.EmptyBorder;
74
import org.netbeans.api.debugger.Breakpoint;
74
import org.netbeans.api.debugger.DebuggerManager;
75
import org.netbeans.api.debugger.DebuggerManager;
75
import org.netbeans.api.debugger.Session;
76
import org.netbeans.api.debugger.Session;
76
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
77
import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport;
77
import org.netbeans.api.debugger.jpda.JPDADebugger;
78
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
78
import org.netbeans.api.debugger.jpda.JPDAThread;
79
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingNodeModel;
80
import org.openide.awt.DropDownButtonFactory;
79
import org.openide.awt.DropDownButtonFactory;
81
import org.openide.util.Exceptions;
80
import org.openide.util.Exceptions;
82
import org.openide.util.ImageUtilities;
81
import org.openide.util.ImageUtilities;
Lines 108-124 Link Here
108
107
109
    private JButton arrowButton;
108
    private JButton arrowButton;
110
    private JPopupMenu arrowMenu;
109
    private JPopupMenu arrowMenu;
111
    private Map<JPDAThread, JMenuItem> threadToMenuItem = new WeakHashMap<JPDAThread, JMenuItem>();
110
    private Map<DVThread, JMenuItem> threadToMenuItem = new WeakHashMap<DVThread, JMenuItem>();
112
    private JPDAThread debuggerDeadlockThread;
111
    private DVThread debuggerDeadlockThread;
113
    private WeakReference<JPDADebugger> stepBrkpDebuggerRef;
112
    private WeakReference<DVSupport> stepBrkpDVSupportRef;
114
    private DebuggingView debuggingView;
113
    private DebuggingViewComponent debuggingView;
115
114
116
    /** Creates new form InfoPanel */
115
    /** Creates new form InfoPanel */
117
    public InfoPanel(TapPanel tapPanel, DebuggingView debuggingView) {
116
    public InfoPanel(TapPanel tapPanel, DebuggingViewComponent debuggingView) {
118
        this.tapPanel = tapPanel;
117
        this.tapPanel = tapPanel;
119
        this.debuggingView = debuggingView;
118
        this.debuggingView = debuggingView;
120
        filterPanelColor = tapPanel.getBackground();
119
        filterPanelColor = tapPanel.getBackground();
121
        hitsPanelColor = DebuggingView.hitsColor;
120
        hitsPanelColor = DebuggingViewComponent.hitsColor;
122
        deadlockPanelColor = hitsPanelColor;
121
        deadlockPanelColor = hitsPanelColor;
123
        stepBrkpColor = hitsPanelColor;
122
        stepBrkpColor = hitsPanelColor;
124
        tapPanelMinimumHeight = tapPanel.getMinimumHeight();
123
        tapPanelMinimumHeight = tapPanel.getMinimumHeight();
Lines 165-171 Link Here
165
        });
164
        });
166
    }
165
    }
167
166
168
    void removeBreakpointHit(final JPDAThread thread, final int newHitsCount) {
167
    void removeBreakpointHit(final DVThread thread, final int newHitsCount) {
169
        SwingUtilities.invokeLater(new Runnable() {
168
        SwingUtilities.invokeLater(new Runnable() {
170
            public void run() {
169
            public void run() {
171
                JMenuItem item = threadToMenuItem.remove(thread);
170
                JMenuItem item = threadToMenuItem.remove(thread);
Lines 181-193 Link Here
181
        });
180
        });
182
    }
181
    }
183
182
184
    void addBreakpointHit(final JPDAThread thread, final int newHitsCount) {
183
    void addBreakpointHit(final DVThread thread, final int newHitsCount) {
185
        SwingUtilities.invokeLater(new Runnable() {
184
        SwingUtilities.invokeLater(new Runnable() {
186
            public void run() {
185
            public void run() {
187
                if (threadToMenuItem.get(thread) != null) {
186
                if (threadToMenuItem.get(thread) != null) {
188
                    return;
187
                    return;
189
                }
188
                }
190
                JMenuItem item = createMenuItem(thread);
189
                JMenuItem item = createMenuItem(thread.getDVSupport(), thread);
191
                threadToMenuItem.put(thread, item);
190
                threadToMenuItem.put(thread, item);
192
                arrowMenu.add(item);
191
                arrowMenu.add(item);
193
                setHitsText(newHitsCount);
192
                setHitsText(newHitsCount);
Lines 198-210 Link Here
198
        });
197
        });
199
    }
198
    }
200
199
201
    void setBreakpointHits(final List<JPDAThread> hits) {
200
    void setBreakpointHits(final DVSupport dvs, final List<DVThread> hits) {
202
        SwingUtilities.invokeLater(new Runnable() {
201
        SwingUtilities.invokeLater(new Runnable() {
203
            public void run() {
202
            public void run() {
204
                arrowMenu.removeAll();
203
                arrowMenu.removeAll();
205
                threadToMenuItem.clear();
204
                threadToMenuItem.clear();
206
                for (JPDAThread thread : hits) {
205
                for (DVThread thread : hits) {
207
                    JMenuItem item = createMenuItem(thread);
206
                    JMenuItem item = createMenuItem(dvs, thread);
208
                    threadToMenuItem.put(thread, item);
207
                    threadToMenuItem.put(thread, item);
209
                    arrowMenu.add(item);
208
                    arrowMenu.add(item);
210
                }
209
                }
Lines 218-230 Link Here
218
        });
217
        });
219
    }
218
    }
220
219
221
    public void recomputeMenuItems(final List<JPDAThread> hits) {
220
    public void recomputeMenuItems(final DVSupport dvs, final List<DVThread> hits) {
222
        SwingUtilities.invokeLater(new Runnable() {
221
        SwingUtilities.invokeLater(new Runnable() {
223
            public void run() {
222
            public void run() {
224
                arrowMenu.removeAll();
223
                arrowMenu.removeAll();
225
                threadToMenuItem.clear();
224
                threadToMenuItem.clear();
226
                for (JPDAThread thread : hits) {
225
                for (DVThread thread : hits) {
227
                    JMenuItem item = createMenuItem(thread);
226
                    JMenuItem item = createMenuItem(dvs, thread);
228
                    threadToMenuItem.put(thread, item);
227
                    threadToMenuItem.put(thread, item);
229
                    arrowMenu.add(item);
228
                    arrowMenu.add(item);
230
                }
229
                }
Lines 232-255 Link Here
232
        });
231
        });
233
    }
232
    }
234
233
235
    private JMenuItem createMenuItem(final JPDAThread thread) {
234
    private JMenuItem createMenuItem(final DVSupport dvs, final DVThread thread) {
236
        String displayName;
235
        String displayName = dvs.getDisplayName(thread);
237
        try {
236
        Image image = dvs.getIcon(thread);
238
            displayName = DebuggingNodeModel.getDisplayName(thread, false);
239
            Method method = thread.getClass().getMethod("getDebugger"); // [TODO]
240
            JPDADebugger debugger = (JPDADebugger)method.invoke(thread);
241
            method = debugger.getClass().getMethod("getSession");
242
            Session session = (Session) method.invoke(debugger);
243
            Session currSession = DebuggerManager.getDebuggerManager().getCurrentSession();
244
            if (session != currSession) {
245
                String str = NbBundle.getMessage(ThreadsHistoryAction.class, "CTL_Session", // [TODO] bundle
246
                        session.getName());
247
                displayName = displayName.charAt(0) + str + ", " + displayName.substring(1);
248
            }
249
        } catch (Exception e) { // [TODO]
250
            displayName = thread.getName();
251
        }
252
        Image image = Utilities.loadImage(DebuggingNodeModel.getIconBase(thread));
253
        Icon icon = image != null ? new ImageIcon(image) : null;
237
        Icon icon = image != null ? new ImageIcon(image) : null;
254
        JMenuItem item = new JMenuItem(displayName, icon);
238
        JMenuItem item = new JMenuItem(displayName, icon);
255
        item.addActionListener(new ActionListener() {
239
        item.addActionListener(new ActionListener() {
Lines 283-289 Link Here
283
        });
267
        });
284
    }
268
    }
285
269
286
    void setShowThreadLocks(final JPDAThread thread, final List<JPDAThread> lockerThreads) {
270
    void setShowThreadLocks(final DVThread thread, final List<DVThread> lockerThreads) {
287
        SwingUtilities.invokeLater(new Runnable() {
271
        SwingUtilities.invokeLater(new Runnable() {
288
            public void run() {
272
            public void run() {
289
                if (lockerThreads != null) {
273
                if (lockerThreads != null) {
Lines 295-305 Link Here
295
        });
279
        });
296
    }
280
    }
297
281
298
    void setShowStepBrkp(final JPDADebugger debugger, final JPDAThread thread, final JPDABreakpoint breakpoint) {
282
    void setShowStepBrkp(final DVSupport dvSupport, final DVThread thread, final Breakpoint breakpoint) {
299
        SwingUtilities.invokeLater(new Runnable() {
283
        SwingUtilities.invokeLater(new Runnable() {
300
            public void run() {
284
            public void run() {
301
                if (breakpoint != null) {
285
                if (breakpoint != null) {
302
                    showStepBrkpPanel(debugger, thread, breakpoint);
286
                    showStepBrkpPanel(dvSupport, thread, breakpoint);
303
                } else {
287
                } else {
304
                    hideStepBrkpPanel();
288
                    hideStepBrkpPanel();
305
                }
289
                }
Lines 376-393 Link Here
376
        hidePanel(DEADLOCKS_BY_DEBUGGER);
360
        hidePanel(DEADLOCKS_BY_DEBUGGER);
377
    }
361
    }
378
362
379
    private boolean isInStep(JPDAThread t) {
363
    private void showDebuggerDeadlockPanel(DVThread thread, List<DVThread> lockerThreads) {
380
        // TODO: Make JPDAThread.isInStep()
381
        try {
382
            java.lang.reflect.Method isInStepMethod = t.getClass().getMethod("isInStep", new Class[] {});
383
            return (Boolean) isInStepMethod.invoke(t, new Object[] {});
384
        } catch (Exception ex) {
385
            Exceptions.printStackTrace(ex);
386
            return false;
387
        }
388
    }
389
390
    private void showDebuggerDeadlockPanel(JPDAThread thread, List<JPDAThread> lockerThreads) {
391
        //this.debuggerDeadlockThreads = lockerThreads;
364
        //this.debuggerDeadlockThreads = lockerThreads;
392
        this.debuggerDeadlockThread = thread;
365
        this.debuggerDeadlockThread = thread;
393
        String infoResource;
366
        String infoResource;
Lines 395-401 Link Here
395
        String resumeTooltipResource;
368
        String resumeTooltipResource;
396
        int numThreads = lockerThreads.size();
369
        int numThreads = lockerThreads.size();
397
        if (numThreads == 1) {
370
        if (numThreads == 1) {
398
            if (isInStep(thread)) {
371
            if (thread.isInStep()) {
399
                infoResource = "InfoPanel.debuggerDeadlocksLabelThread.text"; // NOI18N
372
                infoResource = "InfoPanel.debuggerDeadlocksLabelThread.text"; // NOI18N
400
                resumeTooltipResource = "InfoPanel.resumeDebuggerDeadlockButtonThread.tooltip";
373
                resumeTooltipResource = "InfoPanel.resumeDebuggerDeadlockButtonThread.tooltip";
401
            } else {
374
            } else {
Lines 407-413 Link Here
407
            resumeDebuggerDeadlockButton.setToolTipText(org.openide.util.NbBundle.getMessage(InfoPanel.class,
380
            resumeDebuggerDeadlockButton.setToolTipText(org.openide.util.NbBundle.getMessage(InfoPanel.class,
408
                    resumeTooltipResource, lockerThreads.get(0).getName()));
381
                    resumeTooltipResource, lockerThreads.get(0).getName()));
409
        } else {
382
        } else {
410
            if (isInStep(thread)) {
383
            if (thread.isInStep()) {
411
                infoResource = "InfoPanel.debuggerDeadlocksLabel.text"; // NOI18N
384
                infoResource = "InfoPanel.debuggerDeadlocksLabel.text"; // NOI18N
412
                resumeTooltipResource = "InfoPanel.resumeDebuggerDeadlockButton.tooltip"; // NOI18N
385
                resumeTooltipResource = "InfoPanel.resumeDebuggerDeadlockButton.tooltip"; // NOI18N
413
            } else {
386
            } else {
Lines 443-450 Link Here
443
        hidePanel(STEP_BRKP);
416
        hidePanel(STEP_BRKP);
444
    }
417
    }
445
418
446
    private void showStepBrkpPanel(JPDADebugger debugger, JPDAThread thread, JPDABreakpoint breakpoint) {
419
    private void showStepBrkpPanel(DVSupport dvSupport, DVThread thread, Breakpoint breakpoint) {
447
        this.stepBrkpDebuggerRef = new WeakReference<JPDADebugger>(debugger);
420
        this.stepBrkpDVSupportRef = new WeakReference<DVSupport>(dvSupport);
448
        String text = org.openide.util.NbBundle.getMessage(InfoPanel.class, "InfoPanel.stepBrkpLabel.text", thread.getName()); // NOI18N
421
        String text = org.openide.util.NbBundle.getMessage(InfoPanel.class, "InfoPanel.stepBrkpLabel.text", thread.getName()); // NOI18N
449
        stepBrkpLabel.setText(text);
422
        stepBrkpLabel.setText(text);
450
        stepBrkpLabel.setToolTipText(text);
423
        stepBrkpLabel.setToolTipText(text);
Lines 463-469 Link Here
463
            public void actionPerformed(ActionEvent e) {
436
            public void actionPerformed(ActionEvent e) {
464
                if (arrowMenu.getComponentCount() > 0) {
437
                if (arrowMenu.getComponentCount() > 0) {
465
                    Object item = arrowMenu.getComponent(0);
438
                    Object item = arrowMenu.getComponent(0);
466
                    for (Map.Entry<JPDAThread, JMenuItem> entry : threadToMenuItem.entrySet()) {
439
                    for (Map.Entry<DVThread, JMenuItem> entry : threadToMenuItem.entrySet()) {
467
                        if (entry.getValue() == item) {
440
                        if (entry.getValue() == item) {
468
                            debuggingView.makeThreadCurrent(entry.getKey());
441
                            debuggingView.makeThreadCurrent(entry.getKey());
469
                        } // if
442
                        } // if
Lines 536-542 Link Here
536
        return toggleButton;
509
        return toggleButton;
537
    }
510
    }
538
511
539
    private void resumeThreadToFreeMonitor(JPDAThread thread) {
512
    private void resumeThreadToFreeMonitor(DVThread thread) {
540
        // Do not have monitor breakpoints in the API.
513
        // Do not have monitor breakpoints in the API.
541
        // Have to do that in the implementation module.
514
        // Have to do that in the implementation module.
542
        try {
515
        try {
Lines 732-742 Link Here
732
    }// </editor-fold>//GEN-END:initComponents
705
    }// </editor-fold>//GEN-END:initComponents
733
706
734
    private void resumeDebuggerDeadlockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resumeDebuggerDeadlockButtonActionPerformed
707
    private void resumeDebuggerDeadlockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resumeDebuggerDeadlockButtonActionPerformed
735
        //final List<JPDAThread> threadsToResume = debuggerDeadlockThreads;
708
        //final List<DVThread> threadsToResume = debuggerDeadlockThreads;
736
        final JPDAThread blockedThread = debuggerDeadlockThread;
709
        final DVThread blockedThread = debuggerDeadlockThread;
737
        RequestProcessor rp;
710
        RequestProcessor rp;
738
        try {
711
        try {
739
            JPDADebugger debugger = (JPDADebugger) blockedThread.getClass().getMethod("getDebugger").invoke(blockedThread);
712
            DVSupport debugger = blockedThread.getDVSupport();
740
            rp = getRP(debugger);
713
            rp = getRP(debugger);
741
            if (rp == null) {
714
            if (rp == null) {
742
                return ;
715
                return ;
Lines 747-775 Link Here
747
        }
720
        }
748
        rp.post(new Runnable() {
721
        rp.post(new Runnable() {
749
            public void run() {
722
            public void run() {
750
                resumeThreadToFreeMonitor(blockedThread);
723
                blockedThread.resumeBlockingThreads();
724
                //resumeThreadToFreeMonitor(blockedThread);
751
            }
725
            }
752
        });
726
        });
753
        hideDebuggerDeadlockPanel();
727
        hideDebuggerDeadlockPanel();
754
    }//GEN-LAST:event_resumeDebuggerDeadlockButtonActionPerformed
728
    }//GEN-LAST:event_resumeDebuggerDeadlockButtonActionPerformed
755
729
756
    private static RequestProcessor getRP(JPDADebugger debugger) {
730
    private static RequestProcessor getRP(DVSupport debugger) {
757
        RequestProcessor rp;
731
        RequestProcessor rp;
758
        try {
732
        Session s = debugger.getSession();
759
            Session s = (Session) debugger.getClass().getMethod("getSession").invoke(debugger); // NOI18N
733
        rp = s.lookupFirst(null, RequestProcessor.class);
760
            rp = s.lookupFirst(null, RequestProcessor.class);
734
        if (rp == null) {
761
        } catch (Exception e) {
735
            rp = new RequestProcessor(InfoPanel.class);
762
            Exceptions.printStackTrace(e);
763
            return null;
764
        }
736
        }
765
        return rp;
737
        return rp;
766
    }
738
    }
767
739
768
    private void stepBrkpIgnoreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepBrkpIgnoreButtonActionPerformed
740
    private void stepBrkpIgnoreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepBrkpIgnoreButtonActionPerformed
769
        if (stepBrkpDebuggerRef != null) {
741
        if (stepBrkpDVSupportRef != null) {
770
            final JPDADebugger d = stepBrkpDebuggerRef.get();
742
            final DVSupport ds = stepBrkpDVSupportRef.get();
771
            if (d != null) {
743
            if (ds != null) {
772
                RequestProcessor rp = getRP(d);
744
                RequestProcessor rp = getRP(ds);
773
                if (rp == null) {
745
                if (rp == null) {
774
                    return ;
746
                    return ;
775
                }
747
                }
Lines 777-783 Link Here
777
                    @Override
749
                    @Override
778
                    public void run() {
750
                    public void run() {
779
                        try {
751
                        try {
780
                            d.getClass().getMethod("resume").invoke(d); // NOI18N
752
                            ds.resume();
781
                        } catch (Exception ex) {
753
                        } catch (Exception ex) {
782
                            Exceptions.printStackTrace(ex);
754
                            Exceptions.printStackTrace(ex);
783
                        }
755
                        }
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/KeyboardPopupSwitcher.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import java.awt.AWTEvent;
47
import java.awt.AWTEvent;
48
import java.awt.Component;
48
import java.awt.Component;
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/SwitcherTable.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import java.awt.Color;
47
import java.awt.Color;
48
import java.awt.Component;
48
import java.awt.Component;
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/SwitcherTableItem.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import javax.swing.Icon;
47
import javax.swing.Icon;
48
48
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/SwitcherTableModel.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import javax.swing.event.TableModelEvent;
47
import javax.swing.event.TableModelEvent;
48
import javax.swing.table.AbstractTableModel;
48
import javax.swing.table.AbstractTableModel;
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/TapPanel.java (-1 / +1 lines)
Lines 42-48 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import javax.swing.*;
47
import javax.swing.*;
48
import java.awt.*;
48
import java.awt.*;
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/ThreadsHistoryAction.java (-46 / +30 lines)
Lines 43-49 Link Here
43
 */
43
 */
44
44
45
45
46
package org.netbeans.modules.debugger.jpda.ui.debugging;
46
package org.netbeans.modules.debugger.ui.views.debugging;
47
47
48
import java.awt.Color;
48
import java.awt.Color;
49
import java.awt.Component;
49
import java.awt.Component;
Lines 65-74 Link Here
65
import javax.swing.KeyStroke;
65
import javax.swing.KeyStroke;
66
import org.netbeans.api.debugger.DebuggerManager;
66
import org.netbeans.api.debugger.DebuggerManager;
67
import org.netbeans.api.debugger.Session;
67
import org.netbeans.api.debugger.Session;
68
import org.netbeans.api.debugger.jpda.DeadlockDetector.Deadlock;
68
import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport;
69
import org.netbeans.api.debugger.jpda.JPDADebugger;
69
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
70
import org.netbeans.api.debugger.jpda.JPDAThread;
70
import org.netbeans.spi.debugger.ui.DebuggingView.Deadlock;
71
import org.netbeans.modules.debugger.jpda.ui.models.DebuggingNodeModel;
72
import org.openide.util.ImageUtilities;
71
import org.openide.util.ImageUtilities;
73
import org.openide.util.NbBundle;
72
import org.openide.util.NbBundle;
74
import org.openide.util.Utilities;
73
import org.openide.util.Utilities;
Lines 83-89 Link Here
83
    
82
    
84
    @Override
83
    @Override
85
    public void actionPerformed(ActionEvent evt) {
84
    public void actionPerformed(ActionEvent evt) {
86
        List<JPDAThread> threads = getThreads();
85
        List<DVThread> threads = getThreads();
87
        int threadsCount = threads.size();
86
        int threadsCount = threads.size();
88
        if (threadsCount < 1) {
87
        if (threadsCount < 1) {
89
            Toolkit.getDefaultToolkit().beep();
88
            Toolkit.getDefaultToolkit().beep();
Lines 127-169 Link Here
127
        }
126
        }
128
    }
127
    }
129
    
128
    
130
    public static SwitcherTableItem[] createSwitcherItems(List<JPDAThread> threads) {
129
    public static SwitcherTableItem[] createSwitcherItems(List<DVThread> threads) {
131
        ThreadsListener threadsListener = ThreadsListener.getDefault();
130
        ThreadsListener threadsListener = ThreadsListener.getDefault();
132
        JPDADebugger debugger = threadsListener.getDebugger();
131
        DVSupport debugger = threadsListener.getDVSupport();
133
        JPDAThread currentThread = debugger != null ? debugger.getCurrentThread() : null;
132
        DVThread currentThread = debugger != null ? debugger.getCurrentThread() : null;
134
        // collect all deadlocked threads
133
        // collect all deadlocked threads
135
        Set<Deadlock> deadlocks = debugger != null ? debugger.getThreadsCollector().getDeadlockDetector().getDeadlocks()
134
        Set<Deadlock> deadlocks = debugger != null ? debugger.getDeadlocks()
136
                : Collections.EMPTY_SET;
135
                : Collections.EMPTY_SET;
137
        if (deadlocks == null) {
136
        if (deadlocks == null) {
138
            deadlocks = Collections.EMPTY_SET;
137
            deadlocks = Collections.EMPTY_SET;
139
        }
138
        }
140
        Set<JPDAThread> deadlockedThreads = new HashSet<JPDAThread>();
139
        Set<DVThread> deadlockedThreads = new HashSet<DVThread>();
141
        for (Deadlock deadlock : deadlocks) {
140
        for (Deadlock deadlock : deadlocks) {
142
            deadlockedThreads.addAll(deadlock.getThreads());
141
            deadlockedThreads.addAll(deadlock.getThreads());
143
        }
142
        }
144
        
143
        
145
        SwitcherTableItem[] items = new SwitcherTableItem[threads.size()];
144
        SwitcherTableItem[] items = new SwitcherTableItem[threads.size()];
146
        int i = 0;
145
        int i = 0;
147
        for (JPDAThread thread : threads) {
146
        for (DVThread thread : threads) {
148
            String name;
147
            String name = debugger.getDisplayName(thread);
149
            try {
150
                name = DebuggingNodeModel.getDisplayName(thread, false);
151
                Method method = thread.getClass().getMethod("getDebugger"); // [TODO]
152
                JPDADebugger deb = (JPDADebugger)method.invoke(thread);
153
                method = deb.getClass().getMethod("getSession");
154
                Session session = (Session) method.invoke(deb);
155
                Session currSession = DebuggerManager.getDebuggerManager().getCurrentSession();
156
                if (session != currSession) {
157
                    String str = NbBundle.getMessage(ThreadsHistoryAction.class, "CTL_Session",
158
                            session.getName());
159
                    name = name.charAt(0) + str + ", " + name.substring(1);
160
                }
161
            } catch (Exception e) { // [TODO]
162
                name = thread.getName();
163
            }
164
            String htmlName = name;
148
            String htmlName = name;
165
            String description = ""; // tc.getToolTipText();
149
            String description = ""; // tc.getToolTipText();
166
            Image image = ImageUtilities.loadImage(DebuggingNodeModel.getIconBase(thread));
150
            Image image = debugger.getIcon(thread);//ImageUtilities.loadImage(DebuggingNodeModel.getIconBase(thread));
167
            Icon icon = null;
151
            Icon icon = null;
168
            if (image != null) {
152
            if (image != null) {
169
                boolean isCurrent = thread == currentThread;
153
                boolean isCurrent = thread == currentThread;
Lines 186-194 Link Here
186
    
170
    
187
    private static class ActivatableElement implements SwitcherTableItem.Activatable {
171
    private static class ActivatableElement implements SwitcherTableItem.Activatable {
188
        
172
        
189
        JPDAThread thread;
173
        DVThread thread;
190
        
174
        
191
        private ActivatableElement(JPDAThread thread) {
175
        private ActivatableElement(DVThread thread) {
192
            this.thread = thread;
176
            this.thread = thread;
193
        }
177
        }
194
        @Override
178
        @Override
Lines 197-217 Link Here
197
        }
181
        }
198
    }
182
    }
199
    
183
    
200
    public static List<JPDAThread> getThreads() {
184
    public static List<DVThread> getThreads() {
201
        ThreadsListener threadsListener = ThreadsListener.getDefault();
185
        ThreadsListener threadsListener = ThreadsListener.getDefault();
202
        if (threadsListener == null) {
186
        if (threadsListener == null) {
203
            return Collections.emptyList();
187
            return Collections.emptyList();
204
        }
188
        }
205
        List<JPDAThread> history = threadsListener.getCurrentThreadsHistory();
189
        List<DVThread> history = threadsListener.getCurrentThreadsHistory();
206
        List<JPDAThread> allThreads = threadsListener.getThreads();
190
        List<DVThread> allThreads = threadsListener.getThreads();
207
        Set<JPDAThread> hitsSet = new HashSet<JPDAThread>();
191
        Set<DVThread> hitsSet = new HashSet<DVThread>();
208
        for (JPDAThread hit : threadsListener.getHits()) {
192
        for (DVThread hit : threadsListener.getHits()) {
209
            hitsSet.add(hit);
193
            hitsSet.add(hit);
210
        }
194
        }
211
        Set set = new HashSet(history);
195
        Set set = new HashSet(history);
212
        List<JPDAThread> result = new LinkedList<JPDAThread>();
196
        List<DVThread> result = new LinkedList<DVThread>();
213
        result.addAll(history);
197
        result.addAll(history);
214
        for (JPDAThread thread : allThreads) {
198
        for (DVThread thread : allThreads) {
215
            if (!set.contains(thread) && thread.isSuspended()) {
199
            if (!set.contains(thread) && thread.isSuspended()) {
216
                result.add(thread);
200
                result.add(thread);
217
            }
201
            }
Lines 220-226 Link Here
220
            int index = 1;
204
            int index = 1;
221
            int size = result.size();
205
            int size = result.size();
222
            for (int x = 1; x < size; x++) {
206
            for (int x = 1; x < size; x++) {
223
                JPDAThread t = result.get(x);
207
                DVThread t = result.get(x);
224
                if (hitsSet.contains(t)) {
208
                if (hitsSet.contains(t)) {
225
                    if (x > index) {
209
                    if (x > index) {
226
                        result.remove(x);
210
                        result.remove(x);
Lines 256-269 Link Here
256
            Color primaryColor = null;
240
            Color primaryColor = null;
257
            Color secondaryColor = null;
241
            Color secondaryColor = null;
258
            if (isInDeadlock) {
242
            if (isInDeadlock) {
259
                primaryColor = DebuggingView.deadlockColor;
243
                primaryColor = DebuggingViewComponent.deadlockColor;
260
            } else if (isCurrent) {
244
            } else if (isCurrent) {
261
                primaryColor = DebuggingView.greenBarColor;
245
                primaryColor = DebuggingViewComponent.greenBarColor;
262
            } else if (isAtBreakpoint) {
246
            } else if (isAtBreakpoint) {
263
                primaryColor = DebuggingView.hitsBarColor;
247
                primaryColor = DebuggingViewComponent.hitsBarColor;
264
            }
248
            }
265
            if (isCurrent && isInDeadlock) {
249
            if (isCurrent && isInDeadlock) {
266
                secondaryColor = DebuggingView.greenBarColor;
250
                secondaryColor = DebuggingViewComponent.greenBarColor;
267
            }
251
            }
268
            
252
            
269
            Color originalColor = g.getColor();
253
            Color originalColor = g.getColor();
Lines 272-283 Link Here
272
            g.drawImage(image, x + width, y, iconBase.getImageObserver());
256
            g.drawImage(image, x + width, y, iconBase.getImageObserver());
273
            if (primaryColor != null) {
257
            if (primaryColor != null) {
274
                g.setColor(primaryColor);
258
                g.setColor(primaryColor);
275
                g.fillRect(x, y, DebuggingView.BAR_WIDTH, height);
259
                g.fillRect(x, y, DebuggingViewComponent.BAR_WIDTH, height);
276
            }
260
            }
277
            if (secondaryColor != null) {
261
            if (secondaryColor != null) {
278
                g.setColor(secondaryColor);
262
                g.setColor(secondaryColor);
279
                int w = DebuggingView.BAR_WIDTH / 2 + 1;
263
                int w = DebuggingViewComponent.BAR_WIDTH / 2 + 1;
280
                g.fillRect(x + DebuggingView.BAR_WIDTH - w, y, w, height);
264
                g.fillRect(x + DebuggingViewComponent.BAR_WIDTH - w, y, w, height);
281
            }
265
            }
282
            g.setColor(originalColor);
266
            g.setColor(originalColor);
283
        }
267
        }
(-)a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/debugging/ThreadsListener.java (-93 / +90 lines)
Lines 42-50 Link Here
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
44
45
package org.netbeans.modules.debugger.jpda.ui.debugging;
45
package org.netbeans.modules.debugger.ui.views.debugging;
46
46
47
import java.beans.Customizer;
48
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
50
import java.beans.PropertyChangeSupport;
49
import java.beans.PropertyChangeSupport;
Lines 55-69 Link Here
55
import java.util.Map;
54
import java.util.Map;
56
import java.util.Set;
55
import java.util.Set;
57
import java.util.WeakHashMap;
56
import java.util.WeakHashMap;
57
import org.netbeans.api.debugger.Breakpoint;
58
import org.netbeans.api.debugger.DebuggerEngine;
58
import org.netbeans.api.debugger.DebuggerEngine;
59
import org.netbeans.api.debugger.DebuggerManager;
59
import org.netbeans.api.debugger.DebuggerManager;
60
import org.netbeans.api.debugger.DebuggerManagerAdapter;
60
import org.netbeans.api.debugger.DebuggerManagerAdapter;
61
import org.netbeans.api.debugger.LazyDebuggerManagerListener;
61
import org.netbeans.api.debugger.LazyDebuggerManagerListener;
62
import org.netbeans.api.debugger.jpda.DeadlockDetector;
63
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
64
import org.netbeans.api.debugger.jpda.JPDADebugger;
65
import org.netbeans.api.debugger.jpda.JPDAThread;
66
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
62
import org.netbeans.spi.debugger.DebuggerServiceRegistration;
63
import org.netbeans.spi.debugger.ui.DebuggingView.DVSupport;
64
import org.netbeans.spi.debugger.ui.DebuggingView.DVThread;
67
import org.openide.util.Exceptions;
65
import org.openide.util.Exceptions;
68
66
69
@DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
67
@DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
Lines 73-83 Link Here
73
    private static PropertyChangeSupport pchs = new PropertyChangeSupport(ThreadsListener.class);
71
    private static PropertyChangeSupport pchs = new PropertyChangeSupport(ThreadsListener.class);
74
    private static final ThreadsPropertyChangeListener tpchl = new ThreadsPropertyChangeListener();
72
    private static final ThreadsPropertyChangeListener tpchl = new ThreadsPropertyChangeListener();
75
    
73
    
76
    final LinkedList<JPDAThread> currentThreadsHistory = new LinkedList();
74
    final LinkedList<DVThread> currentThreadsHistory = new LinkedList();
77
    final BreakpointHits hits = new BreakpointHits();
75
    final BreakpointHits hits = new BreakpointHits();
78
    private Map<JPDADebugger, DebuggerListener> debuggerToListener = new WeakHashMap<JPDADebugger, DebuggerListener>();
76
    private Map<DVSupport, DebuggerListener> debuggerToListener = new WeakHashMap<DVSupport, DebuggerListener>();
79
    private JPDADebugger currentDebugger = null;
77
    private DVSupport currentDebugger = null;
80
    private DebuggingView debuggingView;
78
    private DebuggingViewComponent debuggingView;
81
    
79
    
82
    /**
80
    /**
83
     * Constructor for the registry only.
81
     * Constructor for the registry only.
Lines 103-124 Link Here
103
        pchs.removePropertyChangeListener(listener);
101
        pchs.removePropertyChangeListener(listener);
104
    }
102
    }
105
    
103
    
106
    public void setDebuggingView(DebuggingView debuggingView) {
104
    public void setDebuggingView(DVSupport dvs, DebuggingViewComponent debuggingView) {
107
        this.debuggingView = debuggingView;
105
        this.debuggingView = debuggingView;
108
        InfoPanel infoPanel = debuggingView.getInfoPanel();
106
        InfoPanel infoPanel = debuggingView.getInfoPanel();
109
        infoPanel.setBreakpointHits(getHits());
107
        infoPanel.setBreakpointHits(dvs, getHits());
110
    }
108
    }
111
    
109
    
112
    public synchronized void changeDebugger(JPDADebugger deb) {
110
    public synchronized void changeDebugger(DVSupport deb) {
113
        if (currentDebugger == deb) {
111
        if (currentDebugger == deb) {
114
            return;
112
            return;
115
        }
113
        }
116
        if (currentDebugger != null) {
114
        if (currentDebugger != null) {
117
            currentDebugger.getThreadsCollector().removePropertyChangeListener(tpchl);
115
            currentDebugger.removePropertyChangeListener(tpchl);
118
        }
116
        }
119
        if (deb != null) {
117
        if (deb != null) {
120
            deb.getThreadsCollector().addPropertyChangeListener(tpchl);
118
            deb.addPropertyChangeListener(tpchl);
121
            JPDAThread currThread = deb.getCurrentThread();
119
            DVThread currThread = deb.getCurrentThread();
122
            if (currThread != null) {
120
            if (currThread != null) {
123
                synchronized(currentThreadsHistory) {
121
                synchronized(currentThreadsHistory) {
124
                    currentThreadsHistory.remove(currThread);
122
                    currentThreadsHistory.remove(currThread);
Lines 141-155 Link Here
141
            InfoPanel infoPanel = debuggingView.getInfoPanel();
139
            InfoPanel infoPanel = debuggingView.getInfoPanel();
142
            DebuggerListener listener = debuggerToListener.get(deb);
140
            DebuggerListener listener = debuggerToListener.get(deb);
143
            if (listener != null) {
141
            if (listener != null) {
144
                DeadlockDetector detector = deb.getThreadsCollector().getDeadlockDetector();
142
                //DeadlockDetector detector = deb.getThreadsCollector().getDeadlockDetector();
145
                detector.addPropertyChangeListener(this);
143
                //detector.addPropertyChangeListener(this);
146
                if (detector.getDeadlocks() != null) {
144
                if (deb.getDeadlocks() != null) {
147
                    infoPanel.setShowDeadlock(true);
145
                    infoPanel.setShowDeadlock(true);
148
                }
146
                }
149
                infoPanel.setShowThreadLocks(listener.lockedThread, listener.lockerThreads);
147
                infoPanel.setShowThreadLocks(listener.lockedThread, listener.lockerThreads);
150
                infoPanel.setShowStepBrkp(listener.debugger, listener.stepBrkpThread, listener.stepBrkpBreakpoint);
148
                infoPanel.setShowStepBrkp(listener.debugger, listener.stepBrkpThread, listener.stepBrkpBreakpoint);
151
            }
149
            }
152
            infoPanel.recomputeMenuItems(getHits());
150
            infoPanel.recomputeMenuItems(deb, getHits());
153
        } else {
151
        } else {
154
            // Release reference to DebuggingView when there's no debugger.
152
            // Release reference to DebuggingView when there's no debugger.
155
            debuggingView = null;
153
            debuggingView = null;
Lines 157-166 Link Here
157
        this.currentDebugger = deb;
155
        this.currentDebugger = deb;
158
    }
156
    }
159
    
157
    
160
    public synchronized List<JPDAThread> getCurrentThreadsHistory() {
158
    public synchronized List<DVThread> getCurrentThreadsHistory() {
161
        synchronized(currentThreadsHistory) {
159
        synchronized(currentThreadsHistory) {
162
            List<JPDAThread> result = new ArrayList<JPDAThread>(currentThreadsHistory.size());
160
            List<DVThread> result = new ArrayList<DVThread>(currentThreadsHistory.size());
163
            for (JPDAThread thread : currentThreadsHistory) {
161
            for (DVThread thread : currentThreadsHistory) {
164
                if (thread.isSuspended()) {
162
                if (thread.isSuspended()) {
165
                    result.add(thread);
163
                    result.add(thread);
166
                }
164
                }
Lines 169-185 Link Here
169
        }
167
        }
170
    }
168
    }
171
    
169
    
172
    public synchronized List<JPDAThread> getThreads() {
170
    public synchronized List<DVThread> getThreads() {
173
        List<JPDAThread> result = new ArrayList<JPDAThread>();
171
        List<DVThread> result = new ArrayList<DVThread>();
174
        for (JPDADebugger debugger : debuggerToListener.keySet()) {
172
        for (DVSupport debugger : debuggerToListener.keySet()) {
175
            if (debugger != null && debugger.getState() != JPDADebugger.STATE_DISCONNECTED) {
173
            if (debugger != null && debugger.getState() != DVSupport.STATE.DISCONNECTED) {
176
                result.addAll(debugger.getThreadsCollector().getAllThreads());
174
                result.addAll(debugger.getAllThreads());
177
            }
175
            }
178
        }
176
        }
179
        return result;
177
        return result;
180
    }
178
    }
181
179
182
    private void addBreakpointHit(JPDAThread thread) {
180
    private void addBreakpointHit(DVThread thread) {
183
        if (thread != null && !hits.contains(thread)) {
181
        if (thread != null && !hits.contains(thread)) {
184
            // System.out.println("Hit added: " + thread.getName());
182
            // System.out.println("Hit added: " + thread.getName());
185
            hits.add(thread);
183
            hits.add(thread);
Lines 189-195 Link Here
189
        }
187
        }
190
    }
188
    }
191
189
192
    private void removeBreakpointHit(JPDAThread thread) {
190
    private void removeBreakpointHit(DVThread thread) {
193
        if (thread != null && hits.contains(thread)) {
191
        if (thread != null && hits.contains(thread)) {
194
            // System.out.println("Hit removed: " + thread.getName());
192
            // System.out.println("Hit removed: " + thread.getName());
195
            hits.remove(thread);
193
            hits.remove(thread);
Lines 199-207 Link Here
199
        }
197
        }
200
    }
198
    }
201
    
199
    
202
    public synchronized List<JPDAThread> getHits() {
200
    public synchronized List<DVThread> getHits() {
203
        List<JPDAThread> result = new ArrayList<JPDAThread>();
201
        List<DVThread> result = new ArrayList<DVThread>();
204
        for (JPDAThread thread : hits.getStoppedThreads()) {
202
        for (DVThread thread : hits.getStoppedThreads()) {
205
            result.add(thread);
203
            result.add(thread);
206
        }
204
        }
207
        return result;
205
        return result;
Lines 211-217 Link Here
211
        return hits.size();
209
        return hits.size();
212
    }
210
    }
213
    
211
    
214
    public synchronized boolean isBreakpointHit(JPDAThread thread) {
212
    public synchronized boolean isBreakpointHit(DVThread thread) {
215
        return hits.contains(thread);
213
        return hits.contains(thread);
216
    }
214
    }
217
    
215
    
Lines 219-225 Link Here
219
        hits.goToHit();
217
        hits.goToHit();
220
    }
218
    }
221
    
219
    
222
    public JPDADebugger getDebugger() {
220
    public DVSupport getDVSupport() {
223
        return currentDebugger;
221
        return currentDebugger;
224
    }
222
    }
225
223
Lines 230-236 Link Here
230
228
231
    @Override
229
    @Override
232
    public synchronized void engineAdded(DebuggerEngine engine) {
230
    public synchronized void engineAdded(DebuggerEngine engine) {
233
        JPDADebugger deb = engine.lookupFirst(null, JPDADebugger.class);
231
        DVSupport deb = engine.lookupFirst(null, DVSupport.class);
234
        if (deb != null) {
232
        if (deb != null) {
235
            DebuggerListener listener = new DebuggerListener(deb);
233
            DebuggerListener listener = new DebuggerListener(deb);
236
            debuggerToListener.put(deb, listener);
234
            debuggerToListener.put(deb, listener);
Lines 242-248 Link Here
242
240
243
    @Override
241
    @Override
244
    public synchronized void engineRemoved(DebuggerEngine engine) {
242
    public synchronized void engineRemoved(DebuggerEngine engine) {
245
        JPDADebugger deb = engine.lookupFirst(null, JPDADebugger.class);
243
        DVSupport deb = engine.lookupFirst(null, DVSupport.class);
246
        if (deb != null) {
244
        if (deb != null) {
247
            DebuggerListener listener = debuggerToListener.remove(deb);
245
            DebuggerListener listener = debuggerToListener.remove(deb);
248
            if (listener != null) {
246
            if (listener != null) {
Lines 260-282 Link Here
260
258
261
    class DebuggerListener implements PropertyChangeListener {
259
    class DebuggerListener implements PropertyChangeListener {
262
260
263
        private JPDADebugger debugger;
261
        private DVSupport debugger;
264
        Set<JPDAThread> threads = new HashSet<JPDAThread>();
262
        Set<DVThread> threads = new HashSet<DVThread>();
265
        List<JPDAThread> lockerThreads;
263
        List<DVThread> lockerThreads;
266
        JPDAThread lockedThread;
264
        DVThread lockedThread;
267
        JPDAThread stepBrkpThread;
265
        DVThread stepBrkpThread;
268
        JPDABreakpoint stepBrkpBreakpoint;
266
        Breakpoint stepBrkpBreakpoint;
269
267
270
        DebuggerListener(JPDADebugger debugger) {
268
        DebuggerListener(DVSupport debugger) {
271
            this.debugger = debugger;
269
            this.debugger = debugger;
272
            debugger.addPropertyChangeListener(this);
270
            debugger.addPropertyChangeListener(this);
273
            List<JPDAThread> allThreads = debugger.getThreadsCollector().getAllThreads();
271
            List<DVThread> allThreads = debugger.getAllThreads();
274
            for (JPDAThread thread : allThreads) {
272
            for (DVThread thread : allThreads) {
275
                threads.add(thread);
273
                threads.add(thread);
276
                ((Customizer)thread).addPropertyChangeListener(this);
274
                thread.addPropertyChangeListener(this);
277
            }
275
            }
278
            DeadlockDetector detector = debugger.getThreadsCollector().getDeadlockDetector();
276
            //DeadlockDetector detector = debugger.getThreadsCollector().getDeadlockDetector();
279
            detector.addPropertyChangeListener(this);
277
            //detector.addPropertyChangeListener(this);
280
        }
278
        }
281
279
282
        public synchronized void propertyChange(PropertyChangeEvent evt) {
280
        public synchronized void propertyChange(PropertyChangeEvent evt) {
Lines 284-321 Link Here
284
            String propName = evt.getPropertyName();
282
            String propName = evt.getPropertyName();
285
            Object source = evt.getSource();
283
            Object source = evt.getSource();
286
284
287
            if (source instanceof JPDADebugger) {
285
            if (source instanceof DVSupport) {
288
                if (JPDADebugger.PROP_THREAD_STARTED.equals(propName)) {
286
                if (DVSupport.PROP_THREAD_STARTED.equals(propName)) {
289
                    //System.out.println("STARTED: " + evt.getNewValue());
287
                    //System.out.println("STARTED: " + evt.getNewValue());
290
                    final JPDAThread jpdaThread = (JPDAThread)evt.getNewValue();
288
                    final DVThread jpdaThread = (DVThread)evt.getNewValue();
291
                    if (threads.add(jpdaThread)) {
289
                    if (threads.add(jpdaThread)) {
292
                        ((Customizer)jpdaThread).addPropertyChangeListener(this);
290
                        jpdaThread.addPropertyChangeListener(this);
293
                        // System.out.println("WATCHED: " + jpdaThread.getName());
291
                        // System.out.println("WATCHED: " + jpdaThread.getName());
294
                    }
292
                    }
295
                } else if (JPDADebugger.PROP_THREAD_DIED.equals(propName)) {
293
                } else if (DVSupport.PROP_THREAD_DIED.equals(propName)) {
296
                    //System.out.println("DIED: " + evt.getOldValue());
294
                    //System.out.println("DIED: " + evt.getOldValue());
297
                    JPDAThread jpdaThread = (JPDAThread)evt.getOldValue();
295
                    DVThread jpdaThread = (DVThread)evt.getOldValue();
298
                    if (threads.remove(jpdaThread)) {
296
                    if (threads.remove(jpdaThread)) {
299
                        synchronized(currentThreadsHistory) {
297
                        synchronized(currentThreadsHistory) {
300
                            currentThreadsHistory.remove(jpdaThread);
298
                            currentThreadsHistory.remove(jpdaThread);
301
                        }
299
                        }
302
                        ((Customizer)jpdaThread).removePropertyChangeListener(this);
300
                        jpdaThread.removePropertyChangeListener(this);
303
                        // System.out.println("RELEASED: " + jpdaThread.getName());
301
                        // System.out.println("RELEASED: " + jpdaThread.getName());
304
                    }
302
                    }
305
                } else if (JPDADebugger.PROP_CURRENT_THREAD.equals(propName)) {
303
                } else if (DVSupport.PROP_CURRENT_THREAD.equals(propName)) {
306
                    JPDAThread currentThread = debugger.getCurrentThread();
304
                    DVThread currentThread = debugger.getCurrentThread();
307
                    removeBreakpointHit(currentThread);
305
                    removeBreakpointHit(currentThread);
308
                    synchronized(currentThreadsHistory) {
306
                    synchronized(currentThreadsHistory) {
309
                        currentThreadsHistory.remove(currentThread);
307
                        currentThreadsHistory.remove(currentThread);
310
                        currentThreadsHistory.addFirst(currentThread);
308
                        currentThreadsHistory.addFirst(currentThread);
311
                    }
309
                    }
312
                } else if (JPDADebugger.PROP_STATE.equals(propName) &&
310
                } else if (DVSupport.PROP_STATE.equals(propName) &&
313
                        debugger != null && debugger.getState() == JPDADebugger.STATE_DISCONNECTED) {
311
                           debugger != null && debugger.getState() == DVSupport.STATE.DISCONNECTED) {
314
                    unregister();
312
                    unregister();
313
                } else if (DVSupport.PROP_DEADLOCK.equals(propName)) {
314
                    setShowDeadlock(true);
315
                }
315
                }
316
            } else if (source instanceof JPDAThread) {
316
            } else if (source instanceof DVThread) {
317
                final JPDAThread thread = (JPDAThread)source;
317
                final DVThread thread = (DVThread)source;
318
                if (JPDAThread.PROP_BREAKPOINT.equals(propName)) {
318
                if (DVThread.PROP_BREAKPOINT.equals(propName)) {
319
                    // System.out.println("THREAD: " + thread.getName() + ", curr: " + isCurrent(thread) + ", brk: " + isAtBreakpoint(thread));
319
                    // System.out.println("THREAD: " + thread.getName() + ", curr: " + isCurrent(thread) + ", brk: " + isAtBreakpoint(thread));
320
                    if (!isCurrent(thread)) {
320
                    if (!isCurrent(thread)) {
321
                        if (isAtBreakpoint(thread)) {
321
                        if (isAtBreakpoint(thread)) {
Lines 329-374 Link Here
329
                    if (debugger == currentDebugger && debuggingView != null) {
329
                    if (debugger == currentDebugger && debuggingView != null) {
330
                        debuggingView.refreshView(); // [TODO]
330
                        debuggingView.refreshView(); // [TODO]
331
                    }
331
                    }
332
                } else if (JPDAThread.PROP_SUSPENDED.equals(propName)) {
332
                } else if (DVThread.PROP_SUSPENDED.equals(propName)) {
333
                    if (!thread.isSuspended()) {
333
                    if (!thread.isSuspended()) {
334
                        removeBreakpointHit(thread);
334
                        removeBreakpointHit(thread);
335
                    }
335
                    }
336
                    if (debugger == currentDebugger && debuggingView != null) {
336
                    if (debugger == currentDebugger && debuggingView != null) {
337
                        debuggingView.refreshView(); // [TODO]
337
                        debuggingView.refreshView(); // [TODO]
338
                    }
338
                    }
339
                } else if ("lockerThreads".equals(propName)) { // NOI18N
339
                } else if (DVThread.PROP_LOCKER_THREADS.equals(propName)) { // NOI18N
340
                    // Calling List<JPDAThread> getLockerThreads()
340
                    // Calling List<DVThread> getLockerThreads()
341
                    List<JPDAThread> currLockerThreads;
341
                    List<DVThread> currLockerThreads = thread.getLockerThreads();
342
                    /*List<DVThread> currLockerThreads;
342
                    try {
343
                    try {
343
                        java.lang.reflect.Method lockerThreadsMethod = thread.getClass().getMethod("getLockerThreads", new Class[] {}); // NOI18N
344
                        java.lang.reflect.Method lockerThreadsMethod = thread.getClass().getMethod("getLockerThreads", new Class[] {}); // NOI18N
344
                        currLockerThreads = (List<JPDAThread>) lockerThreadsMethod.invoke(thread, new Object[] {});
345
                        currLockerThreads = (List<DVThread>) lockerThreadsMethod.invoke(thread, new Object[] {});
345
                    } catch (Exception ex) {
346
                    } catch (Exception ex) {
346
                        Exceptions.printStackTrace(ex);
347
                        Exceptions.printStackTrace(ex);
347
                        currLockerThreads = null;
348
                        currLockerThreads = null;
348
                    }
349
                    }*/
349
                    setShowThreadLocks(thread, currLockerThreads);
350
                    setShowThreadLocks(thread, currLockerThreads);
350
                } else if ("stepSuspendedByBreakpoint".equals(propName)) {
351
                } else if ("stepSuspendedByBreakpoint".equals(propName)) {
351
                    setShowStepBrkp(thread, (JPDABreakpoint) evt.getNewValue());
352
                    setShowStepBrkp(thread, (Breakpoint) evt.getNewValue());
352
                }
353
            } else if (source instanceof DeadlockDetector) {
354
                if (DeadlockDetector.PROP_DEADLOCK.equals(propName)) {
355
                    setShowDeadlock(true);
356
                }
353
                }
357
            }
354
            }
358
        }
355
        }
359
356
360
        private synchronized void unregister() {
357
        private synchronized void unregister() {
361
            if (debugger == null) return ;
358
            if (debugger == null) return ;
362
            for (JPDAThread thread : threads) {
359
            for (DVThread thread : threads) {
363
                ((Customizer) thread).removePropertyChangeListener(this);
360
                thread.removePropertyChangeListener(this);
364
            }
361
            }
365
            synchronized(currentThreadsHistory) {
362
            synchronized(currentThreadsHistory) {
366
                for (JPDAThread thread : threads) {
363
                for (DVThread thread : threads) {
367
                    currentThreadsHistory.remove(thread);
364
                    currentThreadsHistory.remove(thread);
368
                }
365
                }
369
            }
366
            }
370
            synchronized(hits) {
367
            synchronized(hits) {
371
                for (JPDAThread thread : threads) {
368
                for (DVThread thread : threads) {
372
                    removeBreakpointHit(thread);
369
                    removeBreakpointHit(thread);
373
                }
370
                }
374
            }
371
            }
Lines 378-394 Link Here
378
            stepBrkpThread = null;
375
            stepBrkpThread = null;
379
            stepBrkpBreakpoint = null;
376
            stepBrkpBreakpoint = null;
380
            debugger.removePropertyChangeListener(this);
377
            debugger.removePropertyChangeListener(this);
381
            debugger.getThreadsCollector().getDeadlockDetector().removePropertyChangeListener(this);
378
            debugger./*getThreadsCollector().getDeadlockDetector().*/removePropertyChangeListener(this);
382
            debugger = null;
379
            debugger = null;
383
        }
380
        }
384
        
381
        
385
        private boolean isCurrent(JPDAThread thread) {
382
        private boolean isCurrent(DVThread thread) {
386
            return debugger.getCurrentThread() == thread;
383
            return debugger.getCurrentThread() == thread;
387
        }
384
        }
388
385
389
        private boolean isAtBreakpoint(JPDAThread thread) {
386
        private boolean isAtBreakpoint(DVThread thread) {
390
            JPDABreakpoint breakpoint = thread.getCurrentBreakpoint();
387
            Breakpoint breakpoint = thread.getCurrentBreakpoint();
391
            return breakpoint != null && !breakpoint.isHidden();
388
            return breakpoint != null;// && !breakpoint.isHidden();
392
        }
389
        }
393
390
394
        private void setShowDeadlock(boolean detected) {
391
        private void setShowDeadlock(boolean detected) {
Lines 397-403 Link Here
397
            }
394
            }
398
        }
395
        }
399
396
400
        private void setShowThreadLocks(JPDAThread thread, List<JPDAThread> currLockerThreads) {
397
        private void setShowThreadLocks(DVThread thread, List<DVThread> currLockerThreads) {
401
            lockerThreads = currLockerThreads;
398
            lockerThreads = currLockerThreads;
402
            lockedThread = thread;
399
            lockedThread = thread;
403
            if (debugger == currentDebugger && debuggingView != null) {
400
            if (debugger == currentDebugger && debuggingView != null) {
Lines 405-411 Link Here
405
            }
402
            }
406
        }
403
        }
407
        
404
        
408
        private void setShowStepBrkp(JPDAThread thread, JPDABreakpoint breakpoint) {
405
        private void setShowStepBrkp(DVThread thread, Breakpoint breakpoint) {
409
            stepBrkpThread = thread;
406
            stepBrkpThread = thread;
410
            stepBrkpBreakpoint = breakpoint;
407
            stepBrkpBreakpoint = breakpoint;
411
            if (debugger == currentDebugger && debuggingView != null) {
408
            if (debugger == currentDebugger && debuggingView != null) {
Lines 416-437 Link Here
416
    }
413
    }
417
414
418
    static class BreakpointHits {
415
    static class BreakpointHits {
419
        private Set<JPDAThread> stoppedThreadsSet = new HashSet<JPDAThread>();
416
        private Set<DVThread> stoppedThreadsSet = new HashSet<DVThread>();
420
        private LinkedList<JPDAThread> stoppedThreads = new LinkedList<JPDAThread>();
417
        private LinkedList<DVThread> stoppedThreads = new LinkedList<DVThread>();
421
        
418
        
422
        public void goToHit() {
419
        public void goToHit() {
423
            JPDAThread thread;
420
            DVThread thread;
424
            synchronized (this) {
421
            synchronized (this) {
425
                thread = stoppedThreads.getLast();
422
                thread = stoppedThreads.getLast();
426
            }
423
            }
427
            thread.makeCurrent();
424
            thread.makeCurrent();
428
        }
425
        }
429
        
426
        
430
        public synchronized boolean contains(JPDAThread thread) {
427
        public synchronized boolean contains(DVThread thread) {
431
            return stoppedThreadsSet.contains(thread);
428
            return stoppedThreadsSet.contains(thread);
432
        }
429
        }
433
        
430
        
434
        public synchronized boolean add(JPDAThread thread) {
431
        public synchronized boolean add(DVThread thread) {
435
            if (stoppedThreadsSet.add(thread)) {
432
            if (stoppedThreadsSet.add(thread)) {
436
                stoppedThreads.addFirst(thread);
433
                stoppedThreads.addFirst(thread);
437
                return true;
434
                return true;
Lines 439-445 Link Here
439
            return false;
436
            return false;
440
        }
437
        }
441
        
438
        
442
        public synchronized boolean remove(JPDAThread thread) {
439
        public synchronized boolean remove(DVThread thread) {
443
            if (stoppedThreadsSet.remove(thread)) {
440
            if (stoppedThreadsSet.remove(thread)) {
444
                stoppedThreads.remove(thread);
441
                stoppedThreads.remove(thread);
445
                return true;
442
                return true;
Lines 456-463 Link Here
456
            return stoppedThreads.size();
453
            return stoppedThreads.size();
457
        }
454
        }
458
455
459
        private synchronized Iterable<JPDAThread> getStoppedThreads() {
456
        private synchronized Iterable<DVThread> getStoppedThreads() {
460
            return new ArrayList<JPDAThread>(stoppedThreads);
457
            return new ArrayList<DVThread>(stoppedThreads);
461
        }
458
        }
462
        
459
        
463
    }
460
    }
(-)a/spi.debugger.ui/src/org/netbeans/spi/debugger/ui/DebuggingView.java (+626 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 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 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.spi.debugger.ui;
44
45
import java.awt.Image;
46
import java.beans.PropertyChangeEvent;
47
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeSupport;
49
import java.lang.annotation.ElementType;
50
import java.lang.annotation.Retention;
51
import java.lang.annotation.RetentionPolicy;
52
import java.lang.annotation.Target;
53
import java.lang.ref.Reference;
54
import java.lang.ref.WeakReference;
55
import java.util.Collection;
56
import java.util.LinkedList;
57
import java.util.List;
58
import java.util.Set;
59
import java.util.prefs.Preferences;
60
import javax.swing.Action;
61
import javax.swing.Icon;
62
import org.netbeans.api.debugger.Breakpoint;
63
import org.netbeans.api.debugger.Session;
64
import org.netbeans.modules.debugger.ui.views.debugging.DebuggingViewComponent;
65
import org.netbeans.modules.debugger.ui.views.debugging.FiltersDescriptor;
66
import org.netbeans.modules.debugger.ui.views.debugging.FiltersDescriptor.FilterImpl;
67
import org.netbeans.modules.debugger.ui.views.debugging.FiltersDescriptor.FiltersAccessor;
68
import org.openide.windows.TopComponent;
69
70
/**
71
 * Debugging view component provider. The debugging view displays application threads.
72
 * Implement {@link DVSupport} and register under your session name to use
73
 * debugging view UI and register appropriate view models for path &lt;session name&gt;/DebuggingView.
74
 * 
75
 * @author Martin Entlicher
76
 * @since 2.42
77
 */
78
public final class DebuggingView {
79
    
80
    private final static DebuggingView INSTANCE = new DebuggingView();
81
    
82
    private Reference<DebuggingViewComponent> dvcRef = new WeakReference<DebuggingViewComponent>(null);
83
    
84
    private DebuggingView() {
85
        //this.dvc = DebuggingViewComponent.getInstance();
86
    }
87
    
88
    /**
89
     * Get the default implementation of debugging view provider.
90
     * @return the default instance of debugging view provider.
91
     */
92
    public static DebuggingView getDefault() {
93
        return INSTANCE;
94
    }
95
    
96
    private DebuggingViewComponent getDVC() {
97
        DebuggingViewComponent dvc;
98
        synchronized (this) {
99
            dvc = dvcRef.get();
100
            if (dvc == null) {
101
                dvc = DebuggingViewComponent.getInstance();
102
                dvcRef = new WeakReference<DebuggingViewComponent>(dvc);
103
            }
104
        }
105
        return dvc;
106
    }
107
    
108
    /**
109
     * Get the debugging view top component.
110
     * @return the {@link TopComponent} of the debugging view.
111
     */
112
    public TopComponent getViewTC() {
113
        return getDVC();
114
    }
115
    
116
    /**
117
     * Support for debugging view. The component tree is created from view models
118
     * registered under path &lt;session name&gt;/DebuggingView. But to fully
119
     * support the debugging view UI, additional information is necessary.
120
     * Implement this class to provide the additional information.
121
     * Debugging view is created for the given debugger session only when an
122
     * implementation of this class is found in the current session engine lookup.
123
     */
124
    public static abstract class DVSupport {
125
        
126
        /** Property name constant. */
127
        public static final String          PROP_THREAD_STARTED = "threadStarted";      // NOI18N
128
        /** Property name constant. */
129
        public static final String          PROP_THREAD_DIED = "threadDied";            // NOI18N
130
        /** Property name constant. */
131
        public static final String          PROP_THREAD_GROUP_ADDED = "threadGroupAdded";   // NOI18N
132
        /** Property name constant. */
133
        public static final String          PROP_THREAD_SUSPENDED = "threadSuspended";  // NOI18N
134
        /** Property name constant. */
135
        public static final String          PROP_THREAD_RESUMED = "threadResumed";      // NOI18N
136
        /** Property name constant. */
137
        public static final String          PROP_CURRENT_THREAD = "currentThread";      // NOI18N
138
139
        /**
140
         * Name of property which is fired when deadlock occurs.
141
         */
142
        public static final String          PROP_DEADLOCK = "deadlock";                 // NOI18N
143
        public static final String          PROP_STATE = "state";                       // NOI18N
144
145
        private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
146
        
147
        /**
148
         * The debugger state.
149
         */
150
        public static enum STATE {
151
            RUNNING,
152
            DISCONNECTED
153
        }
154
        
155
        static {
156
            FiltersDescriptor.getInstance().setFiltersAccessor(new FiltersAccessor() {
157
                @Override
158
                public List<DVFilter> getFilters(DVSupport dvs) {
159
                    return dvs.getFilters();
160
                }
161
                @Override
162
                public FilterImpl getImpl(DVFilter filter) {
163
                    return filter.getImpl();
164
                }
165
            });
166
        }
167
        
168
        protected DVSupport() {
169
        }
170
    
171
        /**
172
         * Get the debugger state.
173
         * @return current state of debugger
174
         */
175
        public abstract STATE getState();
176
        
177
        /**
178
         * Get listing of all threads at this moment.
179
         * @return list of all threads
180
         */
181
        public abstract List<DVThread> getAllThreads();
182
        
183
        /**
184
         * Get a current thread, if any.
185
         * @return a current thread, or <code>null</code>.
186
         */
187
        public abstract DVThread getCurrentThread();
188
        
189
        /**
190
         * Get the display name of the thread. It can contain more information
191
         * than a thread name, like current session name, etc.
192
         * @param thread the thread
193
         * @return the thread display name
194
         */
195
        public abstract String getDisplayName(DVThread thread);
196
        
197
        /**
198
         * Get the thread icon.
199
         * @param thread the thread
200
         * @return the thread icon
201
         */
202
        public abstract Image getIcon(DVThread thread);
203
204
        /**
205
         * Get the session associated with this debugging view.
206
         * @return 
207
         */
208
        public abstract Session getSession();
209
210
        /**
211
         * Resume the application (all it's threads).
212
         */
213
        public abstract void resume();
214
215
        /**
216
         * Get the set of detected deadlocks, if any.
217
         * @return The set of deadlocks, or <code>null</code> when no deadlocks are detected.
218
         */
219
        public abstract Set<Deadlock> getDeadlocks();
220
        
221
        /**
222
         * Utility method used by the implementing class to create deadlock description instances.
223
         * @param threads The threads in deadlock
224
         * @return Deadlock instance
225
         */
226
        protected final Deadlock createDeadlock(Collection<DVThread> threads) {
227
            return new Deadlock(threads);
228
        }
229
        
230
        /**
231
         * Get the list of filters applied to debugging view.
232
         * @return list of filters
233
         */
234
        protected abstract List<DVFilter> getFilters();
235
        
236
        /**
237
         * Get actions created from the provided filters.
238
         * The result can be added to actions provider view model.
239
         * @return filter actions.
240
         */
241
        public final Action[] getFilterActions() {
242
            return FiltersDescriptor.getInstance().getFilterActions();
243
        }
244
        
245
        protected final void firePropertyChange(PropertyChangeEvent pce) {
246
            pcs.firePropertyChange(pce);
247
        }
248
        
249
        /**
250
         * Fire a property change event.
251
         * @param propertyName the property name
252
         * @param oldValue old value
253
         * @param newValue new value
254
         */
255
        protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
256
            pcs.firePropertyChange(propertyName, oldValue, newValue);
257
        }
258
        
259
        /**
260
         * Add a property change listener.
261
         * @param pcl the property change listener
262
         */
263
        public final void addPropertyChangeListener(PropertyChangeListener pcl) {
264
            pcs.addPropertyChangeListener(pcl);
265
        }
266
        
267
        /**
268
         * Remove a property change listener.
269
         * @param pcl the property change listener
270
         */
271
        public final void removePropertyChangeListener(PropertyChangeListener pcl) {
272
            pcs.removePropertyChangeListener(pcl);
273
        }
274
        
275
        /**
276
         * Declarative registration of a DVSupport implementation.
277
         * By marking the implementation class with this annotation,
278
         * you automatically register that implementation for use by the debugging view.
279
         * The class must be public and have a public constructor which takes
280
         * no arguments or takes {@link ContextProvider} as an argument.
281
         *
282
         * @author Martin Entlicher
283
         */
284
        @Retention(RetentionPolicy.SOURCE)
285
        @Target({ElementType.TYPE})
286
        public @interface Registration {
287
            /**
288
             * The path to register this implementation in.
289
             * Usually the session ID.
290
             */
291
            String path();
292
            
293
            /**
294
             * An optional position in which to register this service relative to others.
295
             * Lower-numbered services are returned in the lookup result first.
296
             * Services with no specified position are returned last.
297
             */
298
            int position() default Integer.MAX_VALUE;
299
300
        }
301
302
    }
303
    
304
    /**
305
     * Representation of a thread in debugging view.
306
     * Nodes representing a thread in debugging view model should implement this
307
     * interface.
308
     */
309
    public static interface DVThread {
310
        
311
        /**
312
         * Property name fired when a thread gets suspended.
313
         */
314
        public static final String PROP_SUSPENDED = "suspended";            // NOI18N
315
        /**
316
         * Property name fired when list of locker threads change.
317
         */
318
        public static final String PROP_LOCKER_THREADS = "lockerThreads";   // NOI18N
319
        /**
320
         * Property name fired when current breakpoint is changed.
321
         */
322
        public static final String PROP_BREAKPOINT = "currentBreakpoint";   // NOI18N
323
        
324
        /**
325
         * Get the name of the thread.
326
         * @return the name of the thread
327
         */
328
        public String getName();
329
        
330
        /**
331
         * Test if this thread is currently suspended by debugger.
332
         * @return <code>true</code> when the thread is suspended, <code>false</code> otherwise.
333
         */
334
        public boolean isSuspended();
335
        
336
        /**
337
         * Resume this thread.
338
         */
339
        public void resume();
340
341
        /**
342
         * Suspend this thread.
343
         */
344
        public void suspend();
345
        
346
        /**
347
         * Make this thread current. Code evaluation and stepping should be performed
348
         * in the current thread.
349
         */
350
        public void makeCurrent();
351
352
        /**
353
         * Get the debugging view support that provides this thread.
354
         * @return the debugging view support
355
         */
356
        public DVSupport getDVSupport();
357
358
        /**
359
         * Lists threads that hold monitors that this thread is waiting on.
360
         * @return list of locker threads
361
         */
362
        public List<DVThread> getLockerThreads();
363
        
364
        /**
365
         * Resume any suspended threads that block execution of this thread by holding monitors.
366
         */
367
        public void resumeBlockingThreads();
368
369
        /**
370
         * Get current breakpoint, if any. This is a breakpoint that this thread is suspended on.
371
         * @return the current breakpoint or <code>null</code>
372
         */
373
        public Breakpoint getCurrentBreakpoint();
374
        
375
        /**
376
         * Test if this thread is performing a step operation right now.
377
         * @return <code>true</code> if this thread is in a step, <code>false</code> otherwise.
378
         */
379
        public boolean isInStep();
380
381
        /**
382
         * Add a property change listener.
383
         * @param pcl the property change listener
384
         */
385
        public void addPropertyChangeListener(PropertyChangeListener pcl);
386
387
        /**
388
         * Remove a property change listener.
389
         * @param pcl the property change listener
390
         */
391
        public void removePropertyChangeListener(PropertyChangeListener pcl);
392
393
    }
394
    
395
    /**
396
     * Representation of a thread group in debugging view.
397
     * Nodes representing a thread group in debugging view model should implement
398
     * this interface.
399
     */
400
    public static interface DVThreadGroup {
401
        
402
        /**
403
         * Get the name of the thread group.
404
         * @return the name of the thread group
405
         */
406
        public String getName();
407
        
408
        /**
409
         * Get the parent thread group, if exists.
410
         * @return the parent thread group or <code>null</code> if this thread group has no parent (root thread group).
411
         */
412
        public DVThreadGroup getParentThreadGroup();
413
        
414
        /**
415
         * Get this thread group's threads.
416
         * @return threads from this thread group
417
         */
418
        public DVThread[] getThreads();
419
        
420
        /**
421
         * Get this thread group's thread groups.
422
         * @return thread groups from this thread group
423
         */
424
        public DVThreadGroup[] getThreadGroups();
425
    }
426
    
427
    /**
428
     * Representation of a deadlock - one set of mutually deadlocked threads.
429
     */
430
    public static final class Deadlock {
431
432
        private final Collection<DVThread> threads;
433
        
434
        private Deadlock(Collection<DVThread> threads) {
435
            this.threads = threads;
436
        }
437
        
438
        /**
439
         * Get the threads in deadlock.
440
         * @return The threads in deadlock.
441
         */
442
        public Collection<DVThread> getThreads() {
443
            return threads;
444
        }
445
    }
446
    
447
    /**
448
     * Boolean state filter that is applied to the debugging view.
449
     * It's icon is made visible in the debugging view bottom panel.
450
     */
451
    public static final class DVFilter {
452
453
        /**
454
         * Pre-defined default filters enumeration.
455
         */
456
        public static enum DefaultFilter {
457
            sortAlphabetic,
458
            sortSuspend,
459
            sortNatural,
460
            showQualifiedNames,
461
            showMonitors,
462
            showSystemThreads,
463
            showSuspendTable,
464
            showThreadGroups,
465
            showSuspendedThreadsOnly,
466
        }
467
        
468
        private static final Group sortGroup = new Group();
469
        
470
        /**
471
         * Get an instance of a default filter.
472
         * @param filter the default filter kind
473
         * @return filter implementation
474
         */
475
        public static DVFilter getDefault(DefaultFilter filter) {
476
            FilterImpl fimpl = FilterImpl.createDefault(filter);
477
            Group g;
478
            switch (filter) {
479
                case sortAlphabetic:
480
                case sortNatural:
481
                case sortSuspend:
482
                    g = sortGroup;
483
                    break;
484
                default:
485
                    g = null;
486
            }
487
            fimpl.setGroup(g);
488
            return new DVFilter(fimpl, g);
489
        }
490
        
491
        /**
492
         * Create a custom filter.
493
         * @param name name of the filter
494
         * @param displayName display name of the filter (visible in an action menu)
495
         * @param tooltip tool-tip of the filter
496
         * @param selectedIcon icon of the filter
497
         * @param valuePrefs preferences which are asked for the filter value
498
         * @param valuePrefKey key that is used to retrieve the filter value from preferences
499
         * @param isSelectedDefault whether the filter should be selected by default when preferences do not contain the value
500
         * @param group a filter group, can be <code>null</code>
501
         * @return implementation of the filter
502
         */
503
        public static DVFilter create(String name, String displayName,
504
                                      String tooltip, Icon selectedIcon,
505
                                      Preferences valuePrefs, String valuePrefKey,
506
                                      boolean isSelectedDefault, Group group) {
507
            FilterImpl fimpl = new FilterImpl(name, displayName, tooltip, selectedIcon,
508
                                              valuePrefs, valuePrefKey, isSelectedDefault);
509
            fimpl.setGroup(group);
510
            return new DVFilter(fimpl, group);
511
        }
512
        
513
        private final FilterImpl fimpl;
514
        private final Group group;
515
        
516
        DVFilter (FilterImpl fimpl, Group group) {
517
            this.fimpl = fimpl;
518
            this.group = group;
519
            group.add(this);
520
        }
521
522
        private FilterImpl getImpl() {
523
            return fimpl;
524
        }
525
        
526
        /**
527
         * Get the filter group.
528
         * @return the filter group, or <code>null</code> when the filter has no group
529
         */
530
        public Group getGroup() {
531
            return group;
532
        }
533
        
534
        /**
535
         * Get the filter name.
536
         * @return the filter name
537
         */
538
        public String getName() {
539
            return fimpl.getName();
540
        }
541
        
542
        /**
543
         * Get the filter display name.
544
         * @return the filter display name
545
         */
546
        public String getDisplayName() {
547
            return fimpl.getDisplayName();
548
        }
549
        
550
        /**
551
         * Get the filter tooltip.
552
         * @return the filter tooltip
553
         */
554
        public String getTooltip() {
555
            return fimpl.getTooltip();
556
        }
557
558
        /**
559
         * Get the filter icon.
560
         * @return the filter icon
561
         */
562
        public Icon getIcon() {
563
            return fimpl.getIcon();
564
        }
565
566
        /**
567
         * Test if the filter is selected.
568
         * @return whether the filter is selected right now
569
         */
570
        public boolean isSelected() {
571
            return fimpl.isSelected();
572
        }
573
        
574
        /**
575
         * Set the filter as selected/unselected.
576
         * @param state whether to select the filter
577
         */
578
        public void setSelected(boolean state) {
579
            fimpl.setSelected(state);
580
        }
581
        
582
        /**
583
         * Get the filter preferences.
584
         * @return the preferences of this filter
585
         */
586
        public Preferences getPreferences() {
587
            return fimpl.getPreferences();
588
        }
589
        
590
        /**
591
         * Get the preference key.
592
         * @return key that is used to retrieve the filter value from preferences
593
         */
594
        public String getPrefKey() {
595
            return fimpl.getPrefKey();
596
        }
597
        
598
        /**
599
         * The filter group.
600
         */
601
        public static final class Group {
602
            
603
            private final List<DVFilter> items = new LinkedList<DVFilter>();
604
            
605
            /**
606
             * Create a new empty group.
607
             */
608
            public Group() {
609
            }
610
            
611
            void add(DVFilter filter) {
612
                items.add(filter);
613
            }
614
            
615
            /**
616
             * Get list of filters in this group.
617
             * @return list of filters
618
             */
619
            public List<DVFilter> getItems() {
620
                return items;
621
            }
622
        }
623
        
624
    }
625
    
626
}

Return to bug 235565