home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-2001 - Modelworks Software
- /**
- @Tool: Document Sets~defines the document sets toolbar.
- @EndTool:
- @Summary: Document Sets~defines the document sets toolbar
- */
-
- var gDocumentSetMapfile = getMapFile("DocumentSet.map");
- var gOutput = getOutput();
-
- function DoCommand()
- {
- var gDocumentSetComboBox = getGlobal("DocumentSet.DocumentSetComboBox",null);
- if (gDocumentSetComboBox)
- {
- var key = gDocumentSetComboBox.text;
-
- if (key.length == 0)
- {
- alert("You must define a document set before you can open it.");
- return;
- }
-
- var list = GetList(key);
-
- var newList = editList("Document Set: " + key,
- "To delete a document set choose remove all and then OK.",
- list,
- GetItemString,
- Edit,
- null,
- false,
- AddFiles,
- "Add Files...");
-
- if (newList && newList.count > 0)
- {
- gDocumentSetMapfile.add("Windows."+key, newList);
- var dslist = gDocumentSetMapfile.lookup("DocumentSet", null);
- if (dslist)
- {
- var index = -1;
- while ((index = dslist.find(key)) > -1)
- {
- var position = dslist.getPosition(index);
- dslist.removeAt(position)
- }
- dslist.addHead(key);
- }
- }
- else if (newList)
- {
- gDocumentSetMapfile.remove("Windows."+key);
- var dslist = gDocumentSetMapfile.lookup("DocumentSet", null);
- if (dslist)
- {
- var index = dslist.find(key);
- if (index > -1)
- {
- dslist.removeAt(dslist.getPosition(index));
- }
- }
- }
- }
-
- }
-
- function GetList(key)
- {
- var list = gDocumentSetMapfile.lookup("Windows." + key, null);
- if (list == null)
- {
- list = newList();
-
- var index = 0;
- var document = getDocument(index++);
- while(document)
- {
- if (document.path.length > 0)
- {
- list.addTail(document);
- }
- document = getDocument(index++);
- }
- }
- return list;
- }
-
- function GetItemString(item)
- {
- // item is a Document object
- if (item)
- {
- return item.path;
- }
- return "";
- }
-
- function AddFiles(item)
- {
- var filelist = chooseFiles("Add files", "*.*", "*.*");
-
- if (filelist)
- {
- var list = newList();
- var position = filelist.getHeadPosition();
- while (position && position.valid)
- {
- var file = filelist.getNext(position);
- list.addTail(File.newDocument(file.path));
- }
- return list;
- }
-
- return null;
- }
-
- function Edit(item)
- {
- var path = "file://" + File.getToolsPath;
- path += "\\Toolbars\\DocumentSet\\defineItem.dscript";
-
- var result = showHtmlDialog(path, new Array(Host, Application, item));
-
- return File.newDocument(result);
- }
-
-
- !!/Script
-
-