2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.debugger.delegatingview;
44
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeEvent;
49
import org.netbeans.modules.debugger.*;
50
import org.netbeans.modules.debugger.GUIManager.*;
52
import org.openide.TopManager;
53
import org.netbeans.modules.debugger.support.DebuggerModule;
54
import org.netbeans.modules.debugger.support.DelegatingView2;
55
import org.netbeans.modules.debugger.support.View2;
56
import org.netbeans.modules.debugger.support.View2Support;
57
import org.netbeans.modules.debugger.support.nodes.DebuggerNode;
61
* Module installation class for HtmlModule
65
public class DVModule extends org.openide.modules.ModuleInstall {
67
DelegatingView2 breakpointsView;
68
DelegatingView2 threadsView;
69
DelegatingView2 callStackView;
70
DelegatingView2 sessionsView;
71
DelegatingView2 watchesView;
72
DelegatingView2 classesView;
73
View2Support variablesListView;
75
// ModuleInstall implementation ............................................
77
/** Module installed again. */
78
public void installed () {
82
/** Module installed again. */
83
public void restored () {
84
// create new "delegating" views
86
new DelegatingView2 (new View2 [] {
87
DebuggerModule.BREAKPOINTS_VIEW,//JPDA debugger
88
new View2Support ( //tools debugger
89
DebuggerNode.getLocalizedString ("CTL_Breakpoints_view"), // NOI18N
90
"/org/netbeans/modules/debugger/resources/breakpoints", // NOI18N
91
"org.netbeans.modules.debugger.delegatingview.BreakpointsView", // NOI18N
92
false, // has not splitter
93
true, // is in toolbar
99
new DelegatingView2 (new View2 [] {
100
DebuggerModule.THREADS_VIEW,//JPDA debugger
101
new View2Support ( //tools debugger
102
DebuggerNode.getLocalizedString ("CTL_Threads_view"), // NOI18N
103
"/org/netbeans/core/resources/threads", // NOI18N
104
"org.netbeans.modules.debugger.delegatingview.ThreadsView", // NOI18N
105
false, // has not splitter
106
true, // is in toolbar
112
new DelegatingView2 (new View2 [] {
113
DebuggerModule.CALL_STACK_VIEW,//JPDA debugger
114
new View2Support ( //tools debugger
115
DebuggerNode.getLocalizedString ("CTL_Call_stack_view"), // NOI18N
116
"/org/netbeans/core/resources/callstack", // NOI18N
117
"org.netbeans.modules.debugger.delegatingview.CallStackView", // NOI18N
118
false, // has not splitter
119
true, // is in toolbar
124
final DelegatingView2 sessionsView =
125
new DelegatingView2 (new View2 [] {
126
DebuggerModule.SESSIONS_VIEW,//JPDA debugger
127
new View2Support ( //tools debugger
128
DebuggerNode.getLocalizedString ("CTL_Sessions_view"), // NOI18N
129
"/org/netbeans/modules/debugger/multisession/resources/sessions", // NOI18N
130
"org.netbeans.modules.debugger.delegatingview.SessionsView", // NOI18N
131
false, // has not splitter
132
true, // is in toolbar
138
new DelegatingView2 (new View2 [] {
139
DebuggerModule.WATCHES_VIEW,//JPDA debugger
140
new View2Support ( //tools debugger
141
DebuggerNode.getLocalizedString ("CTL_Watches_view"), // NOI18N
142
"/org/netbeans/core/resources/watches", // NOI18N
143
"org.netbeans.modules.debugger.delegatingview.WatchesView", // NOI18N
144
false, // has not splitter
145
true, // is in toolbar
151
new DelegatingView2 (new View2 [] {
152
DebuggerModule.CLASSES_VIEW, //JPDA debugger
153
null //tools debugger
156
new View2Support ( // visibility test
157
DebuggerModule.VARIABLES_VIEW.getDisplayName (), // NOI18N
158
DebuggerModule.VARIABLES_VIEW.getIconBase (),
159
"org.netbeans.modules.debugger.support.nodes.VariablesView", // NOI18N
160
DebuggerModule.VARIABLES_VIEW.hasFixedSize (), // has not splitter
161
DebuggerModule.VARIABLES_VIEW.canBeHidden (), // is in toolbar
163
DebuggerModule.VARIABLES_VIEW.isSeparated () // separated
166
// replace original views
167
View[] vs = GUIManager.getDefault ().getViews ();
168
int i, k = vs.length;
169
View[] nvs = new View [k];
170
for (i = 0; i < k; i++)
171
if (vs [i] == DebuggerModule.WATCHES_VIEW) {
172
nvs [i] = watchesView;
174
if (vs [i] == DebuggerModule.SESSIONS_VIEW) {
175
nvs [i] = sessionsView;
177
if (vs [i] == DebuggerModule.CALL_STACK_VIEW) {
178
nvs [i] = callStackView;
180
if (vs [i] == DebuggerModule.THREADS_VIEW) {
181
nvs [i] = threadsView;
183
if (vs [i] == DebuggerModule.BREAKPOINTS_VIEW) {
184
nvs [i] = breakpointsView;
186
if (vs [i] == DebuggerModule.CLASSES_VIEW) {
187
nvs [i] = classesView;
189
if (vs [i] == DebuggerModule.VARIABLES_VIEW) {
190
nvs [i] = variablesListView;
193
GUIManager.getDefault ().setViews (nvs);
197
final CoreDebugger cd = (CoreDebugger) TopManager.getDefault().getDebugger();
198
cd.addPropertyChangeListener (new PropertyChangeListener () {
199
public void propertyChange (PropertyChangeEvent e) {
200
if (e.getPropertyName () == null) return;
201
if (!e.getPropertyName ().equals (CoreDebugger.PROP_CURRENT_DEBUGGER)) return;
202
AbstractDebugger d = cd.getCurrentDebugger ();
203
if (d == null) return;
204
if (d.getClass ().getName ().indexOf ("JPDADebugger") >= 0) {
205
// switch to debugger1 views (JPDA debugger)
206
SwingUtilities.invokeLater (new Runnable () {
208
breakpointsView.setCurrentView (0);
209
classesView.setCurrentView (0);
210
sessionsView.setCurrentView (0);
211
threadsView.setCurrentView (0);
212
callStackView.setCurrentView (0);
213
watchesView.setCurrentView (0);
214
watchesView.refreshViews ();
218
if (d.getClass ().getName ().indexOf ("ToolsDebugger") >= 0) {
219
// switch to debugger2 views (Tools debugger)
220
SwingUtilities.invokeLater (new Runnable () {
222
breakpointsView.setCurrentView (1);
223
classesView.setCurrentView (1);
224
sessionsView.setCurrentView (1);
225
threadsView.setCurrentView (1);
226
callStackView.setCurrentView (1);
227
watchesView.setCurrentView (1);
228
watchesView.refreshViews ();
234
} catch (org.openide.debugger.DebuggerNotFoundException ex) {
235
ex.printStackTrace();