home *** CD-ROM | disk | FTP | other *** search
- !!include "Library\jdkUtilities.script"
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 223 cm19980923 - removed runInWindow test
- // @Modified build 228 cm19981020 - replaced inline classpath computation with a function call
-
- /**
- @Tool: debugClass1~displays a dialog to let enter a class to
- debug using Sun's command line java debugger (jdb.exe).
- @Image: Debug Class Dialog@debugClassJDKDialog.gif
- @Image: Initial jdb window@debugApplicationJdbWindow.gif
- @Note: This is the script that is used by the JDK/Debug Class menu.
- @EndNote:
- @Tip: Make sure you do not name your JDK directory with a space (e.g., "JDK 1.1.4" or
- use spaces in naming any of your own directories that may need to be included in a classpath.
- This can cause a problem for some of Sun's tools. In particular, Sun's debugger (as of JDK 1.1.4)
- does not work if you have a classpath with a space.
- @EndTip:
- @Tip: Sun's command line debugger communicates with the debugee using TCP/IP. Because of this,
- jdb may prompt you to connect to the internet during initilization if you use a dial-up connection
- to the internet. However, jdb does need the connection to the internet, so you should be able
- to proceed by just canceling the connect dialog.
- @EndTip:
- @EndTool:
- @Summary: debugClass1~runs Sun's command line java debugger
- */
-
- var output = getOutput();
- var helpers = getMapFile("ApplicationHelpers");
- var gOptions = getMapFile("JDKToolsStandardOptions");
-
- function DoCommand()
- {
- output.clear();
-
- // Save all open files
- saveAll();
-
- var runApplicationFile = helpers.lookup("jdk-debugger");
- if (runApplicationFile == null)
- {
- var result = confirm("You need to run the JDK setup script\n"
- + "before you can use this command.\n" +
- "Do you want to run the setup script now?");
- if (result)
- {
- run("Configuration\\JDK");
- }
- return;
- }
-
- var javaUtilities = getScriptObject("\\Library\\javaUtilities");
- var lastClassRun = javaUtilities.GetLastClassRun();
- var applicationParameters = javaUtilities.GetApplicationParameters();
-
- var jdkOptions = getScriptObject("\\Library\\jdkOptions");
- var message = "Enter the full class name of the class to run. ";
- message += "Warning: your class will not run unless the class file exists in the current classpath ";
- var result = chooseApplication(message,
- "",
- lastClassRun, "",
- "Using application parameters (Be sure to quote strings with spaces)",
- applicationParameters,
- "Debug Java application class using " + runApplicationFile.name,
- "Options...",
- jdkOptions.ChooseDebugOptions);
-
- if (result)
- {
- var className = result.key;
- applicationParameters = result.value;
- JDKDebugClass(className, applicationParameters);
-
- // Update Data
- javaUtilities.SetLastClassRun(className);
- javaUtilities.SetApplicationParameters(applicationParameters);
- }
- }
-
-
- function JDKDebugClass(className, applicationParameters)
- {
- var jdkDebugger = helpers.lookup("jdk-debugger");
-
- var useEnvironmentClasspath = gOptions.lookup("useEnvironmentClasspath", false);
- var standardOptions = gOptions.lookup("jdk-debugger", "");
-
- if (jdkDebugger && jdkDebugger.exists)
- {
- output.writeLine("Starting debugger for " + className);
-
- // Quote all paths in case a path contains spaces
-
- // Add the path to the tool -- this must be first
- var command = "\"" + jdkDebugger.path + "\" ";
-
- // Add options
- if (standardOptions.length > 0)
- {
- command += standardOptions + " ";
- }
-
- if (useEnvironmentClasspath)
- {
- var tool = newTool();
- tool.setEnvironmentVariable("Classpath", getGlobal("EnvironmentClasspath"));
- }
- else
- {
- // Add the classpaths quoting the classpaths argument
- command += GetClasspathArgument(""); // cm19981020
- }
-
- // Add the class name of the file to be run
- command += className;
-
- // Add application parameters to command line
- if (applicationParameters.length > 0)
- {
- command += " " + applicationParameters;
- }
-
- if (gOptions.lookup("showCommandLine",false)==true)
- {
- output.writeLine("Command line: " + command);
- }
-
- // Create a process in which to run the java class
- var runTool = newTool();
- runTool.runStandAlone(jdkDebugger.path, command);
- }
- else
- {
- var result = confirm("You need to run the JDK setup script\n"
- + "before you can use this command.\n" +
- "Do you want to run the setup script now?");
- if (result)
- {
- run("Configuration\\JDK");
- }
- }
- }
-
- !!/Script
-