use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
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.GenericTreeModel in project openolat by klemens.
the class AssessmentHelper method assessmentTreeModel.
/**
* @param course
* @return
*/
public static TreeModel assessmentTreeModel(ICourse course) {
CourseNode rootNode = course.getRunStructure().getRootNode();
GenericTreeModel gtm = new GenericTreeModel();
GenericTreeNode node = new GenericTreeNode();
node.setTitle(rootNode.getShortTitle());
node.setUserObject(rootNode);
node.setIconCssClass(CourseNodeFactory.getInstance().getCourseNodeConfiguration(rootNode.getType()).getIconCSSClass());
gtm.setRootNode(node);
List<GenericTreeNode> children = addAssessableNodesToList(rootNode);
children.forEach((child) -> node.addChild(child));
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class QTIStatisticResourceResult method getSubTreeModel.
@Override
public TreeModel getSubTreeModel() {
GenericTreeModel subTreeModel;
if (type == QTIType.onyx) {
subTreeModel = new GenericTreeModel();
StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
subTreeModel.setRootNode(rootTreeNode);
} else if (qtiDocument == null) {
subTreeModel = null;
} else {
subTreeModel = new GenericTreeModel();
StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
subTreeModel.setRootNode(rootTreeNode);
buildQTICourseNodeSubTree(qtiDocument, rootTreeNode);
}
return subTreeModel;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class RunMainController method updateTreeAndContent.
private CourseNode updateTreeAndContent(UserRequest ureq, CourseNode calledCourseNode, String nodecmd, List<ContextEntry> entries, StateEntry state) {
// might be used in both controllers with the same ID (e.g. the course folder)
if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
currentNodeController.dispose();
}
NodeClickedRef nclr = navHandler.evaluateJumpToCourseNode(ureq, getWindowControl(), calledCourseNode, this, nodecmd);
if (!nclr.isVisible()) {
// if not root -> fallback to root. e.g. when a direct node jump fails
if (calledCourseNode != null) {
nclr = navHandler.evaluateJumpToCourseNode(ureq, getWindowControl(), null, this, null);
}
if (!nclr.isVisible()) {
MessageController msgController = MessageUIFactory.createInfoMessage(ureq, getWindowControl(), translate("course.noaccess.title"), translate("course.noaccess.text"));
contentP.setContent(msgController.getInitialComponent());
luTree.setTreeModel(new GenericTreeModel());
return null;
}
}
treeModel = nclr.getTreeModel();
luTree.setTreeModel(treeModel);
String selNodeId = nclr.getSelectedNodeId();
luTree.setSelectedNodeId(selNodeId);
luTree.setOpenNodeIds(nclr.getOpenNodeIds());
// get new run controller.
currentNodeController = nclr.getRunController();
addToHistory(ureq, currentNodeController);
if (currentNodeController instanceof TitledWrapperController) {
Controller contentcontroller = ((TitledWrapperController) currentNodeController).getContentController();
addToHistory(ureq, contentcontroller);
if (contentcontroller instanceof Activateable2) {
((Activateable2) contentcontroller).activate(ureq, entries, state);
}
} else if (currentNodeController instanceof Activateable2) {
((Activateable2) currentNodeController).activate(ureq, entries, state);
}
if (currentNodeController != null) {
contentP.setContent(currentNodeController.getInitialComponent());
} else {
MessageController msgCtrl = MessageUIFactory.createWarnMessage(ureq, getWindowControl(), null, translate("msg.nodenotavailableanymore"));
listenTo(msgCtrl);
contentP.setContent(msgCtrl.getInitialComponent());
}
updateNextPrevious();
updateCourseDataAttributes(nclr.getCalledCourseNode());
updateLastUsage(nclr.getCalledCourseNode());
return nclr.getCalledCourseNode();
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class NavigationHandler method evaluateJumpToTreeNode.
/**
* to be called when the users clickes on a node when in the course
*
* @param ureq
* @param wControl
* @param treeModel
* @param treeEvent
* @param listeningController
* @param nodecmd null or a subcmd which activates a node-specific view (e.g. opens a certain uri in a contentpackaging- buildingblock)
* @return the NodeClickedRef
* @return currentNodeController the current node controller that will be dispose before creating the new one
*/
public NodeClickedRef evaluateJumpToTreeNode(UserRequest ureq, WindowControl wControl, TreeModel treeModel, TreeEvent treeEvent, ControllerEventListener listeningController, String nodecmd, Controller currentNodeController) {
NodeClickedRef ncr;
String treeNodeId = treeEvent.getNodeId();
TreeNode selTN = treeModel.getNodeById(treeNodeId);
if (selTN == null) {
selTN = treeModel.getRootNode();
}
if (!selTN.isAccessible()) {
// event to match the new node
if (selTN.getDelegate() != null) {
selTN = selTN.getDelegate();
treeNodeId = selTN.getIdent();
treeEvent = new TreeEvent(MenuTree.COMMAND_TREENODE_CLICKED, treeNodeId);
}
}
// check if appropriate for subtreemodelhandler
Object userObject = selTN.getUserObject();
if (!(userObject instanceof NodeEvaluation)) {
// yes, appropriate
NodeRunConstructionResult nrcr = null;
CourseNode internCourseNode = null;
GenericTreeModel subTreeModel;
ControllerEventListener subtreemodelListener = null;
if (selTN != null) {
TreeNode internNode = getFirstInternParentNode(selTN);
NodeEvaluation prevEval = (NodeEvaluation) internNode.getUserObject();
CourseNode courseNode = prevEval.getCourseNode();
if (externalTreeModels.containsKey(courseNode.getIdent())) {
SubTree subTree = externalTreeModels.get(courseNode.getIdent());
subtreemodelListener = subTree.getTreeModelListener();
}
}
if (subtreemodelListener == null) {
// throw new AssertException("no handler for subtreemodelcall!");
// reattach the subtreemodellistener
TreeNode internNode = getFirstInternParentNode(selTN);
NodeEvaluation prevEval = (NodeEvaluation) internNode.getUserObject();
internCourseNode = prevEval.getCourseNode();
final OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseNode.class, Long.parseLong(internCourseNode.getIdent()));
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
nrcr = internCourseNode.createNodeRunConstructionResult(ureq, bwControl, userCourseEnv, prevEval, nodecmd);
// remember as instance variable for next click
subtreemodelListener = nrcr.getSubTreeListener();
subTreeModel = (GenericTreeModel) nrcr.getSubTreeModel();
externalTreeModels.put(internCourseNode.getIdent(), new SubTree(nrcr.getRunController(), subTreeModel, subtreemodelListener));
} else {
TreeNode internNode = getFirstInternParentNode(selTN);
NodeEvaluation prevEval = (NodeEvaluation) internNode.getUserObject();
internCourseNode = prevEval.getCourseNode();
SubTree subTree = externalTreeModels.get(internCourseNode.getIdent());
subtreemodelListener = subTree.getTreeModelListener();
if (currentNodeController instanceof TitledWrapperController) {
currentNodeController = ((TitledWrapperController) currentNodeController).getContentController();
}
if (subtreemodelListener != currentNodeController) {
if (subtreemodelListener instanceof CPRunController) {
nrcr = ((CPRunController) subtreemodelListener).createNodeRunConstructionResult(ureq, selTN.getIdent());
} else {
nrcr = new NodeRunConstructionResult((Controller) subtreemodelListener);
}
}
subTreeModel = subTree.getTreeModel();
}
if (log.isDebug()) {
log.debug("delegating to handler: treeNodeId = " + treeNodeId);
}
// used in multiple nodes.
if (!selTN.getUserObject().equals(userObject)) {
selTN = subTreeModel.findNodeByUserObject(userObject);
}
treeEvent = new TreeEvent(treeEvent.getCommand(), treeEvent.getSubCommand(), selTN.getIdent());
boolean dispatch = true;
String selectedNodeId = null;
if (userObject instanceof String) {
String sObject = (String) userObject;
if (MenuTree.COMMAND_TREENODE_CLICKED.equals(treeEvent.getCommand()) && treeEvent.getSubCommand() == null) {
openCourseNodeIds.add(sObject);
if (!openTreeNodeIds.contains(sObject)) {
openTreeNodeIds.add(sObject);
}
selectedNodeId = selTN.getIdent();
} else if (TreeEvent.COMMAND_TREENODE_OPEN.equals(treeEvent.getSubCommand())) {
openCourseNodeIds.add(sObject);
if (!openTreeNodeIds.contains(sObject)) {
openTreeNodeIds.add(sObject);
}
selectedNodeId = selTN.getIdent();
dispatch = false;
} else if (TreeEvent.COMMAND_TREENODE_CLOSE.equals(treeEvent.getSubCommand())) {
removeChildrenFromOpenNodes(selTN);
openCourseNodeIds.remove(sObject);
openTreeNodeIds.remove(sObject);
openCourseNodeIds.remove(selTN.getIdent());
openTreeNodeIds.remove(selTN.getIdent());
dispatch = false;
}
}
if (dispatch) {
// null as controller source since we are not a controller
subtreemodelListener.dispatchEvent(ureq, null, treeEvent);
// no node construction result indicates handled
}
ncr = new NodeClickedRef(treeModel, true, selectedNodeId, openTreeNodeIds, internCourseNode, nrcr, true);
} else {
// normal dispatching to a coursenode.
// get the courseNode that was called
NodeEvaluation prevEval = (NodeEvaluation) selTN.getUserObject();
if (!prevEval.isVisible())
throw new AssertException("clicked on a node which is not visible: treenode=" + selTN.getIdent() + ", " + selTN.getTitle());
CourseNode calledCourseNode = prevEval.getCourseNode();
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(calledCourseNode));
// might be used in both controllers with the same ID (e.g. the course folder)
if (TreeEvent.COMMAND_TREENODE_OPEN.equals(treeEvent.getSubCommand()) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(treeEvent.getSubCommand())) {
if (isInParentLine(calledCourseNode)) {
if (currentNodeController != null && !currentNodeController.isDisposed() && !isListening(currentNodeController)) {
currentNodeController.dispose();
}
}
ncr = doEvaluateJumpTo(ureq, wControl, calledCourseNode, listeningController, nodecmd, treeEvent.getSubCommand(), currentNodeController);
} else {
if (currentNodeController != null && !currentNodeController.isDisposed() && !isListening(currentNodeController)) {
currentNodeController.dispose();
}
ncr = doEvaluateJumpTo(ureq, wControl, calledCourseNode, listeningController, nodecmd, treeEvent.getSubCommand(), currentNodeController);
}
}
return ncr;
}
Aggregations