Search in sources :

Example 71 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPTOCController method doSelectTreeElement.

private void doSelectTreeElement(UserRequest ureq, TreeEvent te) {
    TreeNode selectedNode = treeCtr.getTreeModel().getNodeById(te.getNodeId());
    Object userObj = selectedNode.getUserObject();
    if (userObj instanceof PortfolioStructure) {
        // structure clicked
        structureClicked = (PortfolioStructure) userObj;
        refreshAddElements(ureq, structureClicked);
        delButton.setVisible(true);
        // send event to load this page
        fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.SELECTED, structureClicked));
    } else if (userObj instanceof AbstractArtefact) {
        // artefact clicked
        Object parentObj = ((TreeNode) selectedNode.getParent()).getUserObject();
        if (parentObj instanceof PortfolioStructure) {
            artefactClicked = (AbstractArtefact) userObj;
            PortfolioStructure structure = (PortfolioStructure) parentObj;
            refreshAddElements(ureq, null);
            delButton.setVisible(true);
            fireEvent(ureq, new EPArtefactClicked(ARTEFACT_NODE_CLICKED, structure));
        }
    } else {
        // root tree node clicked, no add/delete link
        delButton.setVisible(false);
        refreshAddElements(ureq, null);
        fireEvent(ureq, new Event(ARTEFACT_NODE_CLICKED));
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) Event(org.olat.core.gui.control.Event) EPStructureChangeEvent(org.olat.portfolio.ui.structel.EPStructureChangeEvent) EPStructureChangeEvent(org.olat.portfolio.ui.structel.EPStructureChangeEvent) EPArtefactClicked(org.olat.portfolio.ui.structel.EPArtefactClicked)

Example 72 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPTOCTreeModel method checkArtefactTarget.

private boolean checkArtefactTarget(Object droppedParentObj, AbstractArtefact artefact, Object targetObj, Object targetParentObj, boolean sibling) {
    PortfolioStructure newParStruct;
    if (targetObj instanceof EPAbstractMap) {
        return false;
    } else if (targetObj instanceof PortfolioStructure) {
        newParStruct = (PortfolioStructure) targetObj;
    } else if (sibling) {
        if (targetObj instanceof AbstractArtefact && targetParentObj instanceof PortfolioStructure) {
            if (droppedParentObj != null && droppedParentObj.equals(targetParentObj)) {
                // reorder
                return true;
            } else {
                newParStruct = (PortfolioStructure) targetParentObj;
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
    boolean sameTarget = ePFMgr.isArtefactInStructure(artefact, newParStruct);
    if (sameTarget) {
        return false;
    }
    return true;
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 73 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPMultipleArtefactPreviewController method preparePaging.

private void preparePaging(UserRequest ureq, int actualPage) {
    int nrOfArtefacts = artefactsFullList.size();
    vC.contextPut("artefactAmnt", Integer.toString(nrOfArtefacts));
    if (nrOfArtefacts > artefactsPerPage) {
        int divRest = (nrOfArtefacts % artefactsPerPage);
        int nrOfPages = (nrOfArtefacts / artefactsPerPage) + (divRest > 0 ? 1 : 0);
        ArrayList<Link> pageLinkList = new ArrayList<Link>();
        for (int i = 1; i < nrOfPages + 1; i++) {
            Link pageLink = LinkFactory.createCustomLink("pageLink" + i, "pageLink" + i, String.valueOf(i), Link.LINK + Link.NONTRANSLATED, vC, this);
            pageLink.setUserObject(i);
            if (actualPage == i)
                pageLink.setEnabled(false);
            pageLinkList.add(pageLink);
        }
        int fromIndex = (actualPage - 1) * artefactsPerPage;
        int toIndex = actualPage * artefactsPerPage;
        if (toIndex > nrOfArtefacts)
            toIndex = nrOfArtefacts;
        List<AbstractArtefact> artefactsToShow = artefactsFullList.subList(fromIndex, toIndex);
        vC.contextPut("pageLinkList", pageLinkList);
        initOrUpdateArtefactControllers(ureq, artefactsToShow);
    } else {
        // no paging needed
        vC.contextRemove("pageLinkList");
        initOrUpdateArtefactControllers(ureq, artefactsFullList);
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Link(org.olat.core.gui.components.link.Link)

Example 74 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPMultipleArtefactPreviewController method initOrUpdateArtefactControllers.

/**
 * @param ureq
 * @param wControl
 * @param artefacts
 */
private void initOrUpdateArtefactControllers(UserRequest ureq, List<AbstractArtefact> artefacts) {
    vC.contextPut("artefacts", artefacts);
    if (artefactCtrls != null)
        disposeArtefactControllers();
    artefactCtrls = new ArrayList<Controller>();
    ArrayList<Component> artefactCtrlComps = new ArrayList<Component>();
    int i = 1;
    getArtefactAttributeDisplayConfig(ureq.getIdentity());
    if (artefacts != null) {
        for (AbstractArtefact abstractArtefact : artefacts) {
            Controller artCtrl = new EPArtefactViewController(ureq, getWindowControl(), abstractArtefact, artAttribConfig, artefactChooseMode, false, true);
            artefactCtrls.add(artCtrl);
            Component artefactCtrlComponent = artCtrl.getInitialComponent();
            listenTo(artCtrl);
            artefactCtrlComps.add(artefactCtrlComponent);
            vC.put("artCtrl" + i, artefactCtrlComponent);
            i++;
        }
    }
    vC.contextPut("artefactCtrlComps", artefactCtrlComps);
}
Also used : ArrayList(java.util.ArrayList) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) Component(org.olat.core.gui.components.Component)

Example 75 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class ArtefactTypeImageCellRenderer method render.

/**
 * @see org.olat.core.gui.components.table.CustomCellRenderer#render(org.olat.core.gui.render.StringOutput, org.olat.core.gui.render.Renderer, java.lang.Object, java.util.Locale, int, java.lang.String)
 */
@Override
public void render(StringOutput sb, Renderer renderer, Object val, Locale locale, int alignment, String action) {
    if (val instanceof AbstractArtefact) {
        AbstractArtefact artefact = (AbstractArtefact) val;
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
        Translator handlerTrans = artHandler.getHandlerTranslator(translator);
        String handlerClass = PortfolioFilterController.HANDLER_PREFIX + artHandler.getClass().getSimpleName() + PortfolioFilterController.HANDLER_TITLE_SUFFIX;
        String artType = handlerTrans.translate(handlerClass);
        String artIcon = artefact.getIcon();
        sb.append("<i class='o_icon o_icon-lg ").append(artIcon).append("' title=\"").append(artType).append("\"> </i>");
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Aggregations

AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)164 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)70 Test (org.junit.Test)54 ArrayList (java.util.ArrayList)36 Date (java.util.Date)20 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 DBQuery (org.olat.core.commons.persistence.DBQuery)10 Link (org.olat.core.gui.components.link.Link)10 Identity (org.olat.core.id.Identity)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)10 List (java.util.List)8 EPFilterSettings (org.olat.portfolio.model.EPFilterSettings)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 Step (org.olat.core.gui.control.generic.wizard.Step)6 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)6 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6