use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class TreeHelper method resolveTreeNode.
public static TreeNode resolveTreeNode(String treePath, TreeModel treeModel) {
// even for the root node, our parameter may not be the empty string, therefore the prefix to be chopped here
treePath = treePath.substring(1);
TreeNode cur = treeModel.getRootNode();
if (!treePath.equals("")) {
// if we are not the root node
String[] res = treePath.split("_");
for (int i = res.length - 1; i >= 0; i--) {
String spos = res[i];
Integer chdPos = Integer.parseInt(spos);
TreeNode chd = (TreeNode) cur.getChildAt(chdPos);
if (chd == null)
throw new AssertException("cannot find: " + treePath);
cur = chd;
}
}
return cur;
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class MergedCourseContainer method init.
protected void init(PersistingCourseImpl persistingCourse) {
super.init();
RepositoryEntry courseRe = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
courseReadOnly = !overrideReadOnly && (courseRe.getRepositoryEntryStatus().isClosed() || courseRe.getRepositoryEntryStatus().isUnpublished());
if (courseReadOnly) {
setLocalSecurityCallback(new ReadOnlyCallback());
}
if (identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
if (courseReadOnly) {
courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
addContainersChildren(courseContainer, true);
} else {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance().isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
if (reSecurity.isEntryAdmin()) {
VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
if (courseReadOnly) {
courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
addContainersChildren(courseContainer, true);
}
}
initSharedFolder(persistingCourse);
// add all course building blocks of type BC to a virtual folder
MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
if (identityEnv == null) {
CourseNode rootNode = persistingCourse.getRunStructure().getRootNode();
addFoldersForAdmin(persistingCourse, nodesContainer, rootNode);
} else {
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, persistingCourse.getCourseEnvironment());
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
addFolders(persistingCourse, nodesContainer, treeRoot);
}
if (nodesContainer.getItems().size() > 0) {
addContainer(nodesContainer);
}
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class ChooseElementsController method getSelectedNames.
public List<String> getSelectedNames() {
Set<String> selectedKeys = selectTree.getSelectedKeys();
List<String> names = new ArrayList<>(selectedKeys.size());
for (String selectedKey : selectedKeys) {
TreeNode node = treeModel.getNodeById(selectedKey);
if (node == null) {
// not published??
} else {
names.add(node.getTitle());
}
}
return names;
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class AssessmentCourseTreeController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == businessGroupListCtrl) {
if (event instanceof CourseNodeEvent) {
CourseNodeEvent cne = (CourseNodeEvent) event;
CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(cne.getIdent());
TreeNode treeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
if (treeNode == null) {
treeNode = menuTree.getTreeModel().getRootNode();
courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getRootNode();
doSelectCourseNode(ureq, treeNode, courseNode);
menuTree.setSelectedNode(treeNode);
showWarning("warning.course.node.deleted");
} else {
stackPanel.changeDisplayname(treeNode.getTitle(), "o_icon " + treeNode.getIconCssClass(), this);
selectedNodeChanged = treeNode;
}
}
}
super.event(ureq, source, event);
}
use of org.olat.core.gui.components.tree.TreeNode in project OpenOLAT by OpenOLAT.
the class AssessmentCourseTreeController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
boolean emptyEntries = entries == null || entries.isEmpty();
if (emptyEntries) {
TreeNode rootNode = menuTree.getTreeModel().getRootNode();
if (rootNode.getUserObject() instanceof CourseNode) {
if (view == null) {
view = View.users;
}
doSelectCourseNode(ureq, rootNode, (CourseNode) rootNode.getUserObject());
menuTree.setSelectedNode(rootNode);
}
} else {
ContextEntry entry = entries.get(0);
String resourceTypeName = entry.getOLATResourceable().getResourceableTypeName();
if ("Identity".equalsIgnoreCase(resourceTypeName)) {
TreeNode treeNode = menuTree.getTreeModel().getRootNode();
CourseNode courseNode = (CourseNode) treeNode.getUserObject();
if (courseNode != null) {
view = View.users;
Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
if (ctrl instanceof Activateable2) {
((Activateable2) ctrl).activate(ureq, entries, null);
}
menuTree.setSelectedNode(treeNode);
}
} else if ("Node".equalsIgnoreCase(resourceTypeName) || "CourseNode".equalsIgnoreCase(resourceTypeName)) {
Long nodeIdent = entries.get(0).getOLATResourceable().getResourceableId();
CourseNode courseNode = CourseFactory.loadCourse(courseEntry).getRunStructure().getNode(nodeIdent.toString());
TreeNode treeNode = TreeHelper.findNodeByUserObject(courseNode, menuTree.getTreeModel().getRootNode());
if (courseNode != null) {
if (view == null) {
view = View.users;
}
Controller ctrl = doSelectCourseNode(ureq, treeNode, courseNode);
if (ctrl instanceof Activateable2) {
List<ContextEntry> subEntries = entries.subList(1, entries.size());
((Activateable2) ctrl).activate(ureq, subEntries, entry.getTransientState());
}
menuTree.setSelectedNode(treeNode);
}
}
}
}
Aggregations