Search in sources :

Example 51 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class StatisticCourseNodesController method buildTreeModel.

private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
    final GenericTreeModel gtm = new GenericTreeModel();
    final GenericTreeNode rootTreeNode = new GenericTreeNode();
    rootTreeNode.setTitle("start");
    gtm.setRootNode(rootTreeNode);
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    new TreeVisitor(new Visitor() {

        @Override
        public void visit(INode node) {
            CourseNode courseNode = (CourseNode) node;
            StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
            if (result != null) {
                StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
                rootTreeNode.addChild(courseNodeTreeNode);
                TreeModel subTreeModel = result.getSubTreeModel();
                if (subTreeModel != null) {
                    TreeNode subRootNode = subTreeModel.getRootNode();
                    List<INode> subNodes = new ArrayList<>();
                    for (int i = 0; i < subRootNode.getChildCount(); i++) {
                        subNodes.add(subRootNode.getChildAt(i));
                    }
                    for (INode subNode : subNodes) {
                        courseNodeTreeNode.addChild(subNode);
                    }
                }
            }
        }
    }, course.getRunStructure().getRootNode(), true).visitAll();
    return gtm;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) CourseNode(org.olat.course.nodes.CourseNode)

Example 52 with TreeVisitor

use of org.olat.core.util.tree.TreeVisitor in project openolat by klemens.

the class ForumArchiveManager method formatThread.

/**
 * @param mn
 * @param forumFormatter
 * @param metaInfo
 * @return
 */
private String formatThread(MessageNode mn, ForumFormatter forumFormatter, Long forumId) {
    forumFormatter.setForumKey(forumId);
    StringBuilder formattedThread = new StringBuilder();
    forumFormatter.openThread();
    TreeVisitor tv = new TreeVisitor(forumFormatter, mn, false);
    tv.visitAll();
    return formattedThread.append(formattedThread.append(forumFormatter.closeThread())).toString();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor)

Aggregations

TreeVisitor (org.olat.core.util.tree.TreeVisitor)52 Visitor (org.olat.core.util.tree.Visitor)42 INode (org.olat.core.util.nodes.INode)30 CourseNode (org.olat.course.nodes.CourseNode)24 ArrayList (java.util.ArrayList)14 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)14 Identity (org.olat.core.id.Identity)10 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)10 ICourse (org.olat.course.ICourse)7 File (java.io.File)6 HashMap (java.util.HashMap)6 List (java.util.List)6 BCCourseNode (org.olat.course.nodes.BCCourseNode)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 STCourseNode (org.olat.course.nodes.STCourseNode)5 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)5 TACourseNode (org.olat.course.nodes.TACourseNode)5 IOException (java.io.IOException)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 CorruptedCourseException (org.olat.course.CorruptedCourseException)4