package com.dev.swms.client.ui.page;

import com.gwtext.client.dd.DragData;
import com.gwtext.client.dd.DragDrop;
import com.gwtext.client.widgets.tree.DropNodeCallback;
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
import com.gwtext.client.widgets.tree.event.TreePanelListenerAdapter;

/**
 * 
 * @author  dev
 * @description 西边布局面板中的树容器,根为'仓库'根节点不显示
 * 
 */

public class WestTreePanel extends TreePanel {

	protected TreeNode root;

	private String title;

	public WestTreePanel(String title) {
		this.title = title;
		init();
	}

	protected void init() {
		setTitle(title);
		setWidth(170);
		setCollapsible(true);
		setAnimate(true);
		
		setAutoScroll(true);
		setContainerScroll(true);
		setRootVisible(false);
		setBorder(false);
		
		setEnableDD(true);
		setHlDrop(true);
		setEnableDrop(true);
		
		this.addListener(new TreePanelListenerAdapter() {
			public boolean doBeforeNodeDrop(TreePanel treePanel,
					TreeNode target, DragData dragData, String point,
					DragDrop source, TreeNode dropNode,
					DropNodeCallback dropNodeCallback) {
				return false;
			}
		});
		
		root = new TreeNode("仓库");
		root.expand();
		setRootNode(root);
	}

	public TreeNode getRoot() {
		return root;
	}

	public void setRoot(TreeNode root) {
		this.root = root;
	}
}
