Search in sources :

Example 6 with EPPage

use of org.olat.portfolio.model.structel.EPPage 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 7 with EPPage

use of org.olat.portfolio.model.structel.EPPage 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 8 with EPPage

use of org.olat.portfolio.model.structel.EPPage in project openolat by klemens.

the class EPStructureManager method createPortfolioPage.

/**
 * Create a page element
 * @param title
 * @param description
 * @return The structure element
 */
protected PortfolioStructure createPortfolioPage(PortfolioStructure root, String title, String description) {
    EPPage el = new EPPage();
    el.setRoot((EPStructureElement) root);
    if (root != null && root.getRootMap() == null && root instanceof PortfolioStructureMap) {
        el.setRootMap((PortfolioStructureMap) root);
    } else if (root != null) {
        el.setRootMap(root.getRootMap());
    }
    return fillStructureElement(el, title, description);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPPage(org.olat.portfolio.model.structel.EPPage)

Example 9 with EPPage

use of org.olat.portfolio.model.structel.EPPage in project openolat by klemens.

the class EPFrontendManager method createAndPersistPortfolioPage.

/**
 * create a page
 * @param root
 * @param title
 * @param description
 * @return
 */
public PortfolioStructure createAndPersistPortfolioPage(PortfolioStructure root, String title, String description) {
    EPPage newPage = (EPPage) structureManager.createPortfolioPage(root, title, description);
    if (root != null)
        structureManager.addStructureToStructure(root, newPage, -1);
    structureManager.savePortfolioStructure(newPage);
    return newPage;
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage)

Example 10 with EPPage

use of org.olat.portfolio.model.structel.EPPage in project openolat by klemens.

the class EPMapViewController 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
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (event instanceof EPStructureChangeEvent && event.getCommand().equals(EPStructureChangeEvent.ADDED)) {
        EPStructureChangeEvent changeEvent = (EPStructureChangeEvent) event;
        PortfolioStructure structure = changeEvent.getPortfolioStructure();
        // don't do reloadMapAndRefreshUI(ureq) here; no db-commit yet! no refresh -> stale object!
        if (structure instanceof EPPage) {
            // jump to the edit mode for new pages
            initOrUpdateEditMode(ureq, structure);
        }
    } else if (event instanceof EPStructureEvent && event.getCommand().equals(EPStructureEvent.CHANGE)) {
        // reload map
        reloadMapAndRefreshUI(ureq);
    } else if (source == editCtrl && event.equals(Event.CHANGED_EVENT)) {
        // refresh view on changes in TOC or style
        reloadMapAndRefreshUI(ureq);
        PortfolioStructure selectedPage = editCtrl.getSelectedStructure();
        initOrUpdateEditMode(ureq, selectedPage);
    } else if (source == confirmationSubmissionCtr) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            doSubmitAssess(ureq);
        }
    }
    // fire to multiple maps controller, so it can refresh itself!
    fireEvent(ureq, event);
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Aggregations

EPPage (org.olat.portfolio.model.structel.EPPage)24 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)16 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)8 ArrayList (java.util.ArrayList)4 Link (org.olat.core.gui.components.link.Link)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)4 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)4 Test (org.junit.Test)2 UserComment (org.olat.core.commons.services.commentAndRating.model.UserComment)2 UserCommentsCount (org.olat.core.commons.services.commentAndRating.model.UserCommentsCount)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Identity (org.olat.core.id.Identity)2 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)2 EPAddElementsController (org.olat.portfolio.ui.structel.EPAddElementsController)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 OLATResource (org.olat.resource.OLATResource)2