Search in sources :

Example 1 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class GenericActionExtension method createMenuNode.

/**
 * @see org.olat.core.extensions.action.ActionExtension#createMenuNode(org.olat.core.gui.UserRequest)
 */
public GenericTreeNode createMenuNode(UserRequest ureq) {
    GenericTreeNode node = new GenericTreeNode();
    node.setAltText(getDescription(ureq.getLocale()));
    node.setTitle(getActionText(ureq.getLocale()));
    node.setIconCssClass(getIconCssClass());
    node.setCssClass(getCssClass());
    node.setUserObject(this);
    return node;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode)

Example 2 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class FolderTreeModel method buildTree.

private boolean buildTree(TreeNode tParent, VFSContainer parentContainer, String parentPath) {
    List<VFSItem> children = parentContainer.getItems(fileFilter);
    if (children.size() == 0)
        return false;
    // sort the children
    Collections.sort(children, new Comparator<VFSItem>() {

        final Collator c = collator;

        public int compare(final VFSItem o1, final VFSItem o2) {
            return c.compare(o1.getName(), o2.getName());
        }
    });
    boolean addedAtLeastOneChild = false;
    for (Iterator<VFSItem> iter = children.iterator(); iter.hasNext(); ) {
        VFSItem child = iter.next();
        String childName = child.getName();
        if (child instanceof VFSContainer) {
            // container node
            String filePath = parentPath + childName + "/";
            // filePath is the information to be remembered later
            GenericTreeNode tChild = new GenericTreeNode(childName, filePath);
            tChild.setIconCssClass("o_filetype_folder");
            tChild.setAltText(child.getName());
            tChild.setAccessible(selectableFolders ? (child.canWrite() == VFSConstants.YES) : false);
            tParent.addChild(tChild);
            boolean addedChildren = buildTree(tChild, (VFSContainer) child, filePath);
            if (foldersOnly || addedChildren) {
                addedAtLeastOneChild = true;
            } else {
                // this directory does not contain anything usefull, remove it again!
                tParent.remove(tChild);
            }
        } else {
            // leaf node
            if (foldersOnly)
                continue;
            String filePath = parentPath + childName;
            GenericTreeNode tChild = new GenericTreeNode(childName, filePath);
            String type = FolderHelper.extractFileType(childName, locale);
            if (!FolderHelper.isKnownFileType(type)) {
                type = "file";
            }
            tChild.setIconCssClass("o_filetype_" + type);
            tChild.setAltText(childName);
            tChild.setAccessible(selectableFiles);
            tParent.addChild(tChild);
            addedAtLeastOneChild = true;
        }
    }
    return addedAtLeastOneChild;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Collator(java.text.Collator)

Example 3 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

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;
}
Also used : Extension(org.olat.core.extensions.Extension) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ExtManager(org.olat.core.extensions.ExtManager) ActionExtension(org.olat.core.extensions.action.ActionExtension) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Example 4 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class AssessmentHelper method addAssessableNodesToList.

private static List<GenericTreeNode> addAssessableNodesToList(CourseNode parentCourseNode) {
    List<GenericTreeNode> result = new ArrayList<>();
    for (int i = 0; i < parentCourseNode.getChildCount(); i++) {
        CourseNode courseNode = (CourseNode) parentCourseNode.getChildAt(i);
        List<GenericTreeNode> assessableChildren = addAssessableNodesToList(courseNode);
        if (assessableChildren.size() > 0 || isAssessable(courseNode)) {
            GenericTreeNode node = new GenericTreeNode();
            node.setTitle(courseNode.getShortTitle());
            node.setUserObject(courseNode);
            CourseNodeConfiguration nodeconfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
            node.setIconCssClass(nodeconfig.getIconCSSClass());
            result.add(node);
            assessableChildren.forEach((child) -> node.addChild(child));
        }
    }
    return result;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ArrayList(java.util.ArrayList) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 5 with GenericTreeNode

use of org.olat.core.gui.components.tree.GenericTreeNode in project OpenOLAT by OpenOLAT.

the class CourseNodeSelectionTreeModel method buildTree.

private TreeNode buildTree(CourseNode courseNode) {
    GenericTreeNode node = new GenericTreeNode(courseNode.getIdent(), courseNode.getShortTitle(), courseNode);
    node.setIconCssClass(("o_icon o_" + courseNode.getType() + "_icon").intern());
    node.setAltText(courseNode.getLongTitle());
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode childNode = (CourseNode) courseNode.getChildAt(i);
        node.addChild(buildTree(childNode));
    }
    return node;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CourseNode(org.olat.course.nodes.CourseNode)

Aggregations

GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)124 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 CourseNode (org.olat.course.nodes.CourseNode)10 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)10 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)10 HashMap (java.util.HashMap)8 INode (org.olat.core.util.nodes.INode)8 ArrayList (java.util.ArrayList)6 Element (org.dom4j.Element)6 XPath (org.dom4j.XPath)6 ExtManager (org.olat.core.extensions.ExtManager)6 Extension (org.olat.core.extensions.Extension)6 CatalogEntry (org.olat.repository.CatalogEntry)6 ActionExtension (org.olat.core.extensions.action.ActionExtension)4 GenericActionExtension (org.olat.core.extensions.action.GenericActionExtension)4 CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)4 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4