Example usage for com.liferay.portal.kernel.util ListTree ListTree

List of usage examples for com.liferay.portal.kernel.util ListTree ListTree

Introduction

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

Prototype

public ListTree(T value) 

Source Link

Usage

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

License:Open Source License

protected void init(long scopeGroupId, long categoryId) throws Exception {
    _allCategories = MBCategoryServiceUtil.getCategories(scopeGroupId);

    _rootCategory = new MBCategoryImpl();

    _rootCategory.setCategoryId(categoryId);

    _categoryTree = new ListTree<MBCategory>(_rootCategory);

    _categoryNodesMap = new HashMap<Long, TreeNode<MBCategory>>();

    Map<Long, List<MBCategory>> categoriesMap = new HashMap<Long, List<MBCategory>>();

    for (MBCategory category : _allCategories) {
        Long parentCategoryId = category.getParentCategoryId();

        List<MBCategory> curCategories = categoriesMap.get(parentCategoryId);

        if (curCategories == null) {
            curCategories = new ArrayList<MBCategory>();

            categoriesMap.put(parentCategoryId, curCategories);
        }//from  w ww . j a v a  2 s .com

        curCategories.add(category);
    }

    populateCategoryNodesMap(_categoryTree.getRootNode(), categoriesMap);
}