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

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

Introduction

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

Prototype

public T getValue() 

Source Link

Usage

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

License:Open Source License

public int getSubcategoriesMessagesCount(MBCategory category) {
    int count = category.getMessageCount();

    TreeNode<MBCategory> node = _categoryNodesMap.get(category.getCategoryId());

    List<TreeNode<MBCategory>> childNodes = _categoryTree.getChildNodes(node);

    for (TreeNode<MBCategory> curNode : childNodes) {
        MBCategory curCategory = curNode.getValue();

        count += curCategory.getMessageCount();
    }/* w ww .  j av  a  2s.co  m*/

    return count;
}

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

License:Open Source License

public int getSubcategoriesThreadsCount(MBCategory category) {
    int count = category.getThreadCount();

    TreeNode<MBCategory> node = _categoryNodesMap.get(category.getCategoryId());

    List<TreeNode<MBCategory>> childNodes = _categoryTree.getChildNodes(node);

    for (TreeNode<MBCategory> curNode : childNodes) {
        MBCategory curCategory = curNode.getValue();

        count += curCategory.getThreadCount();
    }//from ww  w. ja v  a2 s . co  m

    return count;
}

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 .j a 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 ww  w .j  a  va  2  s . co  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;
}

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

License:Open Source License

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

    HeadingNode treeNodeHeadingNode = treeNode.getValue();

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

    if ((headingNode.getLevel() > treeNodeHeadingNode.getLevel()) && (treeNodes != null)
            && (treeNodes.size() > 0)) {

        return true;
    }/*w w  w.  ja v a 2 s  .c  o  m*/

    return false;
}

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

License:Open Source License

protected void appendTableOfContents(TreeNode<HeadingNode> tableOfContents, int depth) {

    append("<ol>");

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

    if (treeNodes != null) {
        for (TreeNode<HeadingNode> treeNode : treeNodes) {
            append("<li class=\"toc-level-");
            append(depth);//w ww .  j  a  va  2 s  .co m
            append("\">");

            HeadingNode headingNode = treeNode.getValue();

            String content = getUnformattedHeadingText(headingNode);

            append("<a class=\"wikipage\" href=\"");

            if (_viewPageURL != null) {
                append(_viewPageURL.toString());
            }

            append(StringPool.POUND);
            append(getHeadingMarkup(_wikiPage.getTitle(), content));
            append("\">");
            append(content);
            append("</a>");

            appendTableOfContents(treeNode, depth + 1);

            append("</li>");
        }
    }

    append("</ol>");
}

From source file:com.liferay.wiki.engine.creole.internal.antlrwiki.translator.TableOfContentsVisitor.java

License:Open Source License

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

    HeadingNode treeNodeHeadingNode = treeNode.getValue();

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

    if ((headingNode.getLevel() > treeNodeHeadingNode.getLevel()) && ListUtil.isNotEmpty(treeNodes)) {

        return true;
    }/*w w  w  .  j  ava2  s . c o m*/

    return false;
}

From source file:com.liferay.wiki.engine.creole.internal.antlrwiki.translator.XhtmlTranslator.java

License:Open Source License

protected void appendTableOfContents(TreeNode<HeadingNode> tableOfContents, int depth) {

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

    if ((treeNodes == null) || treeNodes.isEmpty()) {
        return;/* w ww.j ava  2  s  .  c  om*/
    }

    append("<ol>");

    for (TreeNode<HeadingNode> treeNode : treeNodes) {
        append("<li class=\"toc-level-");
        append(depth);
        append("\">");

        HeadingNode headingNode = treeNode.getValue();

        String content = getUnformattedHeadingText(headingNode);

        append("<a class=\"wikipage\" href=\"");

        if (_viewPageURL != null) {
            String viewPageURLString = _viewPageURL.toString();

            int index = viewPageURLString.indexOf(StringPool.POUND);

            if (index != -1) {
                viewPageURLString = viewPageURLString.substring(0, index);
            }

            append(viewPageURLString);
        }

        append(StringPool.POUND);
        append(getHeadingMarkup(_page.getTitle(), content));
        append("\">");
        append(content);
        append("</a>");

        appendTableOfContents(treeNode, depth + 1);

        append("</li>");
    }

    append("</ol>");
}