Prototype for FolderDocument.Selection objects. Is a kind of Document.Selection object.
To create an empty folder selection:
var folder_doc;
var sel = new FolderDocument.Selection (folder_doc);
To create a folder selection containing all the items in the folder document (include_all=true):
var folder_doc;
var sel = new FolderDocument.Selection (folder_doc,
include_all);
folder_doc. FolderDocument
object. Folder document for which items are selected.
include_all. Boolean. True if you want to select all the items.
False or undefined if you want no items to be selected.
none.
ECMerge 2.1
FolderDocument.Selection objects describe which items are selected in folder document. The items which are selected will be those on which operations occur. These selections are often used to limit the set of items which are compared, modified, copied, deleted...
none specific.
To create a folder selection containing all the items in the folder document:
var folder_doc;
var sel = new FolderDocument.Selection (folder_doc,
true);
Document.Selection object, FolderDocument object
function add (item, recursively)
function remove (item, recursively)
item. FolderDocument.Item
object. Item to add or remove
recursively. Boolean. True if the addition or removal must act
the entire sub-tree rooted at item. False if the addition or
removal concerns only this item itself.
FolderDocument.Selection object.
ECMerge 2.1
add adds item (or sub-tree rooted at item) to the
selection.
remove removes item (or sub-tree rooted at item) from
the selection.
These two methods are the base operations to constitute an arbitrary selection.
Create a selection and add the items under the root matching a regular expression for executable files:
var folder_doc;
var sel = new FolderDocument.Selection (folder_doc);
var root_children = folder_doc.root.items;
root_children.fill ();
for (var i in root_children)
if
(root_children[i].name.match(/.*\.exe/i))
sel.add
(root_children[i]);
FolderDocument object, FolderDocument.Item object, FolderDocument.Selection object
function filter ( f )
function for_each ( f )
f. Function object. f is called for each item. It must return a Boolean and accepts one argument, a FolderDocument.Item object.
FolderDocument.Selection object.
ECMerge 2.1
filter and for_each both enumerate the items in the selection and call f for each enumerated elements.
f must return a Boolean. If this boolean is true, both functions enter the enumerated item and continue enumerating normally. When f returns false, filter will remove the enumerated item whereas for_each does nothing but not entering this item.
Checks whether current document is a folder document, uses the current selection, removes one item out of two from the selection, and set the result as the current selection:
var currentdoc =
current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder selection
test on non-folder document");
var sel = new FolderDocument.Selection(currentdoc, true);
var i = 0;
sel.filter (function () {
return ++i &
1;
});
current_frame.coordinator.current_view.set_selection(sel);
FolderDocument object, FolderDocument.Item object, FolderDocument.Selection object