001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.debugger.delegatingview;
043:
044: import java.beans.PropertyChangeListener;
045: import java.beans.PropertyChangeEvent;
046: import javax.swing.*;
047:
048: import org.netbeans.modules.debugger.*;
049: import org.netbeans.modules.debugger.GUIManager.*;
050:
051: import org.openide.TopManager;
052: import org.netbeans.modules.debugger.support.DebuggerModule;
053: import org.netbeans.modules.debugger.support.DelegatingView2;
054: import org.netbeans.modules.debugger.support.View2;
055: import org.netbeans.modules.debugger.support.View2Support;
056: import org.netbeans.modules.debugger.support.nodes.DebuggerNode;
057:
058: /**
059: * Module installation class for HtmlModule
060: *
061: * @author Jan Jancura
062: */
063: public class DVModule extends org.openide.modules.ModuleInstall {
064:
065: DelegatingView2 breakpointsView;
066: DelegatingView2 threadsView;
067: DelegatingView2 callStackView;
068: DelegatingView2 sessionsView;
069: DelegatingView2 watchesView;
070: DelegatingView2 classesView;
071: View2Support variablesListView;
072:
073: // ModuleInstall implementation ............................................
074:
075: /** Module installed again. */
076: public void installed() {
077: restored();
078: }
079:
080: /** Module installed again. */
081: public void restored() {
082: // create new "delegating" views
083: breakpointsView = new DelegatingView2(
084: new View2[] {
085: DebuggerModule.BREAKPOINTS_VIEW,//JPDA debugger
086: new View2Support(
087: //tools debugger
088: DebuggerNode
089: .getLocalizedString("CTL_Breakpoints_view"), // NOI18N
090: "/org/netbeans/modules/debugger/resources/breakpoints", // NOI18N
091: "org.netbeans.modules.debugger.delegatingview.BreakpointsView", // NOI18N
092: false, // has not splitter
093: true, // is in toolbar
094: true, // visible
095: false // separated
096: ) });
097: threadsView = new DelegatingView2(
098: new View2[] {
099: DebuggerModule.THREADS_VIEW,//JPDA debugger
100: new View2Support(
101: //tools debugger
102: DebuggerNode
103: .getLocalizedString("CTL_Threads_view"), // NOI18N
104: "/org/netbeans/core/resources/threads", // NOI18N
105: "org.netbeans.modules.debugger.delegatingview.ThreadsView", // NOI18N
106: false, // has not splitter
107: true, // is in toolbar
108: false, // visible
109: false // separated
110: ) });
111: callStackView = new DelegatingView2(
112: new View2[] {
113: DebuggerModule.CALL_STACK_VIEW,//JPDA debugger
114: new View2Support(
115: //tools debugger
116: DebuggerNode
117: .getLocalizedString("CTL_Call_stack_view"), // NOI18N
118: "/org/netbeans/core/resources/callstack", // NOI18N
119: "org.netbeans.modules.debugger.delegatingview.CallStackView", // NOI18N
120: false, // has not splitter
121: true, // is in toolbar
122: true, // visible
123: false // separated
124: ) });
125: final DelegatingView2 sessionsView = new DelegatingView2(
126: new View2[] {
127: DebuggerModule.SESSIONS_VIEW,//JPDA debugger
128: new View2Support(
129: //tools debugger
130: DebuggerNode
131: .getLocalizedString("CTL_Sessions_view"), // NOI18N
132: "/org/netbeans/modules/debugger/multisession/resources/sessions", // NOI18N
133: "org.netbeans.modules.debugger.delegatingview.SessionsView", // NOI18N
134: false, // has not splitter
135: true, // is in toolbar
136: false, // visible
137: false // separated
138: ) });
139: watchesView = new DelegatingView2(
140: new View2[] {
141: DebuggerModule.WATCHES_VIEW,//JPDA debugger
142: new View2Support(
143: //tools debugger
144: DebuggerNode
145: .getLocalizedString("CTL_Watches_view"), // NOI18N
146: "/org/netbeans/core/resources/watches", // NOI18N
147: "org.netbeans.modules.debugger.delegatingview.WatchesView", // NOI18N
148: false, // has not splitter
149: true, // is in toolbar
150: true, // visible
151: false // separated
152: ) });
153: classesView = new DelegatingView2(new View2[] {
154: DebuggerModule.CLASSES_VIEW, //JPDA debugger
155: null //tools debugger
156: });
157: variablesListView = new View2Support(
158: // visibility test
159: DebuggerModule.VARIABLES_VIEW.getDisplayName(), // NOI18N
160: DebuggerModule.VARIABLES_VIEW.getIconBase(),
161: "org.netbeans.modules.debugger.support.nodes.VariablesView", // NOI18N
162: DebuggerModule.VARIABLES_VIEW.hasFixedSize(), // has not splitter
163: DebuggerModule.VARIABLES_VIEW.canBeHidden(), // is in toolbar
164: true, // visible
165: DebuggerModule.VARIABLES_VIEW.isSeparated() // separated
166: );
167:
168: // replace original views
169: View[] vs = GUIManager.getDefault().getViews();
170: int i, k = vs.length;
171: View[] nvs = new View[k];
172: for (i = 0; i < k; i++)
173: if (vs[i] == DebuggerModule.WATCHES_VIEW) {
174: nvs[i] = watchesView;
175: } else if (vs[i] == DebuggerModule.SESSIONS_VIEW) {
176: nvs[i] = sessionsView;
177: } else if (vs[i] == DebuggerModule.CALL_STACK_VIEW) {
178: nvs[i] = callStackView;
179: } else if (vs[i] == DebuggerModule.THREADS_VIEW) {
180: nvs[i] = threadsView;
181: } else if (vs[i] == DebuggerModule.BREAKPOINTS_VIEW) {
182: nvs[i] = breakpointsView;
183: } else if (vs[i] == DebuggerModule.CLASSES_VIEW) {
184: nvs[i] = classesView;
185: } else if (vs[i] == DebuggerModule.VARIABLES_VIEW) {
186: nvs[i] = variablesListView;
187: } else
188: nvs[i] = vs[i];
189: GUIManager.getDefault().setViews(nvs);
190:
191: // add listener
192: try {
193: final CoreDebugger cd = (CoreDebugger) TopManager
194: .getDefault().getDebugger();
195: cd.addPropertyChangeListener(new PropertyChangeListener() {
196: public void propertyChange(PropertyChangeEvent e) {
197: if (e.getPropertyName() == null)
198: return;
199: if (!e.getPropertyName().equals(
200: CoreDebugger.PROP_CURRENT_DEBUGGER))
201: return;
202: AbstractDebugger d = cd.getCurrentDebugger();
203: if (d == null)
204: return;
205: if (d.getClass().getName().indexOf("JPDADebugger") >= 0) {
206: // switch to debugger1 views (JPDA debugger)
207: SwingUtilities.invokeLater(new Runnable() {
208: public void run() {
209: breakpointsView.setCurrentView(0);
210: classesView.setCurrentView(0);
211: sessionsView.setCurrentView(0);
212: threadsView.setCurrentView(0);
213: callStackView.setCurrentView(0);
214: watchesView.setCurrentView(0);
215: watchesView.refreshViews();
216: }
217: });
218: } else if (d.getClass().getName().indexOf(
219: "ToolsDebugger") >= 0) {
220: // switch to debugger2 views (Tools debugger)
221: SwingUtilities.invokeLater(new Runnable() {
222: public void run() {
223: breakpointsView.setCurrentView(1);
224: classesView.setCurrentView(1);
225: sessionsView.setCurrentView(1);
226: threadsView.setCurrentView(1);
227: callStackView.setCurrentView(1);
228: watchesView.setCurrentView(1);
229: watchesView.refreshViews();
230: }
231: });
232: }
233: }
234: });
235: } catch (org.openide.debugger.DebuggerNotFoundException ex) {
236: ex.printStackTrace();
237: }
238: }
239: }
|