home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 227 cm19981009 - add forceUpdate
-
- /**
- @Tool: removeFiles~displays a list of files you can remove
- from packages in a project. The list files available to
- be removed depends upon "auto include files" option.
- If the package is created with the "auto include files"
- not marked, then the initial list of files you can remove will
- include all matching source files in the source path and sub-directories.
- If the package is created with the "auto include files"
- marked, then the initial list of files you can remove will be empty.
- @Image: Remove Files Dialog@removeFiles_Project.gif
- @EndTool:
- @Summary: removeFiles~displays a list of files you can remove
- */
-
- 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 packageToRemoveFilesFrom =
- chooseFromList("Choose package to remove files from",
- packageList, getPackageString, false);
-
- if (packageToRemoveFilesFrom)
- {
- RemoveFiles(packageToRemoveFilesFrom);
- }
- }
- else if (packageList.count == 1)
- {
- RemoveFiles(packageList.removeHead());
- }
- }
- else
- {
- alert("You must add a package before removing files");
- }
- }
- else
- {
- alert("A project must be open before you can remove files");
- }
- }
-
- function RemoveFiles(fromPackage)
- {
- if (fromPackage)
- {
- // Get list of files included in the package
- var includedFileList = fromPackage.getFileList(false);
- var filesToRemoveList = chooseFromList("Choose files to remove",
- includedFileList, getFileString, true);
-
- // Remove the files from the package
- if (filesToRemoveList)
- {
- var position = filesToRemoveList.getHeadPosition();
- while (position.valid)
- {
- var file = filesToRemoveList.getNext(position);
- if (file)
- {
- var destFile = fromPackage.getDestinationFile(file);
- if (destFile && pathExists(destFile.path) && destFile.path != file.path)
- {
- File.deleteFile(destFile);
- }
- fromPackage.excludeFile(file);
- }
- }
- Application.updateWorkspaceTab("Class");
- Application.updateWorkspaceTab("Package");
- Application.updateWorkspaceTab("Files");
-
- fromPackage.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
-