use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class ScormAPIandDisplayController method switchToNextOrPreviousSco.
private void switchToNextOrPreviousSco(Link link) {
String nextScoId = (String) link.getUserObject();
GenericTreeNode tn = (GenericTreeNode) treeModel.getNodeByScormItemId(nextScoId);
menuTree.setSelectedNodeId(tn.getIdent());
iframectr.getInitialComponent().setVisible(true);
String identifierRes = (String) tn.getUserObject();
updateNextPreviousButtons(nextScoId);
displayMessages(nextScoId, identifierRes);
updateMenuTreeIconsAndMessages();
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class ScormAPIandDisplayController method updateMenuTreeIconsAndMessages.
private void updateMenuTreeIconsAndMessages() {
menuTree.setDirty(true);
Map<String, String> itemsStat = scormAdapter.getScoItemsStatus();
Map<String, GenericTreeNode> idToNode = treeModel.getScormIdToNodeRelation();
for (Iterator<String> it = itemsStat.keySet().iterator(); it.hasNext(); ) {
String itemId = it.next();
GenericTreeNode tn = idToNode.get(itemId);
// change icon decorator
tn.setIconDecorator1CssClass("o_scorm_" + itemsStat.get(itemId));
}
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class TaxonomyAllTreesBuilder method loadTreeModel.
private void loadTreeModel(Map<Taxonomy, GenericTreeNode> rootNodesMap, Taxonomy taxonomy) {
List<TaxonomyLevel> taxonomyLevels = taxonomyService.getTaxonomyLevels(taxonomy);
Map<Long, GenericTreeNode> fieldKeyToNode = new HashMap<Long, GenericTreeNode>();
for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
Long key = taxonomyLevel.getKey();
GenericTreeNode node = fieldKeyToNode.get(key);
if (node == null) {
node = new GenericTreeNode(nodeKey(taxonomyLevel));
node.setTitle(taxonomyLevel.getDisplayName());
node.setIconCssClass("o_icon_taxonomy_level");
node.setUserObject(taxonomyLevel);
fieldKeyToNode.put(key, node);
}
TaxonomyLevel parentLevel = taxonomyLevel.getParent();
if (parentLevel == null) {
// this is a root
GenericTreeNode taxonomyNode = rootNodesMap.get(taxonomyLevel.getTaxonomy());
taxonomyNode.addChild(node);
} else {
Long parentKey = parentLevel.getKey();
GenericTreeNode parentNode = fieldKeyToNode.get(parentKey);
if (parentNode == null) {
parentNode = new GenericTreeNode("level-" + parentLevel.getKey());
parentNode.setTitle(parentLevel.getDisplayName());
parentNode.setIconCssClass("o_icon_taxonomy_level");
parentNode.setUserObject(parentLevel);
fieldKeyToNode.put(parentKey, parentNode);
}
parentNode.addChild(node);
}
}
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class TaxonomyAllTreesBuilder method toTree.
public List<TaxonomyLevelRow> toTree(List<TaxonomyLevelRow> taxonomyLevels) {
GenericTreeNode rootNode = new GenericTreeNode();
Map<Long, GenericTreeNode> fieldKeyToNode = new HashMap<Long, GenericTreeNode>();
for (TaxonomyLevelRow taxonomyLevel : taxonomyLevels) {
Long key = taxonomyLevel.getKey();
GenericTreeNode node = fieldKeyToNode.get(key);
if (node == null) {
node = new GenericTreeNode(nodeKey(taxonomyLevel));
node.setUserObject(taxonomyLevel);
fieldKeyToNode.put(key, node);
}
TaxonomyLevelRow parentLevel = taxonomyLevel.getParent();
if (parentLevel == null) {
// this is a root
rootNode.addChild(node);
} else {
Long parentKey = parentLevel.getKey();
GenericTreeNode parentNode = fieldKeyToNode.get(parentKey);
if (parentNode == null) {
parentNode = new GenericTreeNode("level-" + parentLevel.getKey());
parentNode.setUserObject(parentLevel);
fieldKeyToNode.put(parentKey, parentNode);
}
parentNode.addChild(node);
}
}
List<TreeNode> nodeList = new ArrayList<>();
TreeHelper.makeTreeFlat(rootNode, nodeList);
List<TaxonomyLevelRow> sortedRows = new ArrayList<>();
for (TreeNode node : nodeList) {
if (node.getUserObject() != null) {
sortedRows.add((TaxonomyLevelRow) node.getUserObject());
}
}
return sortedRows;
}
use of org.olat.core.gui.components.tree.GenericTreeNode in project openolat by klemens.
the class TaxonomyAllTreesBuilder method loadTreeModel.
public void loadTreeModel(GenericTreeModel taxonomyTreesModel) {
List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
GenericTreeNode rootNode = new GenericTreeNode("Root", ROOT);
taxonomyTreesModel.setRootNode(rootNode);
Map<Taxonomy, GenericTreeNode> rootNodesMap = new HashMap<>();
for (Taxonomy taxonomy : taxonomyList) {
GenericTreeNode node = new GenericTreeNode("taxonomy-" + taxonomy.getKey());
node.setTitle(taxonomy.getDisplayName());
node.setIconCssClass("o_icon_taxonomy");
node.setUserObject(taxonomy);
rootNode.addChild(node);
rootNodesMap.put(taxonomy, node);
}
loadTreeModel(rootNodesMap, null);
}
Aggregations