Search in sources :

Example 41 with TreeNode

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

the class CPOfflineReadableManager method writeOfflineCPStartHTMLFile.

/**
 * generates a html-file (_START_.html) that presents the given cp-content
 * (specified by its "_unzipped_"-dir). The resulting file is suitable for
 * offline reading of the cp.
 *
 * @param unzippedDir
 *            the directory that contains the unzipped CP
 */
private void writeOfflineCPStartHTMLFile(File unzippedDir) throws IOException {
    /* first, we do the menu-tree */
    File mani = new File(unzippedDir, FILENAME_IMSMANIFEST);
    LocalFileImpl vfsMani = new LocalFileImpl(mani);
    CPManifestTreeModel ctm = new CPManifestTreeModel(vfsMani, "");
    TreeNode root = ctm.getRootNode();
    // let's take the rootnode title as  page title
    this.rootTitle = root.getTitle();
    StringBuilder menuTreeSB = new StringBuilder();
    renderMenuTreeNodeRecursively(root, menuTreeSB, 0);
    // now put values to velocityContext
    VelocityContext ctx = new VelocityContext();
    ctx.put("menutree", menuTreeSB.toString());
    ctx.put("rootTitle", this.rootTitle);
    ctx.put("cpoff", DIRNAME_CPOFFLINEMENUMAT);
    StringWriter sw = new StringWriter();
    try {
        String template = FileUtils.load(CPOfflineReadableManager.class.getResourceAsStream("_content/cpofflinereadable.html"), "utf-8");
        boolean evalResult = velocityEngine.evaluate(ctx, sw, "cpexport", template);
        if (!evalResult)
            log.error("Could not evaluate velocity template for CP Export");
    } catch (Exception e) {
        log.error("Error while evaluating velovity template for CP Export", e);
    }
    File f = new File(unzippedDir, FILENAME_START);
    if (f.exists()) {
        FileUtils.deleteDirsAndFiles(f, false, true);
    }
    ExportUtil.writeContentToFile(FILENAME_START, sw.toString(), unzippedDir, "utf-8");
}
Also used : StringWriter(java.io.StringWriter) TreeNode(org.olat.core.gui.components.tree.TreeNode) VelocityContext(org.apache.velocity.VelocityContext) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) File(java.io.File) IOException(java.io.IOException)

Example 42 with TreeNode

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

the class CPDisplayController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == cpTree) {
        // TreeEvent.dito...
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent te = (TreeEvent) event;
            switchToPage(ureq, te);
        }
    } else if (source == cpComponent) {
        if (event instanceof NewInlineUriEvent) {
            NewInlineUriEvent nue = (NewInlineUriEvent) event;
            // adjust the tree selection to the current choice if found
            selectTreeNode(ureq, nue.getNewUri());
        }
    } else if (source == nextLink) {
        TreeNode nextUri = (TreeNode) nextLink.getUserObject();
        switchToPage(ureq, nextUri);
        if (cpTree != null) {
            cpTree.setSelectedNode(nextUri);
        }
        fireEvent(ureq, new TreeNodeEvent(nextUri));
    } else if (source == previousLink) {
        TreeNode previousUri = (TreeNode) previousLink.getUserObject();
        if (cpTree != null) {
            cpTree.setSelectedNode(previousUri);
        }
        switchToPage(ureq, previousUri);
        fireEvent(ureq, new TreeNodeEvent(previousUri));
    } else if (source == printLink) {
        selectPagesToPrint(ureq);
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) NewInlineUriEvent(org.olat.core.gui.components.htmlsite.NewInlineUriEvent)

Example 43 with TreeNode

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

