Search in sources :

Example 21 with TaxonomyTreeNode

use of org.olat.modules.taxonomy.model.TaxonomyTreeNode 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)

Example 22 with TaxonomyTreeNode

use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project openolat by klemens.

the class DocumentPoolMainController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (taxonomyTree == source) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                TaxonomyTreeNode node = (TaxonomyTreeNode) taxonomyTree.getTreeModel().getNodeById(te.getNodeId());
                doSelect(ureq, node);
            }
        }
    } else if (content == source) {
        if (event instanceof PopEvent) {
            PopEvent popEvent = (PopEvent) event;
            if (popEvent.getController() instanceof DocumentPoolLevelController) {
                DocumentPoolLevelController taxonomyLevelCtrl = (DocumentPoolLevelController) popEvent.getController();
                TaxonomyLevel level = taxonomyLevelCtrl.getTaxonomyLevel();
                TaxonomyTreeNode node = (TaxonomyTreeNode) TreeHelper.findNodeByUserObject(level, taxonomyTree.getTreeModel().getRootNode());
                TaxonomyTreeNode parentNode = (TaxonomyTreeNode) node.getParent();
                if (parentNode == null) {
                    doSelectTaxonomy(ureq);
                    taxonomyTree.setSelectedNode(taxonomyTree.getTreeModel().getRootNode());
                } else {
                    doSelect(ureq, parentNode);
                    taxonomyTree.setSelectedNode(parentNode);
                }
            } else if (popEvent.getUserObject() instanceof TaxonomyTreeNode) {
                TaxonomyTreeNode node = (TaxonomyTreeNode) popEvent.getUserObject();
                doSelect(ureq, node);
                taxonomyTree.setSelectedNode(node);
            } else if (popEvent.getController() instanceof DocumentDirectoryController) {
                // pop the templates
                taxonomyTree.setSelectedNode(taxonomyTree.getTreeModel().getRootNode());
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) PopEvent(org.olat.core.gui.components.stack.PopEvent)

Aggregations

TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)22 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)12 List (java.util.List)8 ArrayList (java.util.ArrayList)6 TreeModel (org.olat.core.gui.components.tree.TreeModel)6 TreeNode (org.olat.core.gui.components.tree.TreeNode)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 TaxonomyTreeNodeType (org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)6 Date (java.util.Date)4 Locale (java.util.Locale)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 Identity (org.olat.core.id.Identity)4 StringHelper (org.olat.core.util.StringHelper)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)4 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)4 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)4 TaxonomyTreeBuilder (org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2