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

  1. !!Script
  2. // Copyright ⌐ 1997-2000 - Modelworks Software
  3.  
  4. /**
  5. @Tool: namePackage~lets you name a package. You will need to close 
  6. and then reopen the project to see the new name.
  7. @EndTool: 
  8. @Summary: editPackage~lets you name a package
  9. */
  10.  
  11. function DoCommand()
  12. {
  13.     var project = getCurrentProject();
  14.     
  15.     if (project)
  16.     {
  17.         var packageList = project.getPackageList();
  18.         
  19.         if (packageList)
  20.         {
  21.             var packageToEdit = chooseFromList("Choose a package to name",
  22.                 packageList, getString, false);
  23.             
  24.             if (packageToEdit)
  25.             {
  26.                 var name = prompt("Enter a name for this package", packageToEdit.name);  
  27.                 if (name != packageToEdit.name)
  28.                 {
  29.                     packageToEdit.title = name;
  30.                     packageToEdit.forceUpdate(); 
  31.                     Application.updateWorkspaceTab("Class"); 
  32.                     Application.updateWorkspaceTab("Package"); 
  33.                     Application.updateWorkspaceTab("Files"); 
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     else
  39.     {
  40.         alert("A project must be open before you can add a package");
  41.     }
  42. }
  43.  
  44. function getString(item)
  45. {
  46.     // assumes item is a package
  47.     if (item.name.length > 0)
  48.     {
  49.         return item.name + " - " + item.sourcePath ;
  50.     }
  51.     return "<untitled> - " + item.sourcePath;
  52. }
  53.  
  54.  
  55. !!/Script
  56.