History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/tools/example/debug/gui/GUI.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/tools/example/debug/gui/GUI.java+256−0
@@ -0,0 +1,256 @@
1+/*
2+ * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.gui;
27+
28+import java.io.*;
29+import javax.swing.*;
30+import javax.swing.border.*;
31+import java.awt.*;
32+import java.awt.event.*;
33+
34+import com.sun.jdi.*;
35+import com.sun.tools.example.debug.bdi.*;
36+
37+public class GUI extends JPanel {
38+
39+ private static final long serialVersionUID = 3292463234530679091L;
40+ private CommandTool cmdTool;
41+ private ApplicationTool appTool;
42+ //###HACK##
43+ //### There is currently dirty code in Environment that
44+ //### accesses this directly.
45+ //private SourceTool srcTool;
46+ public static SourceTool srcTool;
47+
48+ private SourceTreeTool sourceTreeTool;
49+ private ClassTreeTool classTreeTool;
50+ private ThreadTreeTool threadTreeTool;
51+ private StackTraceTool stackTool;
52+ private MonitorTool monitorTool;
53+
54+ public static final String progname = "javadt";
55+ public static final String version = "1.0Beta"; //### FIX ME.
56+ public static final String windowBanner = "Java(tm) platform Debug Tool";
57+
58+ private Font fixedFont = new Font("monospaced", Font.PLAIN, 10);
59+
60+ private GUI(Environment env) {
61+ setLayout(new BorderLayout());
62+
63+ setBorder(new EmptyBorder(5, 5, 5, 5));
64+
65+ add(new JDBToolBar(env), BorderLayout.NORTH);
66+
67+ srcTool = new SourceTool(env);
68+ srcTool.setPreferredSize(new java.awt.Dimension(500, 300));
69+ srcTool.setTextFont(fixedFont);
70+
71+ stackTool = new StackTraceTool(env);
72+ stackTool.setPreferredSize(new java.awt.Dimension(500, 100));
73+
74+ monitorTool = new MonitorTool(env);
75+ monitorTool.setPreferredSize(new java.awt.Dimension(500, 50));
76+
77+ JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool,
78+ new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool));
79+
80+ sourceTreeTool = new SourceTreeTool(env);
81+ sourceTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
82+
83+ classTreeTool = new ClassTreeTool(env);
84+ classTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
85+
86+ threadTreeTool = new ThreadTreeTool(env);
87+ threadTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
88+
89+ JTabbedPane treePane = new JTabbedPane(SwingConstants.BOTTOM);
90+ treePane.addTab("Source", null, sourceTreeTool);
91+ treePane.addTab("Classes", null, classTreeTool);
92+ treePane.addTab("Threads", null, threadTreeTool);
93+
94+ JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right);
95+
96+ cmdTool = new CommandTool(env);
97+ cmdTool.setPreferredSize(new java.awt.Dimension(700, 150));
98+
99+ appTool = new ApplicationTool(env);
100+ appTool.setPreferredSize(new java.awt.Dimension(700, 200));
101+
102+ JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool);
103+ // centerBottom.setPreferredSize(new java.awt.Dimension(700, 350));
104+
105+ JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom);
106+
107+ add(center, BorderLayout.CENTER);
108+
109+
110+ }
111+
112+ private static void usage() {
113+ String separator = File.pathSeparator;
114+ System.out.println("Usage: " + progname + " <options> <class> <arguments>");
115+ System.out.println();
116+ System.out.println("where options include:");
117+ System.out.println(" -help print out this message and exit");
118+ System.out.println(" -sourcepath <directories separated by \"" +
119+ separator + "\">");
120+ System.out.println(" list directories in which to look for source files");
121+ System.out.println(" -remote <hostname>:<port-number>");
122+ System.out.println(" host machine and port number of interpreter to attach to");
123+ System.out.println(" -dbgtrace [flags] print info for debugging " + progname);
124+ System.out.println();
125+ System.out.println("options forwarded to debuggee process:");
126+ System.out.println(" -v -verbose[:class|gc|jni]");
127+ System.out.println(" turn on verbose mode");
128+ System.out.println(" -D<name>=<value> set a system property");
129+ System.out.println(" -classpath <directories separated by \"" +
130+ separator + "\">");
131+ System.out.println(" list directories in which to look for classes");
132+ System.out.println(" -X<option> non-standard debuggee VM option");
133+ System.out.println();
134+ System.out.println("<class> is the name of the class to begin debugging");
135+ System.out.println("<arguments> are the arguments passed to the main() method of <class>");
136+ System.out.println();
137+ System.out.println("For command help type 'help' at " + progname + " prompt");
138+ }
139+
140+ public static void main(String argv[]) {
141+ String clsName = "";
142+ String progArgs = "";
143+ String javaArgs = "";
144+ final Environment env = new Environment();
145+
146+ JPanel mainPanel = new GUI(env);
147+
148+ ContextManager context = env.getContextManager();
149+ ExecutionManager runtime = env.getExecutionManager();
150+
151+ for (int i = 0; i < argv.length; i++) {
152+ String token = argv[i];
153+ if (token.equals("-dbgtrace")) {
154+ if ((i == argv.length - 1) ||
155+ ! Character.isDigit(argv[i+1].charAt(0))) {
156+ runtime.setTraceMode(VirtualMachine.TRACE_ALL);
157+ } else {
158+ String flagStr = argv[++i];
159+ runtime.setTraceMode(Integer.decode(flagStr).intValue());
160+ }
161+ } else if (token.equals("-X")) {
162+ System.out.println(
163+ "Use 'java -X' to see the available non-standard options");
164+ System.out.println();
165+ usage();
166+ System.exit(1);
167+ } else if (
168+ // Standard VM options passed on
169+ token.equals("-v") || token.startsWith("-v:") || // -v[:...]
170+ token.startsWith("-verbose") || // -verbose[:...]
171+ token.startsWith("-D") ||
172+ // NonStandard options passed on
173+ token.startsWith("-X") ||
174+ // Old-style options
175+ // (These should remain in place as long as the standard VM accepts them)
176+ token.equals("-noasyncgc") || token.equals("-prof") ||
177+ token.equals("-verify") || token.equals("-noverify") ||
178+ token.equals("-verifyremote") ||
179+ token.equals("-verbosegc") ||
180+ token.startsWith("-ms") || token.startsWith("-mx") ||
181+ token.startsWith("-ss") || token.startsWith("-oss") ) {
182+ javaArgs += token + " ";
183+ } else if (token.equals("-sourcepath")) {
184+ if (i == (argv.length - 1)) {
185+ System.out.println("No sourcepath specified.");
186+ usage();
187+ System.exit(1);
188+ }
189+ env.getSourceManager().setSourcePath(new SearchPath(argv[++i]));
190+ } else if (token.equals("-classpath")) {
191+ if (i == (argv.length - 1)) {
192+ System.out.println("No classpath specified.");
193+ usage();
194+ System.exit(1);
195+ }
196+ env.getClassManager().setClassPath(new SearchPath(argv[++i]));
197+ } else if (token.equals("-remote")) {
198+ if (i == (argv.length - 1)) {
199+ System.out.println("No remote specified.");
200+ usage();
201+ System.exit(1);
202+ }
203+ env.getContextManager().setRemotePort(argv[++i]);
204+ } else if (token.equals("-help")) {
205+ usage();
206+ System.exit(0);
207+ } else if (token.equals("-version")) {
208+ System.out.println(progname + " version " + version);
209+ System.exit(0);
210+ } else if (token.startsWith("-")) {
211+ System.out.println("invalid option: " + token);
212+ usage();
213+ System.exit(1);
214+ } else {
215+ // Everything from here is part of the command line
216+ clsName = token;
217+ for (i++; i < argv.length; i++) {
218+ progArgs += argv[i] + " ";
219+ }
220+ break;
221+ }
222+ }
223+
224+ context.setMainClassName(clsName);
225+ context.setProgramArguments(progArgs);
226+ context.setVmArguments(javaArgs);
227+
228+ // Force Cross Platform L&F
229+ try {
230+ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
231+ // If you want the System L&F instead, comment out the above line and
232+ // uncomment the following:
233+ // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
234+ } catch (Exception exc) {
235+ System.err.println("Error loading L&F: " + exc);
236+ }
237+
238+ JFrame frame = new JFrame();
239+ frame.setBackground(Color.lightGray);
240+ frame.setTitle(windowBanner);
241+ frame.setJMenuBar(new JDBMenuBar(env));
242+ frame.setContentPane(mainPanel);
243+
244+ frame.addWindowListener(new WindowAdapter() {
245+ @Override
246+ public void windowClosing(WindowEvent e) {
247+ env.terminate();
248+ }
249+ });
250+
251+ frame.pack();
252+ frame.setVisible(true);
253+
254+ }
255+
256+}