Search in sources :

Example 1 with TreeNode

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

the class GenericMainController method activate.

protected void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry entry = entries.get(0);
    TreeNode selectedNode = getMenuTree().getSelectedNode();
    String node = entry.getOLATResourceable().getResourceableTypeName();
    if (node != null && node.startsWith(GMCMT)) {
        activate(ureq, node + ":" + entries.get(0).getOLATResourceable().getResourceableId());
        if (entries.size() >= 1) {
            entries = entries.subList(1, entries.size());
        }
        if (contentCtr instanceof Activateable2) {
            ((Activateable2) contentCtr).activate(ureq, entries, entry.getTransientState());
        }
    } else {
        // maybe the node is a GAE-NavigationKey ?
        GenericActionExtension gAE = ExtManager.getInstance().getActionExtensioByNavigationKey(className, node);
        if (gAE != null) {
            // if the controller is already selected, only activate it, don't reinstanciate it
            if (selectedNode != null && selectedNode.getUserObject() != gAE) {
                activateTreeNodeByActionExtension(ureq, gAE);
            }
            if (entries.size() >= 1) {
                entries = entries.subList(1, entries.size());
            }
            if (contentCtr instanceof Activateable2) {
                ((Activateable2) contentCtr).activate(ureq, entries, entry.getTransientState());
            }
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 2 with TreeNode

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

the class GenericMainController method activateTreeNodeByActionExtension.

/**
 * activates the correct treenode for a given ActionExtension
 * @param ureq
 * @param ae
 */
private void activateTreeNodeByActionExtension(UserRequest ureq, ActionExtension ae) {
    TreeNode node = ((GenericTreeModel) olatMenuTree.getTreeModel()).findNodeByUserObject(ae);
    if (node != null) {
        olatMenuTree.setSelectedNodeId(node.getIdent());
        TreeEvent te = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, node.getIdent());
        event(ureq, olatMenuTree, te);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 3 with TreeNode

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

the class TreeHelper method findNodeByResourceableUserObject.

public static TreeNode findNodeByResourceableUserObject(OLATResourceable userObject, TreeNode node) {
    if (node.getUserObject() instanceof OLATResourceable && OresHelper.equals((OLATResourceable) node.getUserObject(), userObject)) {
        return node;
    }
    int childcnt = node.getChildCount();
    for (int i = 0; i < childcnt; i++) {
        TreeNode child = (TreeNode) node.getChildAt(i);
        TreeNode result = findNodeByUserObject(userObject, child);
        if (result != null)
            return result;
    }
    return null;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Example 4 with TreeNode

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

the class TreeHelper method getTreePath.

public static List<TreeNode> getTreePath(TreeNode node) {
    List<TreeNode> conPath = new ArrayList<TreeNode>();
    for (TreeNode cur = node; cur != null; cur = (TreeNode) cur.getParent()) {
        conPath.add(cur);
    }
    Collections.reverse(conPath);
    return conPath;
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) ArrayList(java.util.ArrayList)

Example 5 with TreeNode

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

the class TreeHelper method findNodeByUserObject.

/**
 * Depth-first traversal.
 * @param nodeId
 * @param node the root node to start the search with
 * @return the first treenode with the given user object or null if not found
 */
public static TreeNode findNodeByUserObject(Object userObject, TreeNode node) {
    if (node.getUserObject() != null && node.getUserObject().equals(userObject)) {
        return node;
    }
    int childcnt = node.getChildCount();
    for (int i = 0; i < childcnt; i++) {
        TreeNode child = (TreeNode) node.getChildAt(i);
        TreeNode result = findNodeByUserObject(userObject, child);
        if (result != null)
            return result;
    }
    return null;
}
Also used : 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