~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to debuggercore/api/examples/delegatingview/org/netbeans/modules/debugger/delegatingview/DVModule.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
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]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
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.
 
29
 *
 
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.
 
40
 */
 
41
 
 
42
package org.netbeans.modules.debugger.delegatingview;
 
43
 
 
44
import java.beans.PropertyChangeListener;
 
45
import java.beans.PropertyChangeEvent;
 
46
import javax.swing.*;
 
47
 
 
48
 
 
49
import org.netbeans.modules.debugger.*;
 
50
import org.netbeans.modules.debugger.GUIManager.*;
 
51
 
 
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;
 
58
 
 
59
 
 
60
/**
 
61
* Module installation class for HtmlModule
 
62
*
 
63
* @author Jan Jancura
 
64
*/
 
65
public class DVModule extends org.openide.modules.ModuleInstall {
 
66
 
 
67
    DelegatingView2 breakpointsView;
 
68
    DelegatingView2 threadsView;
 
69
    DelegatingView2 callStackView;
 
70
    DelegatingView2 sessionsView;
 
71
    DelegatingView2 watchesView; 
 
72
    DelegatingView2 classesView; 
 
73
    View2Support variablesListView;
 
74
    
 
75
    // ModuleInstall implementation ............................................
 
76
    
 
77
    /** Module installed again. */
 
78
    public void installed () {
 
79
        restored ();
 
80
    }
 
81
    
 
82
    /** Module installed again. */
 
83
    public void restored () {
 
84
        // create new "delegating" views
 
85
        breakpointsView = 
 
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
 
94
                    true,  // visible
 
95
                    false  // separated
 
96
                )
 
97
            });
 
98
        threadsView = 
 
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
 
107
                    false,  // visible
 
108
                    false  // separated
 
109
                )
 
110
            });
 
111
        callStackView = 
 
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
 
120
                    true,  // visible
 
121
                    false  // separated
 
122
                )
 
123
            });
 
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
 
133
                    false,  // visible
 
134
                    false  // separated
 
135
                )
 
136
            });
 
137
        watchesView = 
 
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
 
146
                    true,  // visible
 
147
                    false  // separated
 
148
                )
 
149
            });
 
150
        classesView = 
 
151
            new DelegatingView2 (new View2 [] {
 
152
                DebuggerModule.CLASSES_VIEW,  //JPDA debugger
 
153
                null                          //tools debugger
 
154
            });
 
155
        variablesListView = 
 
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
 
162
                true,  // visible
 
163
                DebuggerModule.VARIABLES_VIEW.isSeparated ()  // separated
 
164
            );
 
165
            
 
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;
 
173
            } else
 
174
            if (vs [i] == DebuggerModule.SESSIONS_VIEW) {
 
175
                nvs [i] = sessionsView;
 
176
            } else
 
177
            if (vs [i] == DebuggerModule.CALL_STACK_VIEW) {
 
178
                nvs [i] = callStackView;
 
179
            } else
 
180
            if (vs [i] == DebuggerModule.THREADS_VIEW) {
 
181
                nvs [i] = threadsView;
 
182
            } else
 
183
            if (vs [i] == DebuggerModule.BREAKPOINTS_VIEW) {
 
184
                nvs [i] = breakpointsView;
 
185
            } else
 
186
            if (vs [i] == DebuggerModule.CLASSES_VIEW) {
 
187
                nvs [i] = classesView;
 
188
            } else
 
189
            if (vs [i] == DebuggerModule.VARIABLES_VIEW) {
 
190
                nvs [i] = variablesListView;
 
191
            } else
 
192
                nvs [i] = vs [i];
 
193
        GUIManager.getDefault ().setViews (nvs);
 
194
 
 
195
        // add listener 
 
196
        try {
 
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 () {
 
207
                            public void run () {
 
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 ();
 
215
                            }
 
216
                        });
 
217
                    } else
 
218
                    if (d.getClass ().getName ().indexOf ("ToolsDebugger") >= 0) {                        
 
219
                        // switch to debugger2 views (Tools debugger)
 
220
                        SwingUtilities.invokeLater (new Runnable () {
 
221
                            public void run () {
 
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 ();
 
229
                            }
 
230
                        });
 
231
                    }
 
232
                }
 
233
            });
 
234
        } catch (org.openide.debugger.DebuggerNotFoundException ex) {
 
235
            ex.printStackTrace();
 
236
        }
 
237
    }
 
238
}
 
239