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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: removePackage~displays a list of packages you can remove 
  6. from a project. 
  7. @Image: Remove Package Dialog@removePackage_Project.gif 
  8. @EndTool: 
  9. @Summary: removePackage~displays a list of packages you can remove 
  10. */
  11.  
  12. function DoUpdate(cmdUI) 
  13. {
  14.     var project = getCurrentProject();
  15.     cmdUI.enable(project != null && !project.readOnly)
  16.     return true;
  17. }
  18.  
  19. function DoCommand()
  20. {
  21.     var project = getCurrentProject();
  22.     
  23.     if (project)
  24.     {
  25.         var packageList = project.getPackageList();
  26.         if (packageList)
  27.         {
  28.             var packagesToRemoveList = chooseFromList("Choose packages to remove",
  29.             packageList, getString, true);
  30.             
  31.             if (packagesToRemoveList)
  32.             {
  33.                 var position = packagesToRemoveList.getHeadPosition();
  34.                 while(position.valid)
  35.                 {
  36.                     project.removePackage(packagesToRemoveList.getNext(position));
  37.                 }
  38.             }
  39.         }
  40.         else
  41.         {
  42.             alert("No packages are in this project");
  43.         }
  44.     }
  45.     else
  46.     {
  47.         alert("A project must be open before you can remove a package");
  48.     }
  49. }
  50.  
  51. function getString(item)
  52. {
  53.     // assumes item is a package
  54.     if (item.name.length > 0)
  55.     {
  56.         return item.name + " - " + item.sourcePath ;
  57.     }
  58.     return "<untitled> - " + item.sourcePath;
  59. }
  60.  
  61. !!/Script
  62.