KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > delegatingview > DVModule


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.debugger.delegatingview;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeEvent JavaDoc;
24 import javax.swing.*;
25
26
27 import org.netbeans.modules.debugger.*;
28 import org.netbeans.modules.debugger.GUIManager.*;
29
30 import org.openide.TopManager;
31 import org.netbeans.modules.debugger.support.DebuggerModule;
32 import org.netbeans.modules.debugger.support.DelegatingView2;
33 import org.netbeans.modules.debugger.support.View2;
34 import org.netbeans.modules.debugger.support.View2Support;
35 import org.netbeans.modules.debugger.support.nodes.DebuggerNode;
36
37
38 /**
39 * Module installation class for HtmlModule
40 *
41 * @author Jan Jancura
42 */

43 public class DVModule extends org.openide.modules.ModuleInstall {
44
45     DelegatingView2 breakpointsView;
46     DelegatingView2 threadsView;
47     DelegatingView2 callStackView;
48     DelegatingView2 sessionsView;
49     DelegatingView2 watchesView;
50     DelegatingView2 classesView;
51     View2Support variablesListView;
52     
53     // ModuleInstall implementation ............................................
54

55     /** Module installed again. */
56     public void installed () {
57         restored ();
58     }
59     
60     /** Module installed again. */
61     public void restored () {
62         // create new "delegating" views
63
breakpointsView =
64             new DelegatingView2 (new View2 [] {
65                 DebuggerModule.BREAKPOINTS_VIEW,//JPDA debugger
66
new View2Support ( //tools debugger
67
DebuggerNode.getLocalizedString ("CTL_Breakpoints_view"), // NOI18N
68
"/org/netbeans/modules/debugger/resources/breakpoints", // NOI18N
69
"org.netbeans.modules.debugger.delegatingview.BreakpointsView", // NOI18N
70
false, // has not splitter
71
true, // is in toolbar
72
true, // visible
73
false // separated
74
)
75             });
76         threadsView =
77             new DelegatingView2 (new View2 [] {
78                 DebuggerModule.THREADS_VIEW,//JPDA debugger
79
new View2Support ( //tools debugger
80
DebuggerNode.getLocalizedString ("CTL_Threads_view"), // NOI18N
81
"/org/netbeans/core/resources/threads", // NOI18N
82
"org.netbeans.modules.debugger.delegatingview.ThreadsView", // NOI18N
83
false, // has not splitter
84
true, // is in toolbar
85
false, // visible
86
false // separated
87
)
88             });
89         callStackView =
90             new DelegatingView2 (new View2 [] {
91                 DebuggerModule.CALL_STACK_VIEW,//JPDA debugger
92
new View2Support ( //tools debugger
93
DebuggerNode.getLocalizedString ("CTL_Call_stack_view"), // NOI18N
94
"/org/netbeans/core/resources/callstack", // NOI18N
95
"org.netbeans.modules.debugger.delegatingview.CallStackView", // NOI18N
96
false, // has not splitter
97
true, // is in toolbar
98
true, // visible
99
false // separated
100
)
101             });
102         final DelegatingView2 sessionsView =
103             new DelegatingView2 (new View2 [] {
104                 DebuggerModule.SESSIONS_VIEW,//JPDA debugger
105
new View2Support ( //tools debugger
106
DebuggerNode.getLocalizedString ("CTL_Sessions_view"), // NOI18N
107
"/org/netbeans/modules/debugger/multisession/resources/sessions", // NOI18N
108
"org.netbeans.modules.debugger.delegatingview.SessionsView", // NOI18N
109
false, // has not splitter
110
true, // is in toolbar
111
false, // visible
112
false // separated
113
)
114             });
115         watchesView =
116             new DelegatingView2 (new View2 [] {
117                 DebuggerModule.WATCHES_VIEW,//JPDA debugger
118
new View2Support ( //tools debugger
119
DebuggerNode.getLocalizedString ("CTL_Watches_view"), // NOI18N
120
"/org/netbeans/core/resources/watches", // NOI18N
121
"org.netbeans.modules.debugger.delegatingview.WatchesView", // NOI18N
122
false, // has not splitter
123
true, // is in toolbar
124
true, // visible
125
false // separated
126
)
127             });
128         classesView =
129             new DelegatingView2 (new View2 [] {
130                 DebuggerModule.CLASSES_VIEW, //JPDA debugger
131
null //tools debugger
132
});
133         variablesListView =
134             new View2Support ( // visibility test
135
DebuggerModule.VARIABLES_VIEW.getDisplayName (), // NOI18N
136
DebuggerModule.VARIABLES_VIEW.getIconBase (),
137                 "org.netbeans.modules.debugger.support.nodes.VariablesView", // NOI18N
138
DebuggerModule.VARIABLES_VIEW.hasFixedSize (), // has not splitter
139
DebuggerModule.VARIABLES_VIEW.canBeHidden (), // is in toolbar
140
true, // visible
141
DebuggerModule.VARIABLES_VIEW.isSeparated () // separated
142
);
143             
144         // replace original views
145
View[] vs = GUIManager.getDefault ().getViews ();
146         int i, k = vs.length;
147         View[] nvs = new View [k];
148         for (i = 0; i < k; i++)
149             if (vs [i] == DebuggerModule.WATCHES_VIEW) {
150                 nvs [i] = watchesView;
151             } else
152             if (vs [i] == DebuggerModule.SESSIONS_VIEW) {
153                 nvs [i] = sessionsView;
154             } else
155             if (vs [i] == DebuggerModule.CALL_STACK_VIEW) {
156                 nvs [i] = callStackView;
157             } else
158             if (vs [i] == DebuggerModule.THREADS_VIEW) {
159                 nvs [i] = threadsView;
160             } else
161             if (vs [i] == DebuggerModule.BREAKPOINTS_VIEW) {
162                 nvs [i] = breakpointsView;
163             } else
164             if (vs [i] == DebuggerModule.CLASSES_VIEW) {
165                 nvs [i] = classesView;
166             } else
167             if (vs [i] == DebuggerModule.VARIABLES_VIEW) {
168                 nvs [i] = variablesListView;
169             } else
170                 nvs [i] = vs [i];
171         GUIManager.getDefault ().setViews (nvs);
172
173         // add listener
174
try {
175             final CoreDebugger cd = (CoreDebugger) TopManager.getDefault().getDebugger();
176             cd.addPropertyChangeListener (new PropertyChangeListener JavaDoc () {
177                 public void propertyChange (PropertyChangeEvent JavaDoc e) {
178                     if (e.getPropertyName () == null) return;
179                     if (!e.getPropertyName ().equals (CoreDebugger.PROP_CURRENT_DEBUGGER)) return;
180                     AbstractDebugger d = cd.getCurrentDebugger ();
181                     if (d == null) return;
182                     if (d.getClass ().getName ().indexOf ("JPDADebugger") >= 0) {
183                         // switch to debugger1 views (JPDA debugger)
184
SwingUtilities.invokeLater (new Runnable JavaDoc () {
185                             public void run () {
186                                 breakpointsView.setCurrentView (0);
187                                 classesView.setCurrentView (0);
188                                 sessionsView.setCurrentView (0);
189                                 threadsView.setCurrentView (0);
190                                 callStackView.setCurrentView (0);
191                                 watchesView.setCurrentView (0);
192                                 watchesView.refreshViews ();
193                             }
194                         });
195                     } else
196                     if (d.getClass ().getName ().indexOf ("ToolsDebugger") >= 0) {
197                         // switch to debugger2 views (Tools debugger)
198
SwingUtilities.invokeLater (new Runnable JavaDoc () {
199                             public void run () {
200                                 breakpointsView.setCurrentView (1);
201                                 classesView.setCurrentView (1);
202                                 sessionsView.setCurrentView (1);
203                                 threadsView.setCurrentView (1);
204                                 callStackView.setCurrentView (1);
205                                 watchesView.setCurrentView (1);
206                                 watchesView.refreshViews ();
207                             }
208                         });
209                     }
210                 }
211             });
212         } catch (org.openide.debugger.DebuggerNotFoundException ex) {
213             ex.printStackTrace();
214         }
215     }
216 }
217
218
Popular Tags