Search in sources :

Example 6 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class TreeHelper method resolveTreeNode.

public static TreeNode resolveTreeNode(String treePath, TreeModel treeModel) {
    // even for the root node, our parameter may not be the empty string, therefore the prefix to be chopped here
    treePath = treePath.substring(1);
    TreeNode cur = treeModel.getRootNode();
    if (!treePath.equals("")) {
        // if we are not the root node
        String[] res = treePath.split("_");
        for (int i = res.length - 1; i >= 0; i--) {
            String spos = res[i];
            Integer chdPos = Integer.parseInt(spos);
            TreeNode chd = (TreeNode) cur.getChildAt(chdPos);
            if (chd == null)
                throw new AssertException("cannot find: " + treePath);
            cur = chd;
        }
    }
    return cur;
}
Also used : AssertException(org.olat.core.logging.AssertException) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 7 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class MergedCourseContainer method init.

protected void init(PersistingCourseImpl persistingCourse) {
    super.init();
    RepositoryEntry courseRe = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    courseReadOnly = !overrideReadOnly && (courseRe.getRepositoryEntryStatus().isClosed() || courseRe.getRepositoryEntryStatus().isUnpublished());
    if (courseReadOnly) {
        setLocalSecurityCallback(new ReadOnlyCallback());
    }
    if (identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
        VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
        if (courseReadOnly) {
            courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
        }
        addContainersChildren(courseContainer, true);
    } else {
        RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance().isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
        if (reSecurity.isEntryAdmin()) {
            VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
            if (courseReadOnly) {
                courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
            }
            addContainersChildren(courseContainer, true);
        }
    }
    initSharedFolder(persistingCourse);
    // add all course building blocks of type BC to a virtual folder
    MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
    if (identityEnv == null) {
        CourseNode rootNode = persistingCourse.getRunStructure().getRootNode();
        addFoldersForAdmin(persistingCourse, nodesContainer, rootNode);
    } else {
        TreeEvaluation treeEval = new TreeEvaluation();
        GenericTreeModel treeModel = new GenericTreeModel();
        UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, persistingCourse.getCourseEnvironment());
        CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
        NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
        TreeNode treeRoot = rootNodeEval.getTreeNode();
        treeModel.setRootNode(treeRoot);
        addFolders(persistingCourse, nodesContainer, treeRoot);
    }
    if (nodesContainer.getItems().size() > 0) {
        addContainer(nodesContainer);
    }
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) MergeSource(org.olat.core.util.vfs.MergeSource) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) TreeNode(org.olat.core.gui.components.tree.TreeNode) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 8 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class ChooseElementsController method getSelectedNames.

public List<String> getSelectedNames() {
    Set<String> selectedKeys = selectTree.getSelectedKeys();
    List<String> names = new ArrayList<>(selectedKeys.size());
    for (String selectedKey : selectedKeys) {
        TreeNode node = treeModel.getNodeById(selectedKey);
        if (node == null) {
        // not published??
        } else {
            names.add(node.getTitle());
        }
    }
    return names;
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 9 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentCourseTreeController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == businessGroupListCtrl) {
        if (event instanceof CourseNodeEvent) {
            CourseNodeEvent cne = (CourseNodeEvent) event;
            CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(cne.getIdent());
            TreeNode treeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
            if (treeNode == null) {
                treeNode = menuTree.getTreeModel().getRootNode();
                courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getRootNode();
                doSelectCourseNode(ureq, treeNode, courseNode);
                menuTree.setSelectedNode(treeNode);
                showWarning("warning.course.node.deleted");
            } else {
                stackPanel.changeDisplayname(treeNode.getTitle(), "o_icon " + treeNode.getIconCssClass(), this);
                selectedNodeChanged = treeNode;
            }
        }
    }
    super.event(ureq, source, event);
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) CourseNodeEvent(org.olat.course.assessment.ui.tool.event.CourseNodeEvent)

Example 10 with TreeNode

use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentCourseTreeController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    boolean emptyEntries = entries == null || entries.isEmpty();
    if (emptyEntries) {
        TreeNode rootNode = menuTree.getTreeModel().getRootNode();
        if (rootNode.getUserObject() instanceof CourseNode) {
            if (view == null) {
                view = View.users;
            }
            doSelectCourseNode(ureq, rootNode, (CourseNode) rootNode.getUserObject());
            menuTree.setSelectedNode(rootNode);
        }
    } else {
        ContextEntry entry = entries.get(0);
        String resourceTypeName = entry.getOLATResourceable().getResourceableTypeName();
        if ("Identity".equalsIgnoreCase(resourceTypeName)) {
            TreeNode treeNode = menuTree.getTreeModel().getRootNode();
            CourseNode courseNode = (CourseNode) treeNode.getUserObject();
            if (courseNode != null) {
                view = View.users;
                Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
                if (ctrl instanceof Activateable2) {
                    ((Activateable2) ctrl).activate(ureq, entries, null);
                }
                menuTree.setSelectedNode(treeNode);
            }
        } else if ("Node".equalsIgnoreCase(resourceTypeName) || "CourseNode".equalsIgnoreCase(resourceTypeName)) {
            Long nodeIdent = entries.get(0).getOLATResourceable().getResourceableId();
            CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(nodeIdent.toString());
            TreeNode treeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
            if (courseNode != null) {
                if (view == null) {
                    view = View.users;
                }
                Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
                if (ctrl instanceof Activateable2) {
                    List<ContextEntry> subEntries = entries.subList(1, entries.size());
                    ((Activateable2) ctrl).activate(ureq, subEntries, entry.getTransientState());
                }
                menuTree.setSelectedNode(treeNode);
            }
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) TreeNode(org.olat.core.gui.components.tree.TreeNode) List(java.util.List) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

TreeNode (org.olat.core.gui.components.tree.TreeNode)296 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)146 ArrayList (java.util.ArrayList)44 CourseNode (org.olat.course.nodes.CourseNode)38 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)32 ContextEntry (org.olat.core.id.context.ContextEntry)30 Controller (org.olat.core.gui.control.Controller)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 INode (org.olat.core.util.nodes.INode)20 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)20 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)20 ICourse (org.olat.course.ICourse)18 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)16 OLATResourceable (org.olat.core.id.OLATResourceable)16 List (java.util.List)14 TreeModel (org.olat.core.gui.components.tree.TreeModel)14 WindowControl (org.olat.core.gui.control.WindowControl)14 AssertException (org.olat.core.logging.AssertException)14