package com.ht.ui.controls;

import java.util.Map;

import javafx.scene.control.TreeItem;

import com.ht.tags.model.index.IndexTreeNode;

public class IndexNodeTreeItem extends TreeItem<IndexTreeNode> {
	private boolean isLeaf = false;

	public IndexNodeTreeItem(IndexTreeNode value,
			Map<String, IndexNodeTreeItem> indexTreeNodeMap) {
		super(value);
		
		if (indexTreeNodeMap != null) {
			indexTreeNodeMap.put(value.getPath(), this);
		}

		if (value.getChildren() != null && !value.getChildren().isEmpty()) {
			for (IndexTreeNode child : value.getChildren()) {
				getChildren().add(
						new IndexNodeTreeItem(child, indexTreeNodeMap));
			}
		} else {
			isLeaf = true;
		}
	}

	@Override
	public boolean isLeaf() {
		return isLeaf;
	}

}