
My task is to create a TreeView simulating the structure of folders and files in the specified directory.
In itself, this problem is easily solved the same way as in the example from Adobe, in the script: SnpCreateTreeView.jsx
But I have a problem becomes more complicated.
Firstly, I want to do its TreeView without root directory:
- MyFolder1
MyFolder2
MyFolder3
But this would be enough if I knew that the number of folders in the selected directory will not be change. But what if their number will change? How to create a "poll" of directory, which result will be: for each folder available in the directory, are dynamically created own Node?
Second. In each of these folders will be located the scripts. As you can guess these scripts, when you double-click in the TreeView, should be executed. Again, this is easy to implement with hard specified number of folders and scripts. And again the question how this can be done dynamically?
Here what i have now:
Code: Select all
var win = this;
var rootFolder = "C:/Program Files/Adobe/Adobe After Effects CS5/Support Files/Scripts/MyEffects/";
var TreePanel = win.add("panel", [10, 10, 250, 400], "My Effects Collection:");
var MyNewNode = TreePanel.add("treeview", [10, 10, 225, 370]);
var aNode = MyNewNode.add("node", "EffectsSet1");
MyNewNode.onExpand = function (item)
{
var nextItem = item;
var path = "";
var goUp = true;
while(goUp)
{
path = "/" + nextItem.text + path;
nextItem = nextItem.parent;
if(nextItem instanceof TreeView)
{
goUp = false;
}
}
// Remove all the children of this item
item.removeAll();
var ref = new Folder(rootFolder + path);
if(ref instanceof Folder)
{
var children = ref.getFiles();
for(var i = 0;i < children.length;i++)
{
if(children[i] instanceof Folder)
{
item.add("node", children[i].displayName);
//item.items[i].image = that.folderIcon;
}
else
{
item.add("item", children[i].displayName);
//item.items[i].image = that.fileIcon;
}
}
}
}
MyNewNode.onChange = RunScript
function RunScript()
{
var scriptFile = File(File($.fileName).parent.parent.absoluteURI + "/Transitions/" + Node + "/" + MyNewNode.selection.text);
$.evalFile (File(scriptFile));
}
But in this way, I can not consider changes in the structure of folders...
And one more. Maybe somebody can comment on these posts:
http://forums.adobe.com/thread/793397?tstart=0
http://forums.adobe.com/thread/791012?tstart=0
There, for some reason no one answers....
Thank you to all who respond.