Search in sources :

Example 21 with TreeModel

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);
}
Also used : MenuTree(org.olat.core.gui.components.tree.MenuTree) TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BreadcrumbPanel(org.olat.core.gui.components.stack.BreadcrumbPanel) Panel(org.olat.core.gui.components.panel.Panel) BreadcrumbedStackedPanel(org.olat.core.gui.components.stack.BreadcrumbedStackedPanel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Component(org.olat.core.gui.components.Component) BreadcrumbedStackedPanel(org.olat.core.gui.components.stack.BreadcrumbedStackedPanel)

Example 22 with TreeModel

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();
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 23 with TreeModel

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);
    }
}
Also used : MenuTree(org.olat.core.gui.components.tree.MenuTree) TreeModel(org.olat.core.gui.components.tree.TreeModel) TreeNode(org.olat.core.gui.components.tree.TreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 24 with TreeModel

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);
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 25 with TreeModel

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

Aggregations

TreeModel (org.olat.core.gui.components.tree.TreeModel)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)16 TreeNode (org.olat.core.gui.components.tree.TreeNode)14 ArrayList (java.util.ArrayList)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)8 HashMap (java.util.HashMap)6 List (java.util.List)6 Map (java.util.Map)6 Identity (org.olat.core.id.Identity)6 StringHelper (org.olat.core.util.StringHelper)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 Taxonomy (org.olat.modules.taxonomy.Taxonomy)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 TaxonomyTreeBuilder (org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)6 Date (java.util.Date)4 Locale (java.util.Locale)4 Collectors (java.util.stream.Collectors)4 Component (org.olat.core.gui.components.Component)4 AssertException (org.olat.core.logging.AssertException)4