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

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3. // @Modified build 227 cm19981009 - add forceUpdate
  4.  
  5. /**
  6. @Tool: addFiles~displays a list of files you can add to 
  7. a package. Only the matching source files within the 
  8. source path and its sub-directories can be added and 
  9. removed from a package. If the package is created with 
  10. the "auto include files" marked then the list 
  11. of files will be empty unless you have excluded files 
  12. from the package. If the package is created with the 
  13. "auto include files" not marked, then the initial 
  14. list of files you can add, will include all matching source 
  15. files in the source path and sub-directories. 
  16. @Image: Add Files Dialog@addFiles_Project.gif 
  17. @EndTool: 
  18. @Summary: addFiles~displays a list of files you can add 
  19. */
  20.  
  21. function DoUpdate(cmdUI) 
  22. {
  23.     var project = getCurrentProject();
  24.     cmdUI.enable(project != null && !project.readOnly)
  25.     return true;
  26. }
  27.  
  28. function DoCommand()
  29. {
  30.     var project = getCurrentProject();
  31.     
  32.     if (project)
  33.     {
  34.         var packageList = project.getPackageList();
  35.         if (packageList && packageList.count >= 1)
  36.         {
  37.             if (packageList.count > 1)
  38.             {
  39.                 var packageToAddFilesTo = chooseFromList("Choose package to add files to",
  40.                 packageList, getPackageString, false);
  41.                 
  42.                 if (packageToAddFilesTo)
  43.                 {
  44.                     AddFiles(packageToAddFilesTo);
  45.                 }
  46.             }
  47.             else if (packageList.count == 1)
  48.             {
  49.                 AddFiles(packageList.removeHead());
  50.             }
  51.         }
  52.         else
  53.         {
  54.             alert("You must add a package before adding files");
  55.         }
  56.     }
  57.     else
  58.     {
  59.         alert("A project must be open before you can add files");
  60.     }
  61. }
  62.  
  63. function AddFiles(packageToAddTo)
  64. {
  65.     if (packageToAddTo)
  66.     {
  67.         // Get list of files excluded or not included from the package
  68.         var excludedFileList = packageToAddTo.getFileList(true);
  69.         var filesToAddList = chooseFromList("Choose files to add", 
  70.         excludedFileList, getFileString, true);
  71.         
  72.         // Now add the files to the appropriate package
  73.         if (filesToAddList)
  74.         {
  75.             var position = filesToAddList.getHeadPosition();
  76.             while (position.valid)
  77.             {
  78.                 var file = filesToAddList.getNext(position);
  79.                 if (file)
  80.                 {
  81.                     packageToAddTo.includeFile(file);
  82.                 }
  83.             }
  84.             Application.updateWorkspaceTab("Class"); 
  85.             Application.updateWorkspaceTab("Package"); 
  86.             Application.updateWorkspaceTab("Files"); 
  87.             packageToAddTo.forceUpdate(); // cm19981009
  88.         }
  89.     }
  90. }
  91.  
  92. function getPackageString(item)
  93. {
  94.     // Assumes item is a Package object
  95.     return item.name + " (" + item.sourcePath + ")";
  96. }
  97.  
  98. function getFileString(item)
  99. {
  100.     // Assumes item is a File object
  101.     return item.path;
  102. }
  103.  
  104. !!/Script
  105.