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;
}
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();
}
Aggregations