Search in sources :

Example 56 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPTOCReadOnlyController method buildTOCModel.

/**
 * builds the tocList recursively containing artefacts, pages and
 * struct-Elements
 *
 * @param pStruct
 * @param tocList
 *            list with TOCElement's to use in velocity
 * @param level
 * @param withArtefacts
 *            set false, to skip artefacts
 */
private void buildTOCModel(PortfolioStructure pStruct, List<TOCElement> tocList, int level) {
    level++;
    if (displayArtefactsInTOC) {
        List<AbstractArtefact> artList = ePFMgr.getArtefacts(pStruct);
        if (artList != null && artList.size() != 0) {
            for (AbstractArtefact artefact : artList) {
                String key = String.valueOf(artefact.getKey());
                String title = StringHelper.escapeHtml(artefact.getTitle());
                Link iconLink = LinkFactory.createCustomLink("arte_" + key, LINK_CMD_OPEN_ARTEFACT, "", Link.NONTRANSLATED, vC, this);
                iconLink.setIconRightCSS("o_icon o_icon_start");
                iconLink.setUserObject(pStruct);
                Link titleLink = LinkFactory.createCustomLink("arte_t_" + key, LINK_CMD_OPEN_ARTEFACT, title, Link.NONTRANSLATED, vC, this);
                titleLink.setUserObject(pStruct);
                TOCElement actualTOCEl = new TOCElement(level, "artefact", titleLink, iconLink, null, null);
                tocList.add(actualTOCEl);
            }
        }
    }
    List<PortfolioStructure> childs = ePFMgr.loadStructureChildren(pStruct);
    if (childs != null && childs.size() != 0) {
        for (PortfolioStructure portfolioStructure : childs) {
            String type = "";
            if (portfolioStructure instanceof EPPage) {
                type = CONST_FOR_VC_STYLE_PAGE;
            } else {
                // a structure element
                type = CONST_FOR_VC_STYLE_STRUCT;
            }
            String key = String.valueOf(portfolioStructure.getKey());
            String title = StringHelper.escapeHtml(portfolioStructure.getTitle());
            Link iconLink = LinkFactory.createCustomLink("portstruct" + key, LINK_CMD_OPEN_STRUCT, "", Link.NONTRANSLATED, vC, this);
            iconLink.setIconRightCSS("o_icon o_icon_start");
            iconLink.setUserObject(portfolioStructure);
            Link titleLink = LinkFactory.createCustomLink("portstruct_t_" + key, LINK_CMD_OPEN_STRUCT, title, Link.NONTRANSLATED, vC, this);
            titleLink.setUserObject(portfolioStructure);
            Link commentLink = null;
            if (portfolioStructure instanceof EPPage && secCallback.canCommentAndRate()) {
                UserCommentsCount comments = getUserCommentsCount(portfolioStructure);
                String count = comments == null ? "0" : comments.getCount().toString();
                String label = translate("commentLink", new String[] { count });
                commentLink = LinkFactory.createCustomLink("commentLink" + key, LINK_CMD_OPEN_COMMENTS, label, Link.NONTRANSLATED, vC, this);
                commentLink.setIconLeftCSS("o_icon o_icon_comments");
                commentLink.setUserObject(portfolioStructure);
            }
            // prefetch children to keep reference on them
            List<TOCElement> tocChildList = new ArrayList<TOCElement>();
            buildTOCModel(portfolioStructure, tocChildList, level);
            TOCElement actualTOCEl = new TOCElement(level, type, titleLink, iconLink, commentLink, tocChildList);
            tocList.add(actualTOCEl);
            if (tocChildList.size() != 0) {
                tocList.addAll(tocChildList);
            }
        }
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) Link(org.olat.core.gui.components.link.Link) UserCommentsCount(org.olat.core.commons.services.commentAndRating.model.UserCommentsCount)

Example 57 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPMapViewController method view.

public void view(UserRequest ureq) {
    PortfolioStructure currentEditedStructure = null;
    if (editCtrl != null) {
        removeAsListenerAndDispose(editCtrl);
        mainVc.remove(editCtrl.getInitialComponent());
        currentEditedStructure = editCtrl.getSelectedStructure();
    }
    initForm(ureq);
    editMode = EditMode.view;
    if (editButton != null) {
        editButton.setCustomDisplayText(translate("map.editButton.on"));
    }
    if (currentEditedStructure != null && pageCtrl != null) {
        EPPage page = getSelectedPage(currentEditedStructure);
        if (page != null) {
            pageCtrl.selectPage(ureq, page);
            addToHistory(ureq, page, null);
        }
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 58 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPMapViewController method edit.

public void edit(UserRequest ureq) {
    if (canEditStructure()) {
        removeAsListenerAndDispose(editCtrl);
        PortfolioStructure selectedPage = null;
        if (pageCtrl != null) {
            selectedPage = pageCtrl.getSelectedPage();
        }
        initOrUpdateEditMode(ureq, selectedPage);
        editMode = EditMode.editor;
    }
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 59 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPMapViewController method initForm.

protected void initForm(UserRequest ureq) {
    Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
    if (ownerIdentity != null) {
        DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
        mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
    }
    mainVc.contextPut("map", map);
    mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
    mainVc.remove(mainVc.getComponent("map.editButton"));
    if (secCallback.canEditStructure()) {
        editButton = LinkFactory.createButton("map.editButton", mainVc, this);
        editButton.setElementCssClass("o_sel_ep_edit_map");
        editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
        if (editMode == EditMode.view) {
            editButton.setCustomDisplayText(translate("map.editButton.on"));
        } else {
            editButton.setCustomDisplayText(translate("map.editButton.off"));
        }
    }
    if (back) {
        backLink = LinkFactory.createLinkBack(mainVc, this);
    }
    mainVc.remove(mainVc.getComponent("map.submit.assess"));
    if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
    }
    if (map instanceof EPStructuredMap) {
        EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
        RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
        if (repoEntry != null) {
            mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
            String url = Settings.getServerContextPathURI();
            url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
            mainVc.contextPut("courseLink", url);
        }
    }
    mainVc.remove(mainVc.getComponent("addButton"));
    if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
        if (secCallback.canAddPage()) {
            addButton.setShowLink(EPAddElementsController.ADD_PAGE);
        }
        mainVc.put("addButton", addButton.getInitialComponent());
        listenTo(addButton);
    }
    mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
    List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
    if (pageList != null && pageList.size() != 0) {
        // prepare to paint pages also
        removeAsListenerAndDispose(pageCtrl);
        pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
        mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
        listenTo(pageCtrl);
    } else if (mainVc.getComponent("pagesCtrl") != null) {
        mainVc.remove(mainVc.getComponent("pagesCtrl"));
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 60 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPMultiplePageController method setAndInitTOCPage.

/**
 * @param ureq
 */
private void setAndInitTOCPage(UserRequest ureq) {
    // this is the toc
    if (tocPageCtrl == null) {
        PageTab page = pageList.get(0);
        PortfolioStructure map = ePFMgr.loadStructureParent(page);
        tocPageCtrl = new EPTOCReadOnlyController(ureq, getWindowControl(), map, secCallback);
        listenTo(tocPageCtrl);
    } else {
        tocPageCtrl.refreshTOC(ureq);
    }
    disableLINK_LC(false);
    disableLink_TOC(true);
    currentActivePageCtrl = tocPageCtrl;
    addToHistory(ureq, OresHelper.createOLATResourceableType("TOC"), null);
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPTOCReadOnlyController(org.olat.portfolio.ui.structel.view.EPTOCReadOnlyController)

Aggregations

PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)236 Test (org.junit.Test)90 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)70 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)54 ArrayList (java.util.ArrayList)40 OLATResource (org.olat.resource.OLATResource)30 Identity (org.olat.core.id.Identity)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)22 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 EPPage (org.olat.portfolio.model.structel.EPPage)16 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)12 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)12 DBQuery (org.olat.core.commons.persistence.DBQuery)10 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)10 Date (java.util.Date)8 Document (org.apache.lucene.document.Document)8 Link (org.olat.core.gui.components.link.Link)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)8