use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class GenericMainController method activate.
// fxdiff BAKS-7 Resume function
private void activate(UserRequest ureq, String viewIdentifier) {
ActionExtension ae;
if (viewIdentifier != null && viewIdentifier.startsWith(GMCMT)) {
Long extensionID = Long.parseLong(viewIdentifier.substring(viewIdentifier.indexOf(':') + 1));
Extension ee = ExtManager.getInstance().getExtensionByID(extensionID);
if (ee == null) {
logWarn("ExtManager did not find an Extension for extensionID '" + extensionID + "'. Activate canceled...", null);
return;
}
ae = (ActionExtension) ee.getExtensionFor(className, ureq);
} else {
int vwindex = viewIdentifier.lastIndexOf(":");
String naviKey = viewIdentifier;
if (vwindex >= 0) {
naviKey = viewIdentifier.substring(0, viewIdentifier.indexOf(':'));
}
ae = ExtManager.getInstance().getActionExtensioByNavigationKey(className, naviKey);
if (ae == null) {
// this happens, if someone uses a navigation key, that no actionExtension uses...
logWarn("couldn't find an ActionExtension for navigationKey '" + naviKey + "' . I suggest adjusting spring configuration for GenericMainController..", null);
}
}
if (ae == null) {
// no action extension to activate...
return;
}
try {
if (olatMenuTree.getTreeModel() instanceof GenericTreeModel) {
activateTreeNodeByActionExtension(ureq, ae);
} else {
// just for precaution (treenode selection won't work, but correct
// content is displayed)
contentCtr = getContentCtr(ae, ureq);
listenTo(contentCtr);
Component resComp = contentCtr.getInitialComponent();
content.setContent(resComp);
// fxdiff BAKS-7 Resume function
addToHistory(ureq, contentCtr);
}
} catch (Exception e) {
logWarn("", e);
}
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class MembersManagementMainController method buildTreeModel.
private GenericTreeModel buildTreeModel() {
GenericTreeModel gtm = new GenericTreeModel();
GenericTreeNode root = new GenericTreeNode();
root.setTitle(translate("menu.members"));
root.setAltText(translate("menu.members.alt"));
gtm.setRootNode(root);
if (entryAdmin || memberManagementRight) {
GenericTreeNode node = new GenericTreeNode(translate("menu.members"), CMD_MEMBERS);
node.setAltText(translate("menu.members.alt"));
node.setCssClass("o_sel_membersmgt_members");
root.addChild(node);
}
if (entryAdmin || memberManagementRight || groupManagementRight) {
GenericTreeNode node = new GenericTreeNode(translate("menu.groups"), CMD_GROUPS);
node.setAltText(translate("menu.groups.alt"));
node.setCssClass("o_sel_membersmgt_groups");
root.addChild(node);
}
if (acModule.isEnabled() && (entryAdmin || memberManagementRight)) {
// check if the course is managed and/or has offers
if (!RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.bookings) || acService.isResourceAccessControled(repoEntry.getOlatResource(), null)) {
GenericTreeNode node = new GenericTreeNode(translate("menu.orders"), CMD_BOOKING);
node.setAltText(translate("menu.orders.alt"));
node.setCssClass("o_sel_membersmgt_orders");
root.addChild(node);
}
}
if (entryAdmin) {
GenericTreeNode node = new GenericTreeNode(translate("menu.rights"), CMD_RIGHTS);
node.setAltText(translate("menu.rights.alt"));
node.setCssClass("o_sel_membersmgt_rights");
root.addChild(node);
}
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class ArchiverMainController method buildTreeModel.
/**
* Generates the archiver menu
* @return The generated menu tree model
*/
private TreeModel buildTreeModel(UserRequest ureq) {
GenericTreeNode root, gtn;
GenericTreeModel gtm = new GenericTreeModel();
root = new GenericTreeNode();
root.setTitle(translate("menu.index"));
root.setUserObject(CMD_INDEX);
root.setAltText(translate("menu.index.alt"));
gtm.setRootNode(root);
if (archiverCallback.mayArchiveQtiResults()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.qtiresults"));
gtn.setUserObject(CMD_QTISURVRESULTS);
gtn.setAltText(translate("menu.qtiresults.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveQtiTestResults()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.qtitestresults"));
gtn.setUserObject(CMD_QTITESTRESULTS);
gtn.setAltText("menu.qtitestresults.alt");
root.addChild(gtn);
}
if (archiverCallback.mayArchiveProperties()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.scoreaccounting"));
gtn.setUserObject(CMD_SCOREACCOUNTING);
gtn.setAltText(translate("menu.scoreaccounting.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveHandedInTasks()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.handedintasks"));
gtn.setUserObject(CMD_HANDEDINTASKS);
gtn.setAltText(translate("menu.handedintasks.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveHandedInTasks()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.grouptasks"));
gtn.setUserObject(CMD_GROUPTASKS);
gtn.setAltText(translate("menu.grouptasks.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveProjectBroker()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.projectbroker"));
gtn.setUserObject(CMD_PROJECTBROKER);
gtn.setAltText(translate("menu.projectbroker.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveLogfiles()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.archivelogfiles"));
gtn.setUserObject(CMD_ARCHIVELOGFILES);
gtn.setAltText(translate("menu.archivelogfiles.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveForums()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.forums"));
gtn.setUserObject(CMD_FORUMS);
gtn.setAltText(translate("menu.forums.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveDialogs()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.dialogs"));
gtn.setUserObject(CMD_DIALOGS);
gtn.setAltText(translate("menu.dialogs.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveParticipantFolder()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.participantfolder"));
gtn.setUserObject(CMD_PARTICIPANTFOLDER);
gtn.setAltText("menu.participantfolder.alt");
root.addChild(gtn);
}
if (archiverCallback.mayArchiveWikis()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.wikis"));
gtn.setUserObject(CMD_WIKIS);
gtn.setAltText(translate("menu.wikis.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveScorm()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.scorm"));
gtn.setUserObject(CMD_SCORM);
gtn.setAltText(translate("menu.scorm.alt"));
root.addChild(gtn);
}
if (archiverCallback.mayArchiveChecklist()) {
gtn = new GenericTreeNode();
gtn.setTitle(translate("menu.checklist"));
gtn.setUserObject(CMD_CHECKLIST);
gtn.setAltText(translate("menu.checklist.alt"));
root.addChild(gtn);
}
// add extension menues
ExtManager extm = ExtManager.getInstance();
Class extensionPointMenu = this.getClass();
int cnt = extm.getExtensionCnt();
for (int i = 0; i < cnt; i++) {
Extension anExt = extm.getExtension(i);
// check for sites
ActionExtension ae = (ActionExtension) anExt.getExtensionFor(extensionPointMenu.getName(), ureq);
if (ae != null && anExt.isEnabled()) {
gtn = new GenericTreeNode();
String menuText = ae.getActionText(locale);
gtn.setTitle(menuText);
gtn.setUserObject(ae);
gtn.setAltText(ae.getDescription(locale));
root.addChild(gtn);
// inform only once
if (!extensionLogged) {
extensionLogged = true;
}
}
}
return gtm;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class NavigationHandler method doEvaluateJumpTo.
private NodeClickedRef doEvaluateJumpTo(UserRequest ureq, WindowControl wControl, CourseNode courseNode, ControllerEventListener listeningController, String nodecmd, String nodeSubCmd, Controller currentNodeController) {
NodeClickedRef nclr;
if (log.isDebug()) {
log.debug("evaluateJumpTo courseNode = " + courseNode.getIdent() + ", " + courseNode.getShortName());
}
// build the new treemodel by evaluating the preconditions
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, filter);
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
// find the treenode that corresponds to the node (!= selectedTreeNode since
// we built the TreeModel anew in the meantime
TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
if (newCalledTreeNode == null) {
// the clicked node is not visible anymore!
// if the new calculated model does not contain the selected node anymore
// (because of visibility changes of at least one of the ancestors
// -> issue an user infomative msg
// nclr: the new treemodel, not visible, no selected nodeid, no
// calledcoursenode, no nodeconstructionresult
nclr = new NodeClickedRef(treeModel, false, null, null, null, null, false);
} else {
// calculate the NodeClickedRef
// 1. get the correct (new) nodeevaluation
NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
if (nodeEval.getCourseNode() != courseNode) {
throw new AssertException("error in structure");
}
if (!nodeEval.isVisible()) {
throw new AssertException("node eval not visible!!");
}
// 2. start with the current NodeEvaluation, evaluate overall accessiblity
// per node bottom-up to see if all ancestors still grant access to the
// desired node
boolean mayAccessWholeTreeUp = mayAccessWholeTreeUp(nodeEval);
String newSelectedNodeId = newCalledTreeNode.getIdent();
Controller controller;
AdditionalConditionManager addMan = null;
if (courseNode instanceof AbstractAccessableCourseNode) {
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance();
Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
AdditionalConditionAnswerContainer answerContainer = cnpm.getAnswerContainer(identity);
addMan = new AdditionalConditionManager((AbstractAccessableCourseNode) courseNode, courseId, answerContainer);
}
if (!mayAccessWholeTreeUp || (addMan != null && !addMan.evaluateConditions())) {
if (nodeEval.oldStyleConditionsOk()) {
controller = addMan.nextUserInputController(ureq, wControl, userCourseEnv);
if (listeningController != null) {
controller.addControllerListener(listeningController);
}
} else {
// NOTE: we do not take into account what node caused the non-access by
// being !isAtLeastOneAccessible, but always state the
// NoAccessExplanation of the Node originally called by the user
String explan = courseNode.getNoAccessExplanation();
String sExplan = (explan == null ? "" : Formatter.formatLatexFormulas(explan));
controller = MessageUIFactory.createInfoMessage(ureq, wControl, null, sExplan);
// write log information
ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_NAVIGATION_NODE_NO_ACCESS, getClass(), LoggingResourceable.wrap(courseNode));
}
NodeRunConstructionResult ncr = new NodeRunConstructionResult(controller, null, null, null);
// nclr: the new treemodel, visible, selected nodeid, calledcoursenode,
// nodeconstructionresult
nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false);
} else if (!CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType()).isEnabled()) {
Translator pT = Util.createPackageTranslator(EditorMainController.class, ureq.getLocale());
controller = MessageUIFactory.createInfoMessage(ureq, wControl, null, pT.translate("course.building.block.disabled.user"));
NodeRunConstructionResult ncr = new NodeRunConstructionResult(controller, null, null, null);
nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false);
} else {
if (STCourseNode.isDelegatingSTCourseNode(courseNode) && (courseNode.getChildCount() > 0)) {
// the clicked node is a STCourse node and is set to "delegate", so
// delegate to its first visible child; if no child is visible, just skip and do normal eval
INode child;
for (int i = 0; i < courseNode.getChildCount(); i++) {
child = courseNode.getChildAt(i);
if (child instanceof CourseNode) {
CourseNode cn = (CourseNode) child;
NodeEvaluation cnEval = cn.eval(userCourseEnv.getConditionInterpreter(), treeEval, filter);
if (cnEval.isVisible()) {
return doEvaluateJumpTo(ureq, wControl, cn, listeningController, nodecmd, nodeSubCmd, currentNodeController);
}
}
}
}
// access the node, display its result in the right pane
NodeRunConstructionResult ncr;
// calculate the new businesscontext for the coursenode being called.
// type: class of node; key = node.getIdent;
// don't use the concrete instance since for the course: to jump to a coursenode with a given id is all there is to know
Class<CourseNode> oresC = CourseNode.class;
Long oresK = new Long(Long.parseLong(courseNode.getIdent()));
final OLATResourceable ores = OresHelper.createOLATResourceableInstance(oresC, oresK);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
if (previewMode) {
ncr = new NodeRunConstructionResult(courseNode.createPreviewController(ureq, bwControl, userCourseEnv, nodeEval));
} else {
// cleanup already existing controllers with external models for this node first, never disposed otherwise
if (externalTreeModels.containsKey(courseNode.getIdent()) && !(TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd))) {
SubTree subTree = externalTreeModels.get(courseNode.getIdent());
ControllerEventListener existingSubtreemodelListener = subTree.getTreeModelListener();
if (existingSubtreemodelListener != null && currentNodeController != null && !currentNodeController.isDisposed()) {
currentNodeController.dispose();
}
}
ncr = courseNode.createNodeRunConstructionResult(ureq, bwControl, userCourseEnv, nodeEval, nodecmd);
// remember as instance variable for next click
ControllerEventListener subtreemodelListener = ncr.getSubTreeListener();
if (subtreemodelListener != null) {
GenericTreeModel subTreeModel = (GenericTreeModel) ncr.getSubTreeModel();
externalTreeModels.put(courseNode.getIdent(), new SubTree(ncr.getRunController(), subTreeModel, subtreemodelListener));
if (!newSelectedNodeId.equals(ncr.getSelectedTreeNodeId())) {
if (ncr.getSelectedTreeNodeId() != null) {
TreeNode selectedNode = subTreeModel.getNodeById(ncr.getSelectedTreeNodeId());
if (selectedNode != null && selectedNode.getUserObject() instanceof String) {
openCourseNodeIds.add((String) selectedNode.getUserObject());
}
}
}
}
}
if (TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd)) {
openCourseNodeIds.add(courseNode.getIdent());
newSelectedNodeId = convertToTreeNodeId(treeEval, selectedCourseNodeId);
} else if (TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd)) {
removeChildrenFromOpenNodes(courseNode);
newSelectedNodeId = convertToTreeNodeId(treeEval, selectedCourseNodeId);
if (!isInParentLine(courseNode)) {
selectedCourseNodeId = courseNode.getIdent();
} else {
selectedCourseNodeId = null;
newSelectedNodeId = null;
}
} else {
// add the selected node to the open one, if not, strange behaviour
selectedCourseNodeId = courseNode.getIdent();
openCourseNodeIds.add(selectedCourseNodeId);
if (ncr != null) {
String subNodeId = ncr.getSelectedTreeNodeId();
if (subNodeId != null) {
openCourseNodeIds.add(subNodeId);
}
}
}
openTreeNodeIds = convertToTreeNodeIds(treeEval, openCourseNodeIds);
reattachExternalTreeModels(treeEval);
if ((TreeEvent.COMMAND_TREENODE_OPEN.equals(nodeSubCmd) || TreeEvent.COMMAND_TREENODE_CLOSE.equals(nodeSubCmd)) && currentNodeController != null && !currentNodeController.isDisposed()) {
nclr = new NodeClickedRef(treeModel, true, null, openTreeNodeIds, null, null, false);
} else {
// nclr: the new treemodel, visible, selected nodeid, calledcoursenode,
// nodeconstructionresult
nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, openTreeNodeIds, courseNode, ncr, false);
// attach listener; we know we have a runcontroller here
if (listeningController != null) {
nclr.getRunController().addControllerListener(listeningController);
}
}
// write log information
ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_NAVIGATION_NODE_ACCESS, getClass(), LoggingResourceable.wrap(courseNode));
}
}
return nclr;
}
use of org.olat.core.gui.components.tree.GenericTreeModel in project openolat by klemens.
the class NavigationHandler method reloadTreeAfterChanges.
public NodeClickedRef reloadTreeAfterChanges(CourseNode courseNode) {
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, filter);
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
TreeNode treeNode = treeEval.getCorrespondingTreeNode(courseNode.getIdent());
NodeClickedRef nclr;
if (treeNode == null) {
nclr = null;
} else {
Object uObject = treeNode.getUserObject();
if (uObject instanceof NodeEvaluation) {
NodeEvaluation nodeEval = (NodeEvaluation) uObject;
ControllerEventListener subtreemodelListener = null;
if (externalTreeModels.containsKey(courseNode.getIdent())) {
SubTree subTree = externalTreeModels.get(courseNode.getIdent());
subtreemodelListener = subTree.getTreeModelListener();
reattachExternalTreeModels(treeEval);
}
openTreeNodeIds = convertToTreeNodeIds(treeEval, openCourseNodeIds);
selectedCourseNodeId = nodeEval.getCourseNode().getIdent();
if (subtreemodelListener == null) {
nclr = new NodeClickedRef(treeModel, true, selectedCourseNodeId, openTreeNodeIds, nodeEval.getCourseNode(), null, false);
} else {
nclr = new NodeClickedRef(treeModel, true, selectedCourseNodeId, openTreeNodeIds, nodeEval.getCourseNode(), null, true);
}
} else {
nclr = null;
}
}
return nclr;
}
Aggregations