the class DocumentPoolMainController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        if (taxonomyTree.getTreeModel().getRootNode().getChildCount() > 0) {
            doSelectTaxonomy(ureq);
        }
    } else {
        String resourceName = entries.get(0).getOLATResourceable().getResourceableTypeName();
        if ("Templates".equals(resourceName) || resourceName.startsWith("path=")) {
            TreeNode rootNode = taxonomyTree.getTreeModel().getRootNode();
            if (rootNode.getChildCount() > 0) {
                TaxonomyTreeNode node = (TaxonomyTreeNode) rootNode.getChildAt(0);
                if (node.getType() == TaxonomyTreeNodeType.templates) {
                    DocumentDirectoryController directoryCtrl = doSelectTemplatesDirectory(ureq, node);
                    if (directoryCtrl != null) {
                        taxonomyTree.setSelectedNode(node);
                        List<ContextEntry> subEntries = entries.subList(1, entries.size());
                        directoryCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
                    }
                }
            }
        } else if ("TaxonomyLevel".equalsIgnoreCase(resourceName)) {
            String levelKey = entries.get(0).getOLATResourceable().getResourceableId().toString();
            TaxonomyTreeNode node = (TaxonomyTreeNode) taxonomyTree.getTreeModel().getNodeById(levelKey);
            if (node != null) {
                DocumentPoolLevelController levelCtrl = doSelectTaxonomyLevel(ureq, node);
                if (levelCtrl != null) {
                    taxonomyTree.setSelectedNode(node);
                    List<ContextEntry> subEntries = entries.subList(1, entries.size());
                    levelCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
                }
            }
        }
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) List(java.util.List) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 44 with TreeNode

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

the class DocumentPoolMainController method doSelectTaxonomyLevel.

private DocumentPoolLevelController doSelectTaxonomyLevel(UserRequest ureq, TaxonomyTreeNode node) {
    if (isTaxonomyAdmin || node.isCanRead() || node.isCanWrite()) {
        TaxonomyLevel level = node.getTaxonomyLevel();
        SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
        TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(node, subscriptionCtx);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("TaxonomyLevel", node.getTaxonomyLevel().getKey());
        WindowControl bwControl = addToHistory(ureq, ores, null);
        DocumentPoolLevelController levelCtrl = new DocumentPoolLevelController(ureq, bwControl, level, node, secCallback);
        listenTo(levelCtrl);
        String displayName = level.getDisplayName();
        content.popUpToRootController(ureq);
        List<TreeNode> parentLines = TreeHelper.getTreePath(node);
        for (int i = 1; i < parentLines.size() - 1; i++) {
            TreeNode parent = parentLines.get(i);
            content.pushController(parent.getTitle(), null, parent);
        }
        content.pushController(displayName, levelCtrl);
        return levelCtrl;
    }
    return null;
}
Also used : TaxonomyVFSSecurityCallback(org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback) OLATResourceable(org.olat.core.id.OLATResourceable) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WindowControl(org.olat.core.gui.control.WindowControl)

Example 45 with TreeNode

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

the class QuestionPoolMainEditorController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    OLATResourceable resource = entries.get(0).getOLATResourceable();
    if ("QuestionItem".equalsIgnoreCase(resource.getResourceableTypeName())) {
        activateQuestionItem(ureq, resource.getResourceableId(), entries);
    } else {
        TreeNode rootNode = menuTree.getTreeModel().getRootNode();
        TreeNode node = TreeHelper.findNodeByResourceableUserObject(resource, rootNode);
        if (node == null) {
            node = TreeHelper.findNodeByUserObject(resource.getResourceableTypeName(), rootNode);
        }
        if (node != null) {
            List<ContextEntry> subEntries = entries.subList(1, entries.size());
            stackPanel.popUpToRootController(ureq);
            doSelectControllerTreeNode(ureq, node, subEntries, entries.get(0).getTransientState());
            menuTree.setSelectedNode(node);
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

TreeNode (org.olat.core.gui.components.tree.TreeNode)296 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)146 ArrayList (java.util.ArrayList)44 CourseNode (org.olat.course.nodes.CourseNode)38 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)32 ContextEntry (org.olat.core.id.context.ContextEntry)30 Controller (org.olat.core.gui.control.Controller)28 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)24 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 INode (org.olat.core.util.nodes.INode)20 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)20 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)20 ICourse (org.olat.course.ICourse)18 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)16 OLATResourceable (org.olat.core.id.OLATResourceable)16 List (java.util.List)14 TreeModel (org.olat.core.gui.components.tree.TreeModel)14 WindowControl (org.olat.core.gui.control.WindowControl)14 AssertException (org.olat.core.logging.AssertException)14