home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 227 cm19981009 - add forceUpdate
-
- /**
- @Tool: addFiles~displays a list of files you can add to
- a package. Only the matching source files within the
- source path and its sub-directories can be added and
- removed from a package. If the package is created with
- the "auto include files" marked then the list
- of files will be empty unless you have excluded files
- from the package. If the package is created with the
- "auto include files" not marked, then the initial
- list of files you can add, will include all matching source
- files in the source path and sub-directories.
- @Image: Add Files Dialog@addFiles_Project.gif
- @EndTool:
- @Summary: addFiles~displays a list of files you can add
- */
-
- function DoUpdate(cmdUI)
- {
- var project = getCurrentProject();
- cmdUI.enable(project != null && !project.readOnly)
- return true;
- }
-
- function DoCommand()
- {
- var project = getCurrentProject();
-
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList && packageList.count >= 1)
- {
- if (packageList.count > 1)
- {
- var packageToAddFilesTo = chooseFromList("Choose package to add files to",
- packageList, getPackageString, false);
-
- if (packageToAddFilesTo)
- {
- AddFiles(packageToAddFilesTo);
- }
- }
- else if (packageList.count == 1)
- {
- AddFiles(packageList.removeHead());
- }
- }
- else
- {
- alert("You must add a package before adding files");
- }
- }
- else
- {
- alert("A project must be open before you can add files");
- }
- }
-
- function AddFiles(packageToAddTo)
- {
- if (packageToAddTo)
- {
- // Get list of files excluded or not included from the package
- var excludedFileList = packageToAddTo.getFileList(true);
- var filesToAddList = chooseFromList("Choose files to add",
- excludedFileList, getFileString, true);
-
- // Now add the files to the appropriate package
- if (filesToAddList)
- {
- var position = filesToAddList.getHeadPosition();
- while (position.valid)
- {
- var file = filesToAddList.getNext(position);
- if (file)
- {
- packageToAddTo.includeFile(file);
- }
- }
- Application.updateWorkspaceTab("Class");
- Application.updateWorkspaceTab("Package");
- Application.updateWorkspaceTab("Files");
- packageToAddTo.forceUpdate(); // cm19981009
- }
- }
- }
-
- function getPackageString(item)
- {
- // Assumes item is a Package object
- return item.name + " (" + item.sourcePath + ")";
- }
-
- function getFileString(item)
- {
- // Assumes item is a File object
- return item.path;
- }
-
- !!/Script
-