use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class QuestionPoolMainEditorController method activateQuestionItem.
private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
QuestionItem item = qpoolService.loadItemById(itemKey);
if (item == null)
return;
List<Identity> authors = qpoolService.getAuthors(item);
if (authors.contains(getIdentity())) {
activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
return;
}
if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
if (treeModel.getSharesNode() != null) {
List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
for (QuestionItem2Resource share : shares) {
TreeNode levelNode = treeModel.getShareNode(share);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
for (QuestionItem2Pool pool : pools) {
TreeNode levelNode = treeModel.getShareNode(pool);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class QuestionPoolMainEditorController method doSelectControllerTreeNode.
private void doSelectControllerTreeNode(UserRequest ureq, TreeNode node, List<ContextEntry> entries, StateEntry state) {
TreeNode nodeToShow = getDelegate(node);
menuTree.setSelectedNode(nodeToShow);
if (nodeToShow instanceof ControllerTreeNode) {
ControllerTreeNode cNode = (ControllerTreeNode) nodeToShow;
doSelectQuestionsNode(ureq, cNode, entries, state);
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class CatalogEntryAddController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == okButton) {
TreeNode node = selectionTree.getSelectedNode();
if (node != null) {
// no selection is allowed
Long newParentId = Long.parseLong(node.getIdent());
insertNode(ureq, newParentId);
}
} else if (source == cancelButton) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class CourseLinkProviderController method setKalendarEvent.
@Override
public void setKalendarEvent(KalendarEvent kalendarEvent) {
this.kalendarEvent = kalendarEvent;
// clear all selections
clearSelection(courseNodeTreeModel.getRootNode());
multiSelectTree.deselectAll();
for (KalendarEventLink link : kalendarEvent.getKalendarEventLinks()) {
if (link.getProvider().equals(COURSE_LINK_PROVIDER)) {
String nodeId = link.getId();
TreeNode node = courseNodeTreeModel.getNodeById(nodeId);
if (node == null) {
String fallBackNodeId = availableCourses.get(0).getResourceableId() + "_" + nodeId;
node = courseNodeTreeModel.getNodeById(fallBackNodeId);
}
if (node == null && nodeId.indexOf("_") < 0) {
// course selected -> map to root node
for (ICourse course : availableCourses) {
if (nodeId.equals(course.getResourceableId().toString())) {
String fallBackNodeId = course.getResourceableId() + "_" + course.getRunStructure().getRootNode().getIdent();
node = courseNodeTreeModel.getNodeById(fallBackNodeId);
}
}
}
if (node != null) {
node.setSelected(true);
multiSelectTree.select(node.getIdent(), true);
multiSelectTree.open(node);
}
}
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class CourseInternalLinkTreeModel method findNode.
/**
* Depth-first traversal.
*
* @param nodeId
* @param node
* @return the treenode with the node id or null if not found
*/
private TreeNode findNode(String nodeId, TreeNode node) {
if (node.getIdent().equals(nodeId))
return node;
int childcnt = node.getChildCount();
for (int i = 0; i < childcnt; i++) {
TreeNode child = (TreeNode) node.getChildAt(i);
TreeNode result = findNode(nodeId, child);
if (result != null)
return result;
}
return null;
}
Aggregations