Search in sources :

Example 66 with GenericTreeNode

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

the class CatalogTreeModel method buildTree.

/**
 * Build the selection tree from the given list of entries
 * @param entryList
 * @return The root node of the tree
 */
private GenericTreeNode buildTree(List<CatalogEntry> entryList) {
    GenericTreeNode rootNode = null;
    // build the tree - note that the entry list is not ordered in any way
    if (entryList != null) {
        for (CatalogEntry elem : entryList) {
            // create a tree node and add it to the entry map
            GenericTreeNode n = addNode(elem);
            if (n != null) {
                // a node was created, keep it as a potential root node candidate
                rootNode = addNode(elem);
            }
        }
    }
    // walk to the final root node of the tree
    while (rootNode != null && rootNode.getParent() != null) {
        rootNode = (GenericTreeNode) rootNode.getParent();
    }
    // we always need a root
    if (rootNode == null) {
        rootNode = new GenericTreeNode("keine Node :(", null);
    }
    calculateAccessibility(rootNode);
    return rootNode;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CatalogEntry(org.olat.repository.CatalogEntry)

Example 67 with GenericTreeNode

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

the class QTIStatisticResourceResult method buildQTICourseNodeSubTree.

private void buildQTICourseNodeSubTree(QTIDocument qtiDoc, GenericTreeNode rootNode) {
    for (Section section : qtiDoc.getAssessment().getSections()) {
        GenericTreeNode sectionNode = new SectionNode(section, null);
        sectionNode.setUserObject(section);
        rootNode.addChild(sectionNode);
        for (Item item : section.getItems()) {
            GenericTreeNode itemNode = new ItemNode(item);
            itemNode.setIdent(Long.toString(CodeHelper.getForeverUniqueID()));
            if (sectionNode.getDelegate() == null) {
                sectionNode.setDelegate(itemNode);
            }
            itemNode.setUserObject(item);
            sectionNode.addChild(itemNode);
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Section(org.olat.ims.qti.editor.beecom.objects.Section) SectionNode(org.olat.ims.qti.editor.tree.SectionNode)

Example 68 with GenericTreeNode

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

the class CatalogHelper method buildCatalogNode.

protected static final TreeNode buildCatalogNode(final CatalogEntry rootEntry) {
    final CatalogManager cm = CoreSpringFactory.getImpl(CatalogManager.class);
    List<CatalogEntry> children = cm.getChildrenOf(rootEntry);
    GenericTreeNode ctn = new GenericTreeNode(rootEntry.getName(), rootEntry);
    ctn.setAccessible(true);
    for (int i = 0; i < children.size(); i++) {
        // add child itself
        CatalogEntry cchild = children.get(i);
        if (cchild.getType() == CatalogEntry.TYPE_NODE) {
            TreeNode ctchild = buildCatalogNode(cchild);
            ((GenericTreeNode) ctchild).setAccessible(true);
            ctn.addChild(ctchild);
        }
    }
    return ctn;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) CatalogEntry(org.olat.repository.CatalogEntry) CatalogManager(org.olat.repository.manager.CatalogManager)

Example 69 with GenericTreeNode

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

the class UserAdminMainController method buildTreeModel.

private TreeModel buildTreeModel(UserRequest ureq) {
    boolean isOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    GenericTreeNode gtnChild, admin;
    Translator translator = getTranslator();
    GenericTreeModel gtm = new GenericTreeModel();
    admin = new GenericTreeNode();
    admin.setTitle(translator.translate("menu.useradmin"));
    admin.setUserObject("useradmin");
    admin.setCssClass("o_sel_useradmin");
    admin.setAltText(translator.translate("menu.useradmin.alt"));
    gtm.setRootNode(admin);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.usearch"));
    gtnChild.setUserObject("usearch");
    gtnChild.setCssClass("o_sel_useradmin_search");
    gtnChild.setAltText(translator.translate("menu.usearch.alt"));
    admin.setDelegate(gtnChild);
    admin.addChild(gtnChild);
    Boolean canCreate = BaseSecurityModule.USERMANAGER_CAN_CREATE_USER;
    if (canCreate.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.ucreate"));
        gtnChild.setUserObject("ucreate");
        gtnChild.setCssClass("o_sel_useradmin_create");
        gtnChild.setAltText(translator.translate("menu.ucreate.alt"));
        admin.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.usersimport"));
        gtnChild.setUserObject("usersimport");
        gtnChild.setCssClass("o_sel_useradmin_import");
        gtnChild.setAltText(translator.translate("menu.usersimport.alt"));
        admin.addChild(gtnChild);
    }
    Boolean canDelete = BaseSecurityModule.USERMANAGER_CAN_DELETE_USER;
    if (canDelete.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.userdelete"));
        gtnChild.setUserObject("userdelete");
        gtnChild.setCssClass("o_sel_useradmin_delete");
        gtnChild.setAltText(translator.translate("menu.userdelete.alt"));
        admin.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.userdelete.direct"));
        gtnChild.setUserObject("userdelete_direct");
        gtnChild.setCssClass("o_sel_useradmin_direct_delete");
        gtnChild.setAltText(translator.translate("menu.userdelete.direct.alt"));
        admin.addChild(gtnChild);
    }
    // START submenu access and rights
    GenericTreeNode gtn3 = new GenericTreeNode();
    gtn3.setTitle(translator.translate("menu.menuaccess"));
    gtn3.setUserObject("menuaccess");
    gtn3.setAltText(translator.translate("menu.menuaccess.alt"));
    admin.addChild(gtn3);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.usergroup"));
    gtnChild.setUserObject("usergroup");
    gtnChild.setAltText(translator.translate("menu.usergroup.alt"));
    gtn3.addChild(gtnChild);
    Boolean canAuthors = BaseSecurityModule.USERMANAGER_CAN_MANAGE_AUTHORS;
    if (canAuthors.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.authorgroup"));
        gtnChild.setUserObject("authorgroup");
        gtnChild.setAltText(translator.translate("menu.authorgroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.coauthors"));
        gtnChild.setUserObject("coauthors");
        gtnChild.setAltText(translator.translate("menu.coauthors.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.resourceowners"));
        gtnChild.setUserObject("resourceowners");
        gtnChild.setAltText(translator.translate("menu.resourceowners.alt"));
        gtn3.addChild(gtnChild);
    }
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.coursecoach"));
    gtnChild.setUserObject("coursecoach");
    gtnChild.setAltText(translator.translate("menu.coursecoach.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.courseparticipants"));
    gtnChild.setUserObject("courseparticipants");
    gtnChild.setAltText(translator.translate("menu.courseparticipants.alt"));
    gtn3.addChild(gtnChild);
    Boolean canGroupmanagers = BaseSecurityModule.USERMANAGER_CAN_MANAGE_GROUPMANAGERS;
    if (canGroupmanagers.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.groupmanagergroup"));
        gtnChild.setUserObject("groupmanagergroup");
        gtnChild.setAltText(translator.translate("menu.groupmanagergroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.groupcoach"));
        gtnChild.setUserObject("groupcoach");
        gtnChild.setAltText(translator.translate("menu.groupcoach.alt"));
        gtn3.addChild(gtnChild);
    }
    // admin group and user manager group always restricted to admins
    if (isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.usermanagergroup"));
        gtnChild.setUserObject("usermanagergroup");
        gtnChild.setAltText(translator.translate("menu.usermanagergroup.alt"));
        gtn3.addChild(gtnChild);
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.admingroup"));
        gtnChild.setUserObject("admingroup");
        gtnChild.setAltText(translator.translate("menu.admingroup.alt"));
        gtn3.addChild(gtnChild);
    }
    Boolean canGuests = BaseSecurityModule.USERMANAGER_CAN_MANAGE_GUESTS;
    if (canGuests.booleanValue() || isOlatAdmin) {
        gtnChild = new GenericTreeNode();
        gtnChild.setTitle(translator.translate("menu.anonymousgroup"));
        gtnChild.setUserObject("anonymousgroup");
        gtnChild.setAltText(translator.translate("menu.anonymousgroup.alt"));
        gtn3.addChild(gtnChild);
    }
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.noauthentication"));
    gtnChild.setUserObject("noauthentication");
    gtnChild.setAltText(translator.translate("menu.noauthentication.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.logondeniedgroup"));
    gtnChild.setUserObject("logondeniedgroup");
    gtnChild.setAltText(translator.translate("menu.logondeniedgroup.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.deletedusers"));
    gtnChild.setUserObject("deletedusers");
    gtnChild.setAltText(translator.translate("menu.deletedusers.alt"));
    gtn3.addChild(gtnChild);
    // END submenu access and rights
    // START other queries
    gtn3 = new GenericTreeNode();
    gtn3.setTitle(translator.translate("menu.menuqueries"));
    gtn3.setUserObject("menuqueries");
    gtn3.setAltText(translator.translate("menu.menuqueries.alt"));
    admin.addChild(gtn3);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.userswithoutgroup"));
    gtnChild.setUserObject("userswithoutgroup");
    gtnChild.setAltText(translator.translate("menu.userswithoutgroup.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.users.without.email"));
    gtnChild.setUserObject("userswithoutemail");
    gtnChild.setAltText(translator.translate("menu.users.without.email.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.users.email.duplicate"));
    gtnChild.setUserObject("usersemailduplicates");
    gtnChild.setAltText(translator.translate("menu.users.email.duplicate.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.lastweek"));
    gtnChild.setUserObject("created.lastweek");
    gtnChild.setAltText(translator.translate("menu.created.lastweek.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.lastmonth"));
    gtnChild.setUserObject("created.lastmonth");
    gtnChild.setAltText(translator.translate("menu.created.lastmonth.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.sixmonth"));
    gtnChild.setUserObject("created.sixmonth");
    gtnChild.setAltText(translator.translate("menu.created.sixmonth.alt"));
    gtn3.addChild(gtnChild);
    gtnChild = new GenericTreeNode();
    gtnChild.setTitle(translator.translate("menu.created.newUsersNotification"));
    gtnChild.setUserObject("created.newUsersNotification");
    gtnChild.setAltText(translator.translate("menu.created.newUsersNotification.alt"));
    gtn3.addChild(gtnChild);
    // add extension menues as child items
    ExtManager extm = ExtManager.getInstance();
    int cnt = extm.getExtensionCnt();
    for (int i = 0; i < cnt; i++) {
        Extension anExt = extm.getExtension(i);
        // 1) general menu extensions
        ExtensionElement ee = anExt.getExtensionFor(UserAdminMainController.class.getName() + EXTENSIONPOINT_MENU_MENUQUERIES, ureq);
        if (ee instanceof GenericActionExtension && anExt.isEnabled()) {
            GenericActionExtension ae = (GenericActionExtension) ee;
            gtnChild = new GenericTreeNode();
            String menuText = ae.getActionText(getLocale());
            gtnChild.setTitle(menuText);
            gtnChild.setUserObject(ae);
            gtnChild.setAltText(ae.getDescription(getLocale()));
            gtn3.addChild(gtnChild);
            // inform only once
            if (!extensionLogged) {
                logInfo("added menu entry for locale " + getLocale().toString() + " '" + menuText + "'", null);
            }
        }
    }
    extensionLogged = true;
    // END other queries
    return gtm;
}
Also used : Extension(org.olat.core.extensions.Extension) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Translator(org.olat.core.gui.translator.Translator) ExtManager(org.olat.core.extensions.ExtManager) ExtensionElement(org.olat.core.extensions.ExtensionElement) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericActionExtension(org.olat.core.extensions.action.GenericActionExtension)

Example 70 with GenericTreeNode

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

the class NavigationHandler method addSubTreeModel.

private void addSubTreeModel(TreeNode parent, TreeModel modelToAppend) {
    // ignore root and directly add children.
    // need to clone children so that are not detached from their original
    // parent (which is the cp treemodel)
    // parent.addChild(modelToAppend.getRootNode());
    TreeNode root = modelToAppend.getRootNode();
    int chdCnt = root.getChildCount();
    // full cloning of ETH webclass energie takes about 4/100 of a second
    for (int i = chdCnt; i > 0; i--) {
        INode chd = root.getChildAt(i - 1);
        INode chdc = (INode) XStreamHelper.xstreamClone(chd);
        if (chdc instanceof GenericTreeNode) {
            ((GenericTreeNode) chdc).setIdent(chd.getIdent());
        }
        // always insert before already existing course building block children
        parent.insert(chdc, 0);
    }
    copyIdent(parent, root);
}
Also used : INode(org.olat.core.util.nodes.INode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode)

Aggregations

GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)124 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 CourseNode (org.olat.course.nodes.CourseNode)10 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)10 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 HashMap (java.util.HashMap)8 INode (org.olat.core.util.nodes.INode)8 ArrayList (java.util.ArrayList)6 Element (org.dom4j.Element)6 XPath (org.dom4j.XPath)6 ExtManager (org.olat.core.extensions.ExtManager)6 Extension (org.olat.core.extensions.Extension)6 CatalogEntry (org.olat.repository.CatalogEntry)6 ActionExtension (org.olat.core.extensions.action.ActionExtension)4 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)4 CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)4 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4