Search in sources :

Example 46 with TreeNode

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

the class QuestionPoolMainEditorController method activateQuestionItem.

private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
    QuestionItem item = qpoolService.loadItemById(itemKey);
    if (item == null)
        return;
    List<Identity> authors = qpoolService.getAuthors(item);
    if (authors.contains(getIdentity())) {
        activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
        return;
    }
    if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
        TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
        if (levelNode != null) {
            activateNode(ureq, levelNode, entries);
            return;
        }
    }
    if (treeModel.getSharesNode() != null) {
        List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
        for (QuestionItem2Resource share : shares) {
            TreeNode levelNode = treeModel.getShareNode(share);
            if (levelNode != null) {
                activateNode(ureq, levelNode, entries);
                return;
            }
        }
        List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
        for (QuestionItem2Pool pool : pools) {
            TreeNode levelNode = treeModel.getShareNode(pool);
            if (levelNode != null) {
                activateNode(ureq, levelNode, entries);
                return;
            }
        }
    }
}
Also used : MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QuestionItem2Resource(org.olat.modules.qpool.QuestionItem2Resource)

Example 47 with TreeNode

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

the class QuestionPoolMainEditorController method doSelectControllerTreeNode.

private void doSelectControllerTreeNode(UserRequest ureq, TreeNode node, List<ContextEntry> entries, StateEntry state) {
    TreeNode nodeToShow = getDelegate(node);
    menuTree.setSelectedNode(nodeToShow);
    if (nodeToShow instanceof ControllerTreeNode) {
        ControllerTreeNode cNode = (ControllerTreeNode) nodeToShow;
        doSelectQuestionsNode(ureq, cNode, entries, state);
    }
}
Also used : ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode)

Example 48 with TreeNode

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

the class CatalogEntryAddController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == okButton) {
        TreeNode node = selectionTree.getSelectedNode();
        if (node != null) {
            // no selection is allowed
            Long newParentId = Long.parseLong(node.getIdent());
            insertNode(ureq, newParentId);
        }
    } else if (source == cancelButton) {
        fireEvent(ureq, Event.CANCELLED_EVENT);
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 49 with TreeNode

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

the class CourseLinkProviderController method setKalendarEvent.

@Override
public void setKalendarEvent(KalendarEvent kalendarEvent) {
    this.kalendarEvent = kalendarEvent;
    // clear all selections
    clearSelection(courseNodeTreeModel.getRootNode());
    multiSelectTree.deselectAll();
    for (KalendarEventLink link : kalendarEvent.getKalendarEventLinks()) {
        if (link.getProvider().equals(COURSE_LINK_PROVIDER)) {
            String nodeId = link.getId();
            TreeNode node = courseNodeTreeModel.getNodeById(nodeId);
            if (node == null) {
                String fallBackNodeId = availableCourses.get(0).getResourceableId() + "_" + nodeId;
                node = courseNodeTreeModel.getNodeById(fallBackNodeId);
            }
            if (node == null && nodeId.indexOf("_") < 0) {
                // course selected -> map to root node
                for (ICourse course : availableCourses) {
                    if (nodeId.equals(course.getResourceableId().toString())) {
                        String fallBackNodeId = course.getResourceableId() + "_" + course.getRunStructure().getRootNode().getIdent();
                        node = courseNodeTreeModel.getNodeById(fallBackNodeId);
                    }
                }
            }
            if (node != null) {
                node.setSelected(true);
                multiSelectTree.select(node.getIdent(), true);
                multiSelectTree.open(node);
            }
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) ICourse(org.olat.course.ICourse) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Example 50 with TreeNode

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

the class CourseInternalLinkTreeModel method findNode.

/**
 * Depth-first traversal.
 *
 * @param nodeId
 * @param node
 * @return the treenode with the node id or null if not found
 */
private TreeNode findNode(String nodeId, TreeNode node) {
    if (node.getIdent().equals(nodeId))
        return node;
    int childcnt = node.getChildCount();
    for (int i = 0; i < childcnt; i++) {
        TreeNode child = (TreeNode) node.getChildAt(i);
        TreeNode result = findNode(nodeId, child);
        if (result != null)
            return result;
    }
    return null;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode)

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