use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class GenericMainController method init.
/**
* use after optional addChildNodeToAppend() or addChildNodeToPrepend() calls
* to initialize MainController and set Panel
*
* @param ureq
*/
public void init(UserRequest ureq) {
olatMenuTree = new MenuTree("olatMenuTree");
TreeModel tm = buildTreeModel(ureq);
olatMenuTree.setTreeModel(tm);
content = new Panel("content");
TreeNode firstNode = tm.getRootNode();
TreeNode nodeToSelect = getLastDelegate(firstNode);
olatMenuTree.setSelectedNodeId(nodeToSelect.getIdent());
olatMenuTree.addListener(this);
// default is to not display the root element and to let user open/close sub elements
olatMenuTree.setRootVisible(false);
olatMenuTree.setExpandSelectedNode(false);
Object uobject = nodeToSelect.getUserObject();
contentCtr = getContentCtr(uobject, ureq);
// auto dispose later
listenTo(contentCtr);
Component resComp = contentCtr.getInitialComponent();
content.setContent(resComp);
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), olatMenuTree, content, className);
// auto dispose later
listenTo(columnLayoutCtr);
// create the stack
stackVC = new BreadcrumbedStackedPanel("genericStack", getTranslator(), this);
stackVC.pushController("content", columnLayoutCtr);
putInitialPanel(stackVC);
}
use of org.olat.core.gui.components.tree.TreeModel in project openolat by klemens.
the class QPoolTaxonomyTreeBuilder method prefill.
private void prefill(List<TaxonomyLevel> levels) {
prefillMaterializedPathKeysWithCompetence(levels);
TreeModel tree = buildTreeModel();
prefillTaxonomyLevels(tree.getRootNode());
prefillSelectableTaxonomyLevelsArrays();
}
use of org.olat.core.gui.components.tree.TreeModel in project openolat by klemens.
the class EPCollectStepForm04 method initForm.
/**
* @see org.olat.core.gui.control.generic.wizard.StepFormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
List<PortfolioStructure> structs = ePFMgr.getStructureElementsForUser(getIdentity());
if (structs != null && structs.size() != 0) {
TreeModel treeModel = new MapsTreeModel(getIdentity(), getTranslator());
mapsTreeController = new MenuTree("my.maps");
mapsTreeController.setTreeModel(treeModel);
mapsTreeController.setSelectedNode(treeModel.getRootNode());
mapsTreeController.setDragEnabled(false);
mapsTreeController.setDropEnabled(false);
mapsTreeController.setDropSiblingEnabled(false);
mapsTreeController.addListener(this);
mapsTreeController.setRootVisible(true);
if (preSelectedStructure != null) {
TreeNode node = TreeHelper.findNodeByUserObject(preSelectedStructure, treeModel.getRootNode());
if (node != null) {
mapsTreeController.setSelectedNode(node);
}
}
flc.put("treeCtr", mapsTreeController);
}
if (!isUsedInStepWizzard()) {
// add form buttons
uifactory.addFormSubmitButton("stepform.submit", formLayout);
}
}
use of org.olat.core.gui.components.tree.TreeModel in project openolat by klemens.
the class WikiRunController method createNodeRunConstructionResult.
public NodeRunConstructionResult createNodeRunConstructionResult() {
TreeModel wikiTreeModel = wikiCtr.getAndUseExternalTree();
String selNodeId = wikiTreeModel.getRootNode().getChildAt(0).getIdent();
return new NodeRunConstructionResult(this, wikiTreeModel, selNodeId, wikiCtr);
}
use of org.olat.core.gui.components.tree.TreeModel 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;
}
Aggregations