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;
}
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());
}
}
}
}
Aggregations