Ellié Computing Home Page
My Shopping Cart

Your shopping cart is empty

Display Cart

Call us at +1 586 62 ELLIE / +1 586 62 35543 Office Opened
sales@elliecomputing.com - Contact us


FolderDocument.Selection object

 

 

Prototype for FolderDocument.Selection objects. Is a kind of Document.Selection object.

Syntax

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);

Parameters

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.

Property Of

none.

Implemented In

ECMerge 2.1

Description

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...

Properties

none specific. 

Methods

add
remove
filter
for_each

Examples

Example 1.

To create a folder selection containing all the items in the folder document:

var folder_doc;
var sel = new FolderDocument.Selection (folder_doc, true);

See Also 

 Document.Selection object, FolderDocument object

Method add / remove

Syntax

function add (item, recursively)
function remove (item, recursively)

Parameters

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.

Method Of

FolderDocument.Selection object.

Implemented In

ECMerge 2.1

Description

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.

Examples

Example 1.

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]);

See Also 

  FolderDocument object, FolderDocument.Item object, FolderDocument.Selection object

Method filter / for_each

Syntax

function filter ( f )
function for_each ( f )

Parameters

f. Function object. f is called for each item. It must return a Boolean and accepts one argument, a FolderDocument.Item object.

Method Of

FolderDocument.Selection object.

Implemented In

ECMerge 2.1

Description

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.

Examples

Example 1.

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);

See Also 

 FolderDocument object, FolderDocument.Item object, FolderDocument.Selection object