Search in sources :

Example 51 with PortfolioStructure

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

the class MapsTreeModel method loadStructure.

private void loadStructure(PortfolioStructure struct, GenericTreeNode parentNode) {
    String ident = struct.getKey().toString();
    GenericTreeNode structureNode = new GenericTreeNode(ident, struct.getTitle(), struct);
    structureNode.setIconCssClass(struct.getIcon());
    parentNode.addChild(structureNode);
    List<PortfolioStructure> structs = ePFMgr.loadStructureChildren(struct);
    for (PortfolioStructure childStruct : structs) {
        loadStructure(childStruct, structureNode);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 52 with PortfolioStructure

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

the class EPArtefactViewController method initForm.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (detailsLinkEnabled && !artefactChooseMode) {
        detailsLink = uifactory.addFormLink("details.link", formLayout, Link.BUTTON);
        detailsLink.setElementCssClass("o_sel_artefact_details");
    }
    title = uifactory.addInlineTextElement("title", artefact.getTitle(), formLayout, this);
    flc.contextPut("cssClosed", artefactInClosedMap ? "o_artefact_closed" : "");
    flc.contextPut("viewOnly", viewOnlyMode);
    if (viewOnlyMode || artefactInClosedMap)
        title.setEnabled(false);
    // get tags and prepare textboxlist-component
    List<String> tagL = ePFMgr.getArtefactTags(artefact);
    Map<String, String> tagLM = new HashMap<String, String>();
    for (String tag : tagL) {
        tagLM.put(tag, tag);
    }
    tblE = uifactory.addTextBoxListElement("tagTextbox", null, "tag.textboxlist.hint", tagLM, formLayout, getTranslator());
    if (viewOnlyMode || artefactInClosedMap) {
        tblE.setEnabled(false);
    } else {
        Map<String, String> allUsersTags = ePFMgr.getUsersMostUsedTags(getIdentity(), -1);
        tblE.setAutoCompleteContent(allUsersTags);
    }
    // get maps wherein this artefact is linked and create links to them
    List<PortfolioStructure> linkedMaps = ePFMgr.getReferencedMapsForArtefact(artefact);
    if (linkedMaps != null && linkedMaps.size() != 0) {
        List<FormLink> selectMapNames = new ArrayList<FormLink>(linkedMaps.size());
        int count = 0;
        for (PortfolioStructure ePMap : linkedMaps) {
            String mapTitle = StringHelper.escapeHtml(ePMap.getTitle());
            FormLink selectMap = uifactory.addFormLink("map-" + count++, "map", mapTitle, null, formLayout, Link.NONTRANSLATED);
            selectMap.setUserObject(ePMap.getOlatResource());
            selectMap.setEnabled(!viewOnlyMode && !artefactChooseMode);
            selectMapNames.add(selectMap);
        }
        flc.contextPut("maps", selectMapNames);
    }
    // build link to original source
    if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
        String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
        flc.contextPut("artefactSourceLink", sourceLink);
    }
    // create a delete button
    deleteBtn = uifactory.addFormLink("delete.artefact", formLayout, Link.BUTTON);
    deleteBtn.setIconLeftCSS("o_icon o_icon_delete");
    deleteBtn.addActionListener(FormEvent.ONCLICK);
    if (viewOnlyMode || artefactChooseMode || artefactInClosedMap)
        deleteBtn.setVisible(false);
    // let the artefact-handler paint what is special for this kind of artefact
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
    Controller detCtrl = artHandler.createDetailsController(ureq, getWindowControl(), artefact, viewOnlyMode || artefactInClosedMap);
    if (detCtrl != null) {
        flc.put("detailsController", detCtrl.getInitialComponent());
    }
    // create edit buttons the adapt meta-data
    if (!(viewOnlyMode || artefactChooseMode || artefactInClosedMap)) {
        String reflexion = artefact.getReflexion();
        reflexion = FilterFactory.getHtmlTagAndDescapingFilter().filter(reflexion);
        reflexion = StringHelper.xssScan(reflexion);
        reflexion = Formatter.truncate(reflexion, 50);
        if (!StringHelper.containsNonWhitespace(reflexion)) {
            // show a link even if empty
            reflexion = "&nbsp; ";
        }
        reflexionBtn = uifactory.addFormLink("reflexionBtn", reflexion, null, formLayout, Link.NONTRANSLATED);
        reflexionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
        String description = artefact.getDescription();
        description = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
        description = Formatter.truncate(description, 50);
        description = StringHelper.xssScan(description);
        if (!StringHelper.containsNonWhitespace(description)) {
            // show a link even if empty
            description = "&nbsp; ";
        }
        descriptionBtn = uifactory.addFormLink("descriptionBtn", description, null, formLayout, Link.NONTRANSLATED);
        descriptionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
    }
    // if in artefactChooseMode, add an "choose this" button
    if (artefactChooseMode) {
        chooseBtn = uifactory.addFormLink("choose.artefact", formLayout, Link.BUTTON);
        chooseBtn.addActionListener(FormEvent.ONCLICK);
    }
    flc.contextPut("artefact", artefact);
    setArtAttribConfig(artAttribConfig);
}
Also used : HashMap(java.util.HashMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Controller(org.olat.core.gui.control.Controller) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)

Example 53 with PortfolioStructure

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

the class EPAddElementsController 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
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == linkArtefactLink) {
        popUpAddArtefactBox(ureq);
    } else if (source == addStructLink) {
        if (ADD_PAGE.equals(activeType)) {
            String title = translate("new.page.title");
            String description = translate("new.page.desc");
            PortfolioStructure newPage = ePFMgr.createAndPersistPortfolioPage(portfolioStructure, title, description);
            DBFactory.getInstance().commit();
            fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.ADDED, newPage));
        } else if (ADD_STRUCTUREELEMENT.equals(activeType)) {
            String title = translate("new.structure.title");
            String description = translate("new.structure.desc");
            PortfolioStructure newStruct = ePFMgr.createAndPersistPortfolioStructureElement(portfolioStructure, title, description);
            DBFactory.getInstance().commit();
            fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.ADDED, newStruct));
        } else if (ADD_PORTFOLIOSTRUCTURE.equals(activeType)) {
        // show tree-with maps to choose from
        }
    }
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 54 with PortfolioStructure

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

the class EPTOCTreeModel method loadChildNode.

protected void loadChildNode(PortfolioStructure structure, TreeNode structureNode) {
    structureNode.removeAllChildren();
    List<PortfolioStructure> structs = ePFMgr.loadStructureChildren(structure);
    for (PortfolioStructure portfolioStructure : structs) {
        loadNode(portfolioStructure, structureNode);
    }
    List<AbstractArtefact> artList = ePFMgr.getArtefacts(structure);
    for (AbstractArtefact artefact : artList) {
        String artefactIdent = structureNode.getIdent() + artefact.getKey().toString();
        GenericTreeNode artefactNode = new GenericTreeNode(artefactIdent, artefact.getTitle(), artefact);
        artefactNode.setIconCssClass("o_icon o_ep_artefact " + artefact.getIcon());
        structureNode.addChild(artefactNode);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 55 with PortfolioStructure

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

the class EPTOCReadOnlyController 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
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == artOnOffLink) {
        displayArtefactsInTOC = !displayArtefactsInTOC;
        artOnOffLink.setCustomDisplayText(translate("artOnOffLink." + !displayArtefactsInTOC));
        refreshTOC(ureq);
    } else if (source instanceof Link) {
        // could be a TOC-Link
        Link link = (Link) source;
        String cmd = link.getCommand();
        PortfolioStructure parentStruct = (PortfolioStructure) link.getUserObject();
        if (cmd.equals(LINK_CMD_OPEN_STRUCT)) {
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT, parentStruct));
        } else if (cmd.equals(LINK_CMD_OPEN_ARTEFACT)) {
            // open the parent structure
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT, parentStruct));
        } else if (cmd.equals(LINK_CMD_OPEN_COMMENTS)) {
            fireEvent(ureq, new EPStructureEvent(EPStructureEvent.SELECT_WITH_COMMENTS, parentStruct));
        }
    }
}
Also used : EPStructureEvent(org.olat.portfolio.ui.structel.EPStructureEvent) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Link(org.olat.core.gui.components.link.Link)

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