use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class NavigationHandler method reattachExternalTreeModels.
private void reattachExternalTreeModels(TreeEvaluation treeEval) {
if (externalTreeModels == null || externalTreeModels.isEmpty())
return;
for (Map.Entry<String, SubTree> entry : externalTreeModels.entrySet()) {
String courseNodeId = entry.getKey();
SubTree subTree = entry.getValue();
TreeModel treeModel = subTree.getTreeModel();
CourseNode courseNode = userCourseEnv.getCourseEnvironment().getRunStructure().getNode(courseNodeId);
TreeNode treeNode = treeEval.getCorrespondingTreeNode(courseNode);
if (treeNode != null) {
addSubTreeModel(treeNode, treeModel);
}
}
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelLibraryIndexer method checkAccess.
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
if (roles.isOLATAdmin())
return true;
if ("TaxonomyLevel".equals(contextEntry.getOLATResourceable().getResourceableTypeName())) {
Long levelKey = contextEntry.getOLATResourceable().getResourceableId();
TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelKey));
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(level.getTaxonomy(), identity, null, false, true, "Templates", null);
TreeModel model = builder.buildTreeModel();
List<TreeNode> flat = new ArrayList<>();
TreeHelper.makeTreeFlat(model.getRootNode(), flat);
for (TreeNode node : flat) {
TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
if (taxonomyNode.getType() == TaxonomyTreeNodeType.taxonomyLevel && level.equals(taxonomyNode.getTaxonomyLevel())) {
if (taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
return true;
}
}
}
}
return false;
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class StatisticCourseNodesController method buildTreeModel.
private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
final GenericTreeModel gtm = new GenericTreeModel();
final GenericTreeNode rootTreeNode = new GenericTreeNode();
rootTreeNode.setTitle("start");
gtm.setRootNode(rootTreeNode);
ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
CourseNode courseNode = (CourseNode) node;
StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
if (result != null) {
StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
rootTreeNode.addChild(courseNodeTreeNode);
TreeModel subTreeModel = result.getSubTreeModel();
if (subTreeModel != null) {
TreeNode subRootNode = subTreeModel.getRootNode();
List<INode> subNodes = new ArrayList<>();
for (int i = 0; i < subRootNode.getChildCount(); i++) {
subNodes.add(subRootNode.getChildAt(i));
}
for (INode subNode : subNodes) {
courseNodeTreeNode.addChild(subNode);
}
}
}
}
}, course.getRunStructure().getRootNode(), true).visitAll();
return gtm;
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == bgEditCntrllr) {
// changes from the admin controller
if (event == Event.CHANGED_EVENT) {
businessGroup = bgEditCntrllr.getBusinessGroup();
chatAvailable = isChatAvailable();
TreeModel trMdl = buildTreeModel();
bgTree.setTreeModel(trMdl);
bgTree.setSelectedNode(nodeAdmin);
} else if (event == Event.CANCELLED_EVENT) {
// could not get lock on business group, back to inital screen
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == resourcesCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
RepositoryTableModel repoTableModel = (RepositoryTableModel) resourcesCtr.getTableDataModel();
if (RepositoryTableModel.TABLE_ACTION_SELECT_LINK.equals(actionid)) {
RepositoryEntry currentRepoEntry = repoTableModel.getObject(rowid);
OLATResource ores = currentRepoEntry.getOlatResource();
if (ores == null)
throw new AssertException("repoEntry had no olatresource, repoKey = " + currentRepoEntry.getKey());
addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.genRepoEntry));
String businessPath = "[RepositoryEntry:" + currentRepoEntry.getKey() + "]";
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
}
}
} else if (source == sendToChooserForm) {
if (event == Event.DONE_EVENT) {
removeAsListenerAndDispose(collabToolCtr);
collabToolCtr = createContactFormController(ureq);
listenTo(collabToolCtr);
mainPanel.setContent(collabToolCtr.getInitialComponent());
} else if (event == Event.CANCELLED_EVENT) {
// back to group overview
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == collabToolCtr) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.BACK_EVENT || event == Event.FAILED_EVENT) {
// In all cases (success or failure) we
// go back to the group overview page.
bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
mainPanel.setContent(main);
}
} else if (source == accessController) {
if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
removeAsListenerAndDispose(accessController);
accessController = null;
// check if on waiting list
List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupMembership(Collections.singletonList(businessGroup.getKey()), getIdentity());
if (isOnWaitinglist(memberships)) {
Component cmp = getOnWaitingListMessage(ureq, businessGroup);
mainPanel.setContent(cmp);
} else {
mainPanel.setContent(main);
bgTree.setTreeModel(buildTreeModel());
needActivation = false;
}
} else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
String msg = ((AccessEvent) event).getMessage();
if (StringHelper.containsNonWhitespace(msg)) {
getWindowControl().setError(msg);
} else {
showError("error.accesscontrol");
}
}
}
}
use of org.olat.core.gui.components.tree.TreeModel in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method event.
/**
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/
@Override
public void event(Event event) {
if (event instanceof OLATResourceableJustBeforeDeletedEvent) {
OLATResourceableJustBeforeDeletedEvent delEvent = (OLATResourceableJustBeforeDeletedEvent) event;
if (!delEvent.targetEquals(businessGroup)) {
throw new AssertException("receiving a delete event for a olatres we never registered for!!!:" + delEvent.getDerivedOres());
}
dispose();
} else if (event instanceof BusinessGroupModifiedEvent) {
BusinessGroupModifiedEvent bgmfe = (BusinessGroupModifiedEvent) event;
if (event.getCommand().equals(BusinessGroupModifiedEvent.CONFIGURATION_MODIFIED_EVENT)) {
// reset business group property manager
// update reference to update business group object
businessGroup = businessGroupService.loadBusinessGroup(businessGroup);
chatAvailable = isChatAvailable();
main.contextPut("BuddyGroup", businessGroup);
TreeModel trMdl = buildTreeModel();
bgTree.setTreeModel(trMdl);
if (bgEditCntrllr == null) {
// change didn't origin by our own edit controller
showInfo("grouprun.configurationchanged");
bgTree.setSelectedNodeId(trMdl.getRootNode().getIdent());
mainPanel.setContent(main);
} else {
// Activate edit menu item
bgTree.setSelectedNodeId(ACTIVITY_MENUSELECT_ADMINISTRATION);
}
} else if (bgmfe.wasMyselfRemoved(getIdentity()) && !wildcard && !isGroupsAdmin) {
// nothing more here!! The message will be created and displayed upon disposing
// disposed message controller will be set
dispose();
}
} else if (event instanceof AssessmentEvent) {
if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STARTED)) {
groupRunDisabled = true;
} else if (((AssessmentEvent) event).getEventType().equals(AssessmentEvent.TYPE.STOPPED)) {
groupRunDisabled = false;
}
}
}
Aggregations