home *** CD-ROM | disk | FTP | other *** search
- !!Script
-
- /**
- @Tool: javadoc~creates HTML documents from
- Java source.
- @Note: This is the script that is used by the JDK/Run Javadoc menu.
- @EndNote:
- @EndTool:
- @Summary: javadoc~creates HTML documents
- */
-
- var gOutput = getOutput();
- var gHelpers = getMapFile("ApplicationHelpers");
- var gOptions = getMapFile("JDKToolsStandardOptions");
-
- function DoCommand()
- {
- var path = "";
- var directory = "";
-
- var project = getCurrentProject();
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList)
- {
- var position = packageList.getHeadPosition();
- while (position && position.valid)
- {
- var p = packageList.getNext(position);
- path += p.name;
- if (position && position.valid)
- {
- path += " ";
- }
- }
- }
- }
-
- // If the current document is a Java file then use that file
- if (path == "")
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var fileType = editor.getFile().fileType.toLowerCase();
- if (fileType == "java")
- {
- path = editor.path;
- directory = editor.getFile().directory;
- }
- }
- }
-
- // Else ask the user to locate a Java file
- if (path == "")
- {
- var file = chooseFile("Choose a Java file for Javadoc", "Java files", "*.java");
- if (file && file.exists)
- {
- path = file.path;
- directory = file.directory;
- }
- }
-
- if (path.length > 0 && gHelpers)
- {
- var jdkDirectory = gHelpers.lookup("jdk-bin_directory");
- var javadoc = jdkDirectory.path + "\\javadoc.exe";
-
- // Add the path to the javadoc.exe -- this must be first
- var command = "\"" + javadoc + "\" ";
-
- var jdkSource = ";" + GetJDKSourcePath();
-
- command += "-sourcepath \"." + GetBuildPackageSourcePaths() +
- GetCustomSourcePaths() + jdkSource + "\"";
-
- // Add options
- command += " -private ";
-
- gOutput.clear();
- if (project)
- {
- command += path; // Contains package name[s]
- }
- else
- {
- command += "\"" + path + "\"";
- }
-
- File.setDirectory(directory);
- if (gOptions.lookup("showCommandLine",false)==true)
- {
- gOutput.writeLine("The current directory is: " + File.getDirectory().path);
- }
-
- // Create a process to run the appletviewer
- var javadocTool = newTool();
-
- if (gOptions.lookup("showCommandLine",false)==true)
- {
- gOutput.writeLine("Command line: " + command);
- }
-
- javadocTool.run(command);
- }
- }
-
- function GetJDKSourcePath()
- {
- var jdkDirectory = gHelpers.lookup("jdk-directory", null);
- if (jdkDirectory == null)
- {
- var jdkDirectoryPath = "";
- var jdkBinDirectory = gHelpers.lookup("jdk-bin_directory", null);
- if (jdkBinDirectory)
- {
- // chop off \bin
- jdkDirectoryPath =
- jdkBinDirectory.path.substring(0, jdkBinDirectory.path.length - 3) +
- "src";
- }
- return jdkDirectoryPath;
- }
- else
- {
- return jdkDirectory.path + "\\src";
- }
- }
-
- function GetCustomSourcePaths()
- {
- var customSourcePaths = "";
- var sourcePathList = gOptions.lookup("customSourcePathList", null);
- if (sourcePathList)
- {
- var position = sourcePathList.getHeadPosition();
- while (position && position.valid)
- {
- customSourcePaths += ";" + sourcePathList.getNext(position);
- }
- }
- return customSourcePaths;
- }
-
- function GetBuildPackageSourcePaths()
- {
- var sourcepaths = "";
- var project = getCurrentProject();
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList)
- {
- var position = packageList.getHeadPosition();
- while (position.valid)
- {
- var p = packageList.getNext(position);
- var packageSourcePath = p.sourcePath;
- var packageName = p.name;
- if (packageName.length > 0)
- {
- packageSourcePath = packageSourcePath.substring(0,
- packageSourcePath.length - 1 - packageName.length);
- }
-
- if (packageSourcePath && sourcepaths.indexOf(packageSourcePath) == -1)
- {
- sourcepaths += ";" + packageSourcePath;
- }
- }
- }
- }
-
- return sourcepaths;
- }
-
- !!/Script
-
-