Prototype for FolderDocument objects
To create a folder document:
var parameters = new Document.Parameters ( );
parameters.document_type = "folders";
var doc = new Document (parameters, "view");
none.
none.
ECMerge 2.1
FolderDocument objects handle folder browsing or folder comparisons.
Property | Description |
root | FolderDocument.Item object. Root item, let you access the folder's item tree from the root |
information | See description in Document object. |
Property | Description |
background_content_diff | Boolean. Read-only. True if content differentiation is used in background to determine the comparison status of files. Use macro "options_toggle_background_content_diff" to switch this option on and off. |
visiting_sub_folders | Boolean. Read-only. True if the view is currently visiting all folders. Use macro "options_toggle_folder_visit", to switch this on and off. |
compare
compare_content
generic_copy
get_bookmarks_selection
get_item
get_statistics (in
Document
object)
merge
recompare
remove
reset_written_state
resolve
Creates a folder document to compare two directories, view it and display the statistics box:
var parameters = new Document.Parameters ( );
paramerers.left.url = "/folder1";
paramerers.left.url = "/folder2";
parameters.object_type = "folders";
var doc = new Document (parameters, "view");
add_frame (doc);
execute_macro ("view_comparison_stats");
FolderDocument.Selection object, FolderDocument.Item object
function compare (selection)
function compare_content (selection)
function recompare (selection)
function reset_written_state (selection)
selection. FolderDocument.Selection object. Selection of items to compare
FolderDocument object
ECMerge 2.1
compare and compare_content make the folder document compares the selected items. compare_content always compares the content of the items (when possible). compare follows the rules established in the Folder Comparisons panel of the Document options (i.e. "typed.folders.comparison" name space of the OptionsSet object).
recompare invalidates the result of previous comparisons for selected items, it does not run comparison at once.
reset_written_state removes the Written marker. Written items are ignored by the merge method.
Compares the currently selected elements:
current_frame.coordinator.document.compare (current_frame.coordinator.current_view.clone_selection());
function generic_copy (selection, source, target, mode, questions_answers)
selection.
FolderDocument.Selection object.
Selection of items to act on
source, target.
Side
string. Source and target sides for the generic copy operation
mode.
Generic
Copy Action string. Type of action to do
questions_answers.
Questions/Answers
string. Optional. Gives pre-established answers to known UI
questions, allowing you to avoid messages boxes.
FolderDocument object
ECMerge 2.1
Realizes the same operation as Generic Copy Dialog Box, without user interface.
Note the presence of the "simulate" question, in questions_answers parameter which allow you to only simulate the generic copy operation, and as such, only generate the log corresponding to what would be done (assuming everything is successful).
Cheks whether the document is folder document, then proposes various actions in choose( ) box and act:
var currentdoc = current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
selection test on non-folder document");
// take the selection and copies it from left to right
with selected parameters
var copy_choices = ["copy", "mirror", "copy (test
only)"];
var copy_codes = ["copy", "mirror", "copy"];
var qa_codes = ["", "", "yes:simulate"];
var copy_choice_idx = choose ("Select a copy mode:",
copy_choices);
if (copy_choice_idx != -1)
{
currentdoc.generic_copy
(current_frame.coordinator.current_view.clone_selection(),
"left",
"right", copy_codes[copy_choice_idx],
qa_codes[copy_choice_idx]);
}
FolderDocument.Selection object, Side string, Generic Copy Action string, Questions/Answers string
function get_bookmarks_selection( )
returns a
FolderDocument.Selection object
none.
FolderDocument object
ECMerge 2.1
Returns a selection built of the bookmarked items. This method allows you to act on bookmarked items, as easily as you can on selected items.
Compares contents of the bookmarked items:
var currentdoc =
current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
test on non-folder document");
currentdoc.compare
(currendoc.get_bookmarks_selection());
FolderDocument.Selection object
function get_item (url, side)
returns a
FolderDocument.Item object
or undefined if not found.
url.
URL object
or String. URL leading to the object which is compared in the
wanted folder item
side.
Side
string. Side in which the searched object appears in the
comparison. If undefined or omitted, searches all the
sides.
FolderDocument object
ECMerge 2.1
get_item searches for the comparison item in which the object pointed to by url appears.
Finds an item which has the object pointed to by "c:\\temp" in its ancestor side:
var currentdoc =
current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
test on non-folder document");
var item = currentdoc.get_item ("c:\\temp",
"ancestor");
FolderDocument.Item object
function merge (selection, questions_answers)
selection.
FolderDocument.Selection object.
Selection of items to act on
questions_answers.
Questions/Answers
string. Optional. Gives pre-established answers to known UI
questions, allowing you to avoid messages boxes.
FolderDocument object
ECMerge 2.1
Realizes the 'write merge results' operation as defined in Ellié Computing Merge: it takes each item, do the necessary comparisons, deduce the appropriate action from the comparison class and the settings found in the current document OptionsSet, then it executes this action.
merge will skip errors and unresolved items by default. You can change these baheviour with questions_answers parameters.
Merges the selected items:
var currentdoc =
current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
test on non-folder document");
currentdoc.merge
(current_frame.coordinator.current_view.clone_selection());
FolderDocument.Selection object, reset_written_state method.
function remove (selection, side, questions_answers)
selection.
FolderDocument.Selection object.
Selection of items to act on
side.
Side
string. Side from which the objects must be removed
questions_answers.
Questions/Answers
string. Optional. Gives pre-established answers to known UI
questions, allowing you to avoid messages boxes.
FolderDocument object
ECMerge 2.1
Deletes the file system objects in given side, for each item of the selection.
Note the presence of the "simulate" question, in questions_answers parameter which allow you to only simulate the deletion operation, and as such, only generate the log corresponding to what would be done (assuming everything is successful).
Tests whether current document is a folder, then asks if the user really wants to delete, then ask if confirmations are necessary, and deleted currently selected items:
var currentdoc = current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
selection test on non-folder document");
if (confirm ("Are you sure you want to delete selected
items in " +
current_frame.coordinator.current_view.role + " side?"))
{
var yesnos = confirm ("Remove
confirmations ?") ? "yes=fm-rm-folder,fm-rm-f-folder" : "";
currentdoc.remove
(current_frame.coordinator.current_view.clone_selection(),
current_frame.coordinator.current_view.role, yesnos);
}
FolderDocument.Selection object, Questions/Answers string
function resolve (selection, rules_set, undoable)
selection.
FolderDocument.Selection object.
Selection of items to act on
rules_set.
FolderDocument.MergeRulesSet
object. Set of actions to use for selected items
undoable. Boolean. True if you want the resolution action
to be undoable. This is possible only if the document is
viewed.
FolderDocument object
ECMerge 2.1
Resolves the selected items with the given resolution rules.
Tests whether current document is a folder, then let the user choose an action, and finally resolve currently selected item with it:
var currentdoc = current_frame.coordinator.document;
if (!(currentdoc instanceof FolderDocument))
return alert("can't apply folder
selection test on non-folder document");
var sel =
current_frame.coordinator.current_view.clone_selection();
var actions = [ 'none', 'mimic:left', 'mimic:right',
'delete' ];
var action = actions[choose('choose an action to
apply:', actions)];
if (action)
currentdoc.resolve (sel,
FolderDocument.MergeRulesSet(action));
FolderDocument.Selection object, FolderDocument.MergeRulesSet object