$package("com.qn.dlg");

com.qn.dlg.DirDlg = function (){
}

com.qn.dlg.DirDlg.prototype = new js.ui.BaseWindow();

com.qn.dlg.DirDlg.prototype.file = null;

com.qn.dlg.DirDlg.prototype.extendUI = function (){
	var __this = this;
	this.setTitle(props("Select Directory"));
	var extui = this.getDomNode("com.qn.dlg.DirDlg");
	this.container.appendChild(extui);
	this.okButton = extui.getElementsByTagName("input")[0];
	this.cancelButton = extui.getElementsByTagName("input")[1];
	this.leftDiv = extui.getElementsByTagName("div")[1];
	this.okButton.onclick = function(){
		__this.result = 1;
		__this.close();
	}
	this.cancelButton.onclick = function(){
		__this.result = 0;
		__this.close();
	}
	this.ui.style.width = "500px";
	this.ui.style.height = "300px";
	this.buildTree();
}

com.qn.dlg.DirDlg.prototype.list = function (path){
	if(path) {
		var rootNode = this.tree.getRoot();
		var file = rootNode.userObject;
		file.setPath(path);
	}
	this.tree.setSelected(this.tree.getRoot());
}

com.qn.dlg.DirDlg.prototype.buildTree = function (){
	var __this = this;
	var tree = this.tree = new com.qn.ui.FileTreeView();
	tree.getUI().style.height = "170px";
	tree.getUI().style.width = "100%";

	this.leftDiv.appendChild(tree.getUI());

	var file = new com.qn.io.File();
	file.type = 1;
	file.setPath("Share");
	var	rootnode = new js.ui.tree.TreeNode(tree);
	rootnode.setUserObject(file);
	tree.setRoot(rootnode);
	rootnode.getRenderer().text.innerHTML = props("Share Folders");

	tree.onload = function(files, parentNode){
		__this.currentPath = parentNode.userObject.getPath();
	}

}




