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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3. // @Created build 237 cm19981117
  4.  
  5. /**
  6. @Tool: editBuildOrder~lets you edit the order of packages in a project.
  7. @EndTool: 
  8. @Summary: editBuildOrder~lets you edit the order of packages in a project
  9. */
  10.  
  11. function DoUpdate(cmdUI) 
  12. {
  13.     var project = getCurrentProject(); 
  14.     cmdUI.enable(project != null && !project.readOnly) 
  15.     return true;
  16. }
  17.  
  18. function DoCommand()
  19. {
  20.     var project = getCurrentProject();
  21.     
  22.     if (project)
  23.     {
  24.         var packageList = project.getPackageList();
  25.         
  26.         var packagesNotInbuild = RemoveNonbuildPackages(packageList);
  27.         
  28.         if (packageList)
  29.         {
  30.             var newPackageList = reorderList("Edit build order", "Choose the order in which the packages will be built",
  31.                 packageList, getString);
  32.             
  33.             if (newPackageList)
  34.             {
  35.                 newPackageList.appendList(packagesNotInbuild);
  36.                 project.setPackageList(newPackageList);
  37.  
  38.                 project.forceUpdate(); 
  39.                 Application.updateWorkspaceTab("Class"); 
  40.                 Application.updateWorkspaceTab("Package"); 
  41.                 Application.updateWorkspaceTab("Files"); 
  42.             }
  43.         }
  44.     }
  45.     else
  46.     {
  47.         alert("A project must be open before you can add a package");
  48.     }
  49. }
  50.  
  51. function RemoveNonbuildPackages(packageList)
  52. {
  53.     var list = newList();
  54.     var position = packageList.getHeadPosition();
  55.     while (position && position.valid)
  56.     {
  57.         var current = position.clone();
  58.         var pkg = packageList.getNext(position);
  59.         if (!pkg.includeInBuild)
  60.         {
  61.             packageList.removeAt(current);
  62.             list.addTail(pkg);
  63.         }
  64.     }
  65.     return list;
  66. }
  67.  
  68. function getString(item)
  69. {
  70.     // assumes item is a package
  71.     if (item.name.length > 0)
  72.     {
  73.         return item.name + " - " + item.sourcePath ;
  74.     }
  75.     return "<untitled> - " + item.sourcePath;
  76. }
  77.  
  78.  
  79. !!/Script
  80.