package gov.va.med.esr.ui.util;

import com.jenkov.prizetags.tree.itf.ITree;
import com.jenkov.prizetags.tree.itf.ITreeNode;
import com.jenkov.prizetags.tree.itf.IUnSelectListener;

public class TreeNodeUnSelectListener implements IUnSelectListener {

	public void nodeUnselected(ITreeNode itreenode, ITree tree) {
		// TODO Auto-generated method stub
		if ( itreenode == null ) return;
		//if the parent is null then return;
		ITreeNode parentNode = itreenode.getParent();
		if ( parentNode == null ) return;
		
		//if the parent is already unselected then return. 
		if ( ! tree.isSelected(parentNode.getId())) {
			System.out.println("Stop unselect @ :" + parentNode.getId());
			return;
		}
		
		// unselect the parent.
		tree.unSelect(parentNode.getId());
		
	}

}
