Search in sources :

Example 86 with GenericTreeNode

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

the class CatalogTreeModel method addNode.

/**
 * Create and add a node to the tree
 * @param entry
 * @return
 */
private GenericTreeNode addNode(CatalogEntry entry) {
    GenericTreeNode node = entryMap.get(entry.getKey());
    if (node == null && entry.getType() == CatalogEntry.TYPE_NODE) {
        if (entry.getParent() != null) {
            node = entryMap.get(entry.getParent().getKey());
            if (node != null) {
                GenericTreeNode build = buildNode(entry);
                node.addChild(build);
                build.setParent(node);
            } else {
                addMissingNodes(entry);
            }
        } else {
            // it's the root
            node = buildNode(entry);
        }
    }
    return node;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode)

Example 87 with GenericTreeNode

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

the class CatalogTreeModel method addMissingNodes.

/**
 * Create the parent and child nodes that are not yet in the entry map
 *
 * @param fault
 */
private void addMissingNodes(CatalogEntry fault) {
    GenericTreeNode branch = null;
    GenericTreeNode helper = null;
    while (fault != null) {
        if (entryMap.get(fault.getKey()) == null) {
            GenericTreeNode build = buildNode(fault);
            if (// in case of catalog root
            fault.getParent() != null)
                branch = entryMap.get(fault.getParent().getKey());
            if (helper != null) {
                helper.setParent(build);
                build.addChild(helper);
            }
            if (branch != null) {
                build.setParent(branch);
                branch.addChild(build);
                return;
            }
            helper = build;
        }
        fault = fault.getParent();
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode)

Example 88 with GenericTreeNode

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

the class MoveTaxonomyLevelController method filterByAllowedTypes.

private boolean filterByAllowedTypes(TreeNode node, List<TreeNode> openedNodes) {
    ((GenericTreeNode) node).setIconCssClass(null);
    for (int i = node.getChildCount(); i-- > 0; ) {
        boolean ok = filterByAllowedTypes((TreeNode) node.getChildAt(i), openedNodes);
        if (!ok) {
            node.remove(node.getChildAt(i));
        }
    }
    boolean ok = false;
    Object uobject = node.getUserObject();
    if (uobject instanceof TaxonomyLevel) {
        TaxonomyLevel level = (TaxonomyLevel) uobject;
        TaxonomyLevelType type = level.getType();
        if (type == null || allowedTypes.contains(type)) {
            openedNodes.add(node);
            ((GenericTreeNode) node).setIconCssClass("o_icon_node_under o_icon-rotate-180");
            targetableNodes.add(node);
            ok = true;
        } else if (node.getChildCount() > 0) {
            openedNodes.add(node);
            ok = true;
        }
    } else {
        targetableNodes.add(node);
        openedNodes.add(node);
        ok = true;
    }
    return ok;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType)

Example 89 with GenericTreeNode

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

the class UserInfoMainController method buildTreeModel.

/**
 * Generates the archiver menu
 *
 * @return The generated menu tree model
 * @param firstLastName
 */
private GenericTreeModel buildTreeModel(String name) {
    GenericTreeNode root, gtn;
    GenericTreeModel gtm = new GenericTreeModel();
    root = new GenericTreeNode();
    root.setTitle(name);
    root.setAltText(name);
    root.setAccessible(false);
    gtm.setRootNode(root);
    gtn = new GenericTreeNode();
    gtn.setTitle(translate("menu.homepage"));
    gtn.setUserObject(CMD_HOMEPAGE);
    gtn.setAltText(translate("menu.homepage.alt"));
    root.addChild(gtn);
    // following user info elements are only shown for undeleted and real
    // users (not invited
    // eportfolio users)
    boolean isInvitee = invitationDao.isInvitee(chosenIdentity);
    boolean isDeleted = chosenIdentity.getStatus().equals(Identity.STATUS_DELETED);
    if (!isDeleted && !isInvitee) {
        if (calendarModule.isEnablePersonalCalendar()) {
            gtn = new GenericTreeNode();
            gtn.setTitle(translate("menu.calendar"));
            gtn.setUserObject(CMD_CALENDAR);
            gtn.setAltText(translate("menu.calendar.alt"));
            gtn.setCssClass("o_visiting_card_calendar");
            root.addChild(gtn);
        }
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.folder"));
        gtn.setUserObject(CMD_FOLDER);
        gtn.setAltText(translate("menu.folder.alt"));
        gtn.setCssClass("o_visiting_card_folder");
        root.addChild(gtn);
    }
    if (!isDeleted) {
        gtn = new GenericTreeNode();
        gtn.setTitle(translate("menu.contact"));
        gtn.setUserObject(CMD_CONTACT);
        gtn.setAltText(translate("menu.contact.alt"));
        gtn.setCssClass("o_visiting_card_contact");
        root.addChild(gtn);
    }
    if (!isDeleted && !isInvitee) {
        PortfolioModule portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule");
        if (portfolioModule.isEnabled()) {
            gtn = new GenericTreeNode();
            gtn.setTitle(translate("menu.portfolio"));
            gtn.setUserObject(CMD_PORTFOLIO);
            gtn.setAltText(translate("menu.portfolio.alt"));
            gtn.setCssClass("o_visiting_card_portfolio");
            root.addChild(gtn);
        }
    }
    return gtm;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) PortfolioModule(org.olat.portfolio.PortfolioModule)

Example 90 with GenericTreeNode

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

the class TaxonomyTreeNodeComparator method compare.

@Override
public int compare(INode i1, INode i2) {
    if (i1 == null || i2 == null) {
        return compareNullObjects(i1, i2);
    }
    Integer s1 = null;
    Integer s2 = null;
    String title1 = null;
    String title2 = null;
    TaxonomyTreeNodeType type1 = null;
    TaxonomyTreeNodeType type2 = null;
    if (i1 instanceof TaxonomyTreeNode) {
        TaxonomyTreeNode t1 = (TaxonomyTreeNode) i1;
        title1 = t1.getTitle();
        type1 = t1.getType();
        if (t1.getTaxonomyLevel() != null) {
            s1 = t1.getTaxonomyLevel().getSortOrder();
        }
    } else if (i1 instanceof GenericTreeNode) {
        GenericTreeNode node = (GenericTreeNode) i1;
        title1 = node.getTitle();
        Object uobject = node.getUserObject();
        if (uobject instanceof TaxonomyLevel) {
            TaxonomyLevel level = (TaxonomyLevel) uobject;
            type1 = TaxonomyTreeNodeType.taxonomyLevel;
            s1 = level.getSortOrder();
        }
    }
    if (i2 instanceof TaxonomyTreeNode) {
        TaxonomyTreeNode t2 = (TaxonomyTreeNode) i2;
        title2 = t2.getTitle();
        type2 = t2.getType();
        if (t2.getTaxonomyLevel() != null) {
            s2 = t2.getTaxonomyLevel().getSortOrder();
        }
    } else if (i1 instanceof GenericTreeNode) {
        GenericTreeNode node = (GenericTreeNode) i2;
        title2 = node.getTitle();
        Object uobject = node.getUserObject();
        if (uobject instanceof TaxonomyLevel) {
            TaxonomyLevel level = (TaxonomyLevel) uobject;
            type2 = TaxonomyTreeNodeType.taxonomyLevel;
            s2 = level.getSortOrder();
        }
    }
    int c = 0;
    if (type1 == TaxonomyTreeNodeType.templates && type2 == TaxonomyTreeNodeType.templates) {
        c = 0;
    } else if (type1 == TaxonomyTreeNodeType.templates) {
        return -1;
    } else if (type2 == TaxonomyTreeNodeType.templates) {
        return 1;
    }
    if (type1 == TaxonomyTreeNodeType.lostAndFound && type2 == TaxonomyTreeNodeType.lostAndFound) {
        c = 0;
    } else if (type1 == TaxonomyTreeNodeType.lostAndFound) {
        return 1;
    } else if (type2 == TaxonomyTreeNodeType.lostAndFound) {
        return -1;
    }
    if (c == 0) {
        if (s1 == null || s2 == null) {
            c = compareNullObjects(s1, s2);
        } else {
            c = s1.compareTo(s2);
        }
    }
    if (c == 0) {
        if (title1 == null || title2 == null) {
            c = compareNullObjects(title1, title2);
        } else {
            c = title1.compareTo(title2);
        }
    }
    return c;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

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