home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 216 cm19980914 - see below
- // @Modified build 228 cm19981021 - added path parameter to GetJViewCommandLine and GetMSJCompileCommandLine
- // @Modified build 329 cm19991128 - added option to share classpaths with JDK
- // @Modified build 356 cm20000602 - fixed AddFilePathsToBatchFile - output not defined
-
- // MSJUtiltity functions
-
- var gJDKOptions = getMapFile("JDKToolsStandardOptions");
- var gMSJOptions = getMapFile("MSJToolsStandardOptions");
-
- // removed function DoCommand() - cm19980914
-
- function MSJSupported()
- {
- var supported = getGlobal("MSJ");
- if (!supported)
- {
- alert("Microsoft's Java Tools are not supported on NT 3.51");
- }
- return supported;
- }
-
- function GetJViewCommandLine(className, path) //cm19981021
- {
- var commandLine = "";
-
- var jviewPath;
- var standardOptions;
-
- var useEnvironmentClasspath = gMSJOptions.lookup("useEnvironmentClasspath", false);
- var runInWindow = gMSJOptions.lookup("runInWindow", true);
-
- if (runInWindow)
- {
- jviewPath = helpers.lookup("msj-wjview");
- standardOptions = gMSJOptions.lookup("msj-wjview", "");
- }
- else
- {
- jviewPath = helpers.lookup("msj-jview");
- standardOptions = gMSJOptions.lookup("msj-jview", "");
- }
-
- if (jviewPath)
- {
- commandLine = "\"" + jviewPath.path + "\" ";
-
- // Add options
- if (standardOptions.length > 0)
- {
- commandLine += standardOptions + " ";
- }
-
- if (useEnvironmentClasspath)
- {
- var tool = newTool();
- tool.setEnvironmentVariable("Classpath", getGlobal("EnvironmentClasspath"));
- }
- else
- {
- commandLine += GetClassPathArgument(false, path); //cm19981021
- }
-
- commandLine += " " + className;
- }
- else
- {
- var result = confirm("You need to run the MSJ setup script\n"
- + "before you can use this command.\n" +
- "Do you want to run the setup script now?");
- if (result)
- {
- run("Configuration\\MSJ");
- }
- }
-
- return commandLine;
- }
-
- function GetMSJCompileCommandLine(javafile) // cm19981021
- {
- // Get the compiler file object
- var compiler = helpers.lookup("msj-jvc");
-
- var useEnvironmentClasspath = gMSJOptions.lookup("useEnvironmentClasspath", false);
- var standardOptions = gMSJOptions.lookup("msj-jvc", "");
-
- if (compiler && compiler.exists)
- {
- // Quote all paths in case a path contains spaces
-
- // Add the path of the compiler -- this must be first
- var commandLine = "\"" + compiler.path + "\" ";
-
- // Add other options for the compiler
- if (standardOptions.length > 0)
- {
- commandLine += standardOptions + " ";
- }
-
- if (useEnvironmentClasspath)
- {
- var tool = newTool();
- tool.setEnvironmentVariable("Classpath", getGlobal("EnvironmentClasspath"));
- }
- else
- {
- commandLine += GetClassPathArgument(true, javafile); // cm19981021
- }
-
- return commandLine;
- }
- else
- {
- var result = confirm("You need to run the MSJ setup script\n"
- + "before you can use this command.\n" +
- "Do you want to run the setup script now?");
- if (result)
- {
- run("Configuration\\MSJ");
- }
- }
- }
-
- // This function set the global environment CLASSPATH
- // Use it as an alternative to the command line argument
- function setCLASSPATH(tool)
- {
- var value = "."; // Add the current directory
- value += GetPackageClassPaths();
- value += GetCustomClassPaths();
-
- var currentClasspath =
- tool.setEnvironmentVariable("CLASSPATH", value);
-
- // Return the current CLASSPATH
- return currentClasspath;
- }
-
- function clearCLASSPATH(tool)
- {
- var useEnvironmentClasspath = gMSJOptions.lookup("useEnvironmentClasspath", false);
- if (useEnvironmentClasspath)
- {
- tool.setEnvironmentVariable("Classpath", getGlobal("EnvironmentClasspath"));
- }
- else
- {
- tool.setEnvironmentVariable("CLASSPATH", "");
- }
- }
-
- function GetClassPathArgument(build, classpath)
- {
- // Add the classpaths quoting the classpaths argument
- var argument = "";
-
- var classPaths;
- if (build)
- {
- classPaths = GetBuildPackageClassPaths();
- }
- else
- {
- classPaths = GetPackageClassPaths();
- }
-
- var customClassPaths = GetCustomClassPaths();
- if (classPaths != "" || customClassPaths != "")
- {
- argument += "/cp:p \""; // Prepend these packages paths to the standard classpath
- if (classpath != "")
- {
- argument += Java.getClassPath(classpath) + ';';
- }
- if (customClassPaths != "")
- {
- argument += customClassPaths;
- if (classPaths != "")
- {
- argument += ";";
- }
- }
- argument += classPaths + "\"";
- }
- return argument;
- }
-
- function GetCustomClassPaths()
- {
- var shareCustomClasspathsWithJDK = getMapFileValue("Preferences", "Share JDK classpaths when using MSJ tools", true);; //cm19991128
-
- if (shareCustomClasspathsWithJDK)
- {
- var classpaths = "";
- classpaths = GetJDKCustomClassPaths(classpaths);
- return classpaths;
- }
-
- var classpaths = "";
- var entry = gMSJOptions.lookup("customClasspaths", "");
- if (entry != "")
- {
- classpaths = entry;
- }
- return classpaths;
- }
-
- function GetJDKCustomClassPaths(classpaths) //cm19991128
- {
- var entry = gJDKOptions.lookup("standardClasspaths", "");
- if (entry != "")
- {
- if (classpaths.length > 0)
- {
- classpaths += ";" + entry;
- }
- else
- {
- classpaths += entry;
- }
- }
-
- var entry = gJDKOptions.lookup("customClasspaths", "");
- if (entry != "")
- {
- if (classpaths.length > 0)
- {
- classpaths += ";" + entry;
- }
- else
- {
- classpaths += entry;
- }
- }
- return classpaths;
- }
-
- function GetPackageClassPaths()
- {
- var classpaths = "";
- var project = getCurrentProject();
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList)
- {
- var position = packageList.getHeadPosition();
- while (position && position.valid)
- {
- var packageClassPath =
- packageList.getNext(position).getJavaClassPath();
- if (packageClassPath && classpaths.indexOf(packageClassPath) == -1)
- {
- classpaths += packageClassPath;
- }
- if (position.valid)
- {
- classpaths += ";";
- }
- }
- }
- }
- return classpaths;
- }
-
- function GetBuildPackageClassPaths()
- {
- var classpaths = "";
- var project = getCurrentProject();
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList)
- {
- var position = packageList.getHeadPosition();
- while (position && position.valid)
- {
- var packageClassPath =
- packageList.getNext(position).getJavaClassPath();
- if (packageClassPath && classpaths.indexOf(packageClassPath) == -1)
- {
- classpaths += packageClassPath;
- }
- if (position.valid)
- {
- classpaths += ";";
- }
- }
- // Add SourcePath directories if needed
- position = packageList.getHeadPosition();
- while (position.valid)
- {
- var pack = packageList.getNext(position);
- if (pack.destinationNotSource)
- {
- var packageClassPath =
- pack.getJavaSourceClassPath();
- if (packageClassPath && classpaths.indexOf(packageClassPath) == -1)
- {
- classpaths += ";" + packageClassPath;
- }
- }
- }
- }
- }
- return classpaths;
- }
-
- function GetDestinationPath(sourcePath)
- {
- var destinationPath = "";
- var project = getCurrentProject();
- if (project)
- {
- var sourcePackage = project.getPackage(sourcePath);
- if (sourcePackage)
- {
- return sourcePackage.getDestinationPath(sourcePath);
- }
- }
- return destinationPath;
- }
-
- function AddFilePathsToBatchFile(buildList)
- {
- var file = null;
- var path = File.getDataPath() + "\\MSJCommandFile.txt";
- var editor = newEditor(path, false);
- if (editor)
- {
- editor.removeAll();
- var position = buildList.getHeadPosition();
- while (position.valid)
- {
- var file = buildList.getNext(position);
- if (file.fileType == "java")
- {
- editor.append(file.path + "\n");
- gOutput.writeLine("Including: " + file.path);
- }
- }
-
- file = editor.getFile();
- editor.close();
- }
- return file;
- }
-
- !!/Script
-