Example usage for com.liferay.portal.kernel.util TreeNode addChildNode

List of usage examples for com.liferay.portal.kernel.util TreeNode addChildNode

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util TreeNode addChildNode.

Prototype

public TreeNode<T> addChildNode(T value) 

Source Link

Usage

From source file:com.liferay.portlet.messageboards.model.impl.MBCategoryDisplayImpl.java

License:Open Source License

protected void populateCategoryNodesMap(TreeNode<MBCategory> node, Map<Long, List<MBCategory>> categoriesMap) {

    MBCategory category = node.getValue();

    if (category.getCategoryId() == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

        _categoryNodesMap.put(category.getCategoryId(), node);
    }/*w w w.ja v  a  2  s .  c o  m*/

    List<MBCategory> categories = categoriesMap.get(category.getCategoryId());

    if (categories == null) {
        return;
    }

    for (MBCategory curCategory : categories) {
        TreeNode<MBCategory> curNode = node.addChildNode(curCategory);

        _categoryNodesMap.put(curCategory.getCategoryId(), curNode);

        populateCategoryNodesMap(curNode, categoriesMap);
    }
}

From source file:com.liferay.portlet.wiki.engines.antlrwiki.translator.TableOfContentsVisitor.java

License:Open Source License

protected boolean addHeadingNode(TreeNode<HeadingNode> treeNode, HeadingNode headingNode) {

    if (!isLastHeadingNode(treeNode, headingNode)) {
        HeadingNode treeNodeHeadingNode = treeNode.getValue();

        if (headingNode.getLevel() <= treeNodeHeadingNode.getLevel()) {
            TreeNode<HeadingNode> parentTreeNode = treeNode.getParentNode();

            parentTreeNode.addChildNode(headingNode);
        } else {//from  w w  w .j av  a  2s.  c  o m
            treeNode.addChildNode(headingNode);
        }

        return false;
    }

    List<TreeNode<HeadingNode>> treeNodes = treeNode.getChildNodes();

    for (int i = treeNodes.size() - 1; i >= 0; --i) {
        return addHeadingNode(treeNodes.get(i), headingNode);
    }

    return true;
}