home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / JAVADOC1.SCRIPT < prev    next >
Encoding:
Text File  |  1999-04-16  |  3.9 KB  |  181 lines

  1. !!Script
  2.  
  3. /**   
  4. @Tool: javadoc~creates HTML documents from 
  5. Java source. 
  6. @Note: This is the script that is used by the JDK/Run Javadoc menu. 
  7. @EndNote:
  8. @EndTool: 
  9. @Summary: javadoc~creates HTML documents 
  10. */
  11.  
  12. var gOutput = getOutput();
  13. var gHelpers = getMapFile("ApplicationHelpers");
  14. var gOptions = getMapFile("JDKToolsStandardOptions");
  15.  
  16. function DoCommand()
  17.     var path = "";
  18.     var directory = "";
  19.     
  20.     var project = getCurrentProject();
  21.     if (project)
  22.     {
  23.         var packageList = project.getPackageList();
  24.         if (packageList)
  25.         {
  26.             var position = packageList.getHeadPosition();
  27.             while (position && position.valid)
  28.             {
  29.                 var p = packageList.getNext(position);
  30.                 path += p.name;
  31.                 if (position && position.valid)
  32.                 {
  33.                     path += " ";
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     
  39.     // If the current document is a Java file then use that file
  40.     if (path == "")
  41.     {
  42.         var editor = getActiveEditor();
  43.         if (editor)
  44.         {
  45.             var fileType = editor.getFile().fileType.toLowerCase();
  46.             if (fileType == "java")
  47.             {
  48.                 path = editor.path;
  49.                 directory = editor.getFile().directory;
  50.             }
  51.         }
  52.     }
  53.     
  54.     // Else ask the user to locate a Java file
  55.     if (path == "")
  56.     {
  57.         var file = chooseFile("Choose a Java file for Javadoc", "Java files", "*.java");
  58.         if (file && file.exists)
  59.         {
  60.             path = file.path;
  61.             directory = file.directory;
  62.         }
  63.     }
  64.     
  65.     if (path.length > 0 && gHelpers)
  66.     {
  67.         var jdkDirectory = gHelpers.lookup("jdk-bin_directory");
  68.         var javadoc = jdkDirectory.path + "\\javadoc.exe";
  69.         
  70.         // Add the path to the javadoc.exe -- this must be first
  71.         var command = "\"" + javadoc + "\" ";
  72.         
  73.         var jdkSource = ";" + GetJDKSourcePath();
  74.         
  75.         command += "-sourcepath \"." + GetBuildPackageSourcePaths() + 
  76.             GetCustomSourcePaths() + jdkSource + "\"";
  77.         
  78.         // Add options
  79.         command += " -private ";
  80.         
  81.         gOutput.clear();
  82.         if (project)
  83.         {
  84.             command += path; // Contains package name[s]
  85.         }
  86.         else
  87.         {
  88.             command += "\"" + path + "\"";
  89.         }
  90.         
  91.         File.setDirectory(directory);
  92.         if (gOptions.lookup("showCommandLine",false)==true)
  93.         {
  94.             gOutput.writeLine("The current directory is: " + File.getDirectory().path);
  95.         }
  96.         
  97.         // Create a process to run the appletviewer
  98.         var javadocTool = newTool();
  99.         
  100.         if (gOptions.lookup("showCommandLine",false)==true)
  101.         {
  102.             gOutput.writeLine("Command line: " + command);
  103.         }
  104.         
  105.         javadocTool.run(command);
  106.     }
  107. }
  108.  
  109. function GetJDKSourcePath()
  110. {
  111.     var jdkDirectory = gHelpers.lookup("jdk-directory", null);
  112.     if (jdkDirectory == null)
  113.     {
  114.         var jdkDirectoryPath = "";
  115.         var jdkBinDirectory = gHelpers.lookup("jdk-bin_directory", null);
  116.         if (jdkBinDirectory)
  117.         {
  118.             // chop off \bin
  119.             jdkDirectoryPath = 
  120.                 jdkBinDirectory.path.substring(0, jdkBinDirectory.path.length - 3) +
  121.                 "src";
  122.         }
  123.         return jdkDirectoryPath;
  124.     }
  125.     else
  126.     {
  127.         return jdkDirectory.path + "\\src";
  128.     }
  129. }
  130.  
  131. function GetCustomSourcePaths()
  132. {
  133.     var customSourcePaths = "";
  134.     var sourcePathList = gOptions.lookup("customSourcePathList", null);
  135.     if (sourcePathList)
  136.     {
  137.         var position = sourcePathList.getHeadPosition();
  138.         while (position && position.valid)
  139.         {
  140.             customSourcePaths += ";" + sourcePathList.getNext(position);
  141.         }
  142.     }
  143.     return customSourcePaths;
  144. }
  145.  
  146. function GetBuildPackageSourcePaths()
  147. {
  148.     var sourcepaths = "";
  149.     var project = getCurrentProject();
  150.     if (project)
  151.     {
  152.         var packageList = project.getPackageList();
  153.         if (packageList)
  154.         {
  155.             var position = packageList.getHeadPosition();
  156.             while (position.valid)
  157.             {
  158.                 var p = packageList.getNext(position);
  159.                 var packageSourcePath = p.sourcePath;
  160.                 var packageName = p.name;
  161.                 if (packageName.length > 0)
  162.                 {
  163.                     packageSourcePath = packageSourcePath.substring(0, 
  164.                         packageSourcePath.length - 1 - packageName.length);
  165.                 }
  166.                 
  167.                 if (packageSourcePath && sourcepaths.indexOf(packageSourcePath) == -1)
  168.                 {
  169.                     sourcepaths += ";" + packageSourcePath;
  170.                 }
  171.             }
  172.         }
  173.     }
  174.     
  175.     return sourcepaths;
  176. }
  177.  
  178. !!/Script
  179.  
  180.