home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / DEBUGCLASS1.SCRIPT < prev    next >
Encoding:
Text File  |  2000-07-10  |  4.5 KB  |  145 lines

  1. !!include "Library\jdkUtilities.script"
  2. !!Script
  3. // Copyright ⌐ 1997-1998 - Modelworks Software
  4. // @Modified build 223 cm19980923 - removed runInWindow test
  5. // @Modified build 228 cm19981020 - replaced inline classpath computation with a function call
  6.  
  7. /**
  8. @Tool: debugClass1~displays a dialog to let enter a class to 
  9. debug using Sun's command line java debugger (jdb.exe). 
  10. @Image: Debug Class Dialog@debugClassJDKDialog.gif 
  11. @Image: Initial jdb window@debugApplicationJdbWindow.gif 
  12. @Note: This is the script that is used by the JDK/Debug Class menu. 
  13. @EndNote:
  14. @Tip: Make sure you do not name your JDK directory with a space (e.g., "JDK 1.1.4" or 
  15. use spaces in naming any of your own directories that may need to be included in a classpath. 
  16. This can cause a problem for some of Sun's tools. In particular, Sun's debugger (as of JDK 1.1.4) 
  17. does not work if you have a classpath with a space. 
  18. @EndTip:
  19. @Tip: Sun's command line debugger communicates with the debugee using TCP/IP. Because of this, 
  20. jdb may prompt you to connect to the internet during initilization if you use a dial-up connection 
  21. to the internet. However, jdb does need the connection to the internet, so you should be able 
  22. to proceed by just canceling the connect dialog. 
  23. @EndTip:
  24. @EndTool: 
  25. @Summary: debugClass1~runs Sun's command line java debugger
  26. */
  27.  
  28. var output = getOutput();
  29. var helpers = getMapFile("ApplicationHelpers");   
  30. var gOptions = getMapFile("JDKToolsStandardOptions");
  31.  
  32. function DoCommand()  
  33. {
  34.     output.clear();
  35.     
  36.     // Save all open files
  37.     saveAll();
  38.     
  39.     var runApplicationFile = helpers.lookup("jdk-debugger");
  40.     if (runApplicationFile == null)
  41.     {
  42.         var result = confirm("You need to run the JDK setup script\n"
  43.         + "before you can use this command.\n" +
  44.         "Do you want to run the setup script now?");
  45.         if (result)
  46.         {
  47.             run("Configuration\\JDK");
  48.         }
  49.         return;
  50.     }
  51.     
  52.     var javaUtilities = getScriptObject("\\Library\\javaUtilities");
  53.     var lastClassRun = javaUtilities.GetLastClassRun();
  54.     var applicationParameters = javaUtilities.GetApplicationParameters();
  55.     
  56.     var jdkOptions = getScriptObject("\\Library\\jdkOptions");
  57.     var message = "Enter the full class name of the class to run. ";
  58.     message += "Warning: your class will not run unless the class file exists in the current classpath ";
  59.     var result = chooseApplication(message, 
  60.         "", 
  61.         lastClassRun, "", 
  62.         "Using application parameters (Be sure to quote strings with spaces)", 
  63.         applicationParameters,
  64.         "Debug Java application class using " + runApplicationFile.name,
  65.         "Options...",
  66.         jdkOptions.ChooseDebugOptions);
  67.     
  68.     if (result)
  69.     {
  70.         var className = result.key;
  71.         applicationParameters = result.value;
  72.         JDKDebugClass(className, applicationParameters);
  73.         
  74.         // Update Data
  75.         javaUtilities.SetLastClassRun(className);
  76.         javaUtilities.SetApplicationParameters(applicationParameters);
  77.     }
  78.  
  79.  
  80. function JDKDebugClass(className, applicationParameters)
  81. {
  82.     var jdkDebugger = helpers.lookup("jdk-debugger"); 
  83.     
  84.     var useEnvironmentClasspath = gOptions.lookup("useEnvironmentClasspath", false);
  85.     var standardOptions = gOptions.lookup("jdk-debugger", "");
  86.     
  87.     if (jdkDebugger && jdkDebugger.exists)
  88.     {
  89.         output.writeLine("Starting debugger for " + className);
  90.         
  91.         // Quote all paths in case a path contains spaces
  92.         
  93.         // Add the path to the tool -- this must be first
  94.         var command = "\"" + jdkDebugger.path + "\" ";
  95.         
  96.         // Add options
  97.         if (standardOptions.length > 0)
  98.         {
  99.             command += standardOptions + " ";
  100.         }
  101.         
  102.         if (useEnvironmentClasspath)
  103.         {
  104.             var tool = newTool();
  105.             tool.setEnvironmentVariable("Classpath", getGlobal("EnvironmentClasspath"));
  106.         }
  107.         else
  108.         {
  109.             // Add the classpaths quoting the classpaths argument
  110.             command += GetClasspathArgument(""); // cm19981020
  111.         }
  112.         
  113.         // Add the class name of the file to be run
  114.         command += className;
  115.         
  116.         // Add application parameters to command line       
  117.         if (applicationParameters.length > 0)
  118.         {
  119.             command += " " + applicationParameters;
  120.         }
  121.         
  122.         if (gOptions.lookup("showCommandLine",false)==true)
  123.         {
  124.             output.writeLine("Command line: " + command);
  125.         }
  126.         
  127.         // Create a process in which to run the java class
  128.         var runTool = newTool();
  129.         runTool.runStandAlone(jdkDebugger.path, command);
  130.     }
  131.     else
  132.     {
  133.         var result = confirm("You need to run the JDK setup script\n"
  134.         + "before you can use this command.\n" +
  135.         "Do you want to run the setup script now?");
  136.         if (result)
  137.         {
  138.             run("Configuration\\JDK");
  139.         }
  140.     }
  141. }
  142.  
  143. !!/Script
  144.