home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Project / addPackages.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.6 KB  |  62 lines

  1. !!Script
  2. // Copyright ⌐ 1999 - Modelworks Software
  3. // @Created build 289 cm19990419
  4.  
  5. /**
  6. @Tool: addPackages~adds all top level java packages to
  7. the current project.
  8. @EndTool: 
  9. @Summary: addPackages~adds all top level java packages.
  10. */
  11.  
  12. var gOutput = getOutput();
  13.  
  14. function DoCommand()
  15. {
  16.     var project = getCurrentProject();
  17.     
  18.     if (project)
  19.     {
  20.         var path = "" ; // Enter the path to your directory - ??\\MyProjects\\com\\modelworks"
  21.         var pkgRoot = ""; // Enter your root package name - "com.modelworks"
  22.         
  23.         if (path == "" || pkgRoot == "")
  24.         {
  25.             alert("You must edit this script before you can run it.");
  26.             return;
  27.         }
  28.  
  29.         var directoryList = getDirectories(path);
  30.         var position = directoryList.getHeadPosition();
  31.         while (position && position.valid)
  32.         {
  33.             var directory = directoryList.getNext(position);
  34.             
  35.             gOutput.writeLine("Adding package for: " + directory.path);
  36.             
  37.             var pkgName = pkgRoot + "." + directory.title;
  38.             var sourcePath = directory.path; // Change this if you want another path
  39.             
  40.             // Change destinationPath if you want another path
  41.             var destinationPath = sourcePath.substring(0, sourcePath.length - pkgName.length); 
  42.             
  43.             var pkg = newPackage("java", sourcePath, destinationPath, pkgName); 
  44.             pkg.includeSubdirectories = true;
  45.             
  46.             project.addPackage(pkg);
  47.         }
  48.         
  49.         // Force update of tabs
  50.         Application.updateWorkspaceTab("Class"); 
  51.         Application.updateWorkspaceTab("Package"); 
  52.         Application.updateWorkspaceTab("Files"); 
  53.     }
  54.     else
  55.     {
  56.         alert("A project must be open before you can add a package");
  57.     }
  58. }
  59.  
  60.  
  61. !!/Script
  62.