Search in sources :

Example 1 with TreeModel

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);
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with 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;
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)

Example 3 with TreeModel

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;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) CourseNode(org.olat.course.nodes.CourseNode)

Example 4 with TreeModel

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");
            }
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) AssertException(org.olat.core.logging.AssertException) TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component)

Example 5 with TreeModel

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;
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) AssertException(org.olat.core.logging.AssertException) AssessmentEvent(org.olat.course.nodes.iq.AssessmentEvent) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Aggregations

TreeModel (org.olat.core.gui.components.tree.TreeModel)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)16 TreeNode (org.olat.core.gui.components.tree.TreeNode)14 ArrayList (java.util.ArrayList)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)8 HashMap (java.util.HashMap)6 List (java.util.List)6 Map (java.util.Map)6 Identity (org.olat.core.id.Identity)6 StringHelper (org.olat.core.util.StringHelper)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 Taxonomy (org.olat.modules.taxonomy.Taxonomy)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 TaxonomyTreeBuilder (org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)6 Date (java.util.Date)4 Locale (java.util.Locale)4 Collectors (java.util.stream.Collectors)4 Component (org.olat.core.gui.components.Component)4 AssertException (org.olat.core.logging.AssertException)4