Search in sources :

Example 96 with AbstractArtefact

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

the class EPTOCController 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 instanceof Link) {
        Link link = (Link) source;
        if (link.getCommand().equals(DELETE_LINK_CMD)) {
            if (artefactClicked != null) {
                AbstractArtefact artefact = artefactClicked;
                PortfolioStructure parentStruct = getArtefactParentStruct(artefactClicked);
                ePFMgr.removeArtefactFromStructure(artefact, parentStruct);
                // refresh the view
                fireEvent(ureq, Event.CHANGED_EVENT);
            } else if (structureClicked != null) {
                if ((structureClicked instanceof EPPage) && !(structureClicked instanceof EPAbstractMap)) {
                    PortfolioStructure ps = structureClicked;
                    while (ePFMgr.loadStructureParent(ps) != null) {
                        ps = ePFMgr.loadStructureParent(ps);
                    }
                    int childPages = ePFMgr.countStructureChildren(ps);
                    if (childPages > 1) {
                        eSTMgr.removeStructureRecursively(structureClicked);
                        // refresh the view
                        fireEvent(ureq, Event.CHANGED_EVENT);
                    } else {
                        showError("last.page.not.deletable");
                    }
                } else if (structureClicked instanceof EPStructureElement && !(structureClicked instanceof EPAbstractMap)) {
                    // structures should always be deletable
                    eSTMgr.removeStructureRecursively(structureClicked);
                    // refresh the view
                    fireEvent(ureq, Event.CHANGED_EVENT);
                } else {
                    showInfo("element.not.deletable");
                }
            }
        }
    } else if (source == treeCtr) {
        if (event instanceof TreeEvent) {
            TreeEvent te = (TreeEvent) event;
            if (MenuTree.COMMAND_TREENODE_CLICKED.equals(te.getCommand())) {
                doSelectTreeElement(ureq, te);
            }
        } else if (event instanceof TreeDropEvent) {
            TreeDropEvent te = (TreeDropEvent) event;
            doDrop(ureq, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild());
        }
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) EPPage(org.olat.portfolio.model.structel.EPPage) EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) Link(org.olat.core.gui.components.link.Link)

Example 97 with AbstractArtefact

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

the class EPTOCController method doDrop.

private void doDrop(UserRequest ureq, String droppedNodeId, String targetNodeId, boolean asChild) {
    TreeNode droppedNode = treeCtr.getTreeModel().getNodeById(droppedNodeId);
    TreeNode targetNode = treeCtr.getTreeModel().getNodeById(targetNodeId);
    if (droppedNode == null || targetNode == null)
        return;
    Object droppedObj = droppedNode.getUserObject();
    Object droppedParentObj = null;
    if (droppedNode.getParent() != null) {
        droppedParentObj = ((TreeNode) droppedNode.getParent()).getUserObject();
    }
    Object targetObj = targetNode.getUserObject();
    Object targetParentObj = null;
    if (targetNode.getParent() != null) {
        targetParentObj = ((TreeNode) targetNode.getParent()).getUserObject();
    }
    if (droppedObj instanceof AbstractArtefact) {
        AbstractArtefact artefact = (AbstractArtefact) droppedObj;
        if (checkArtefactTarget(artefact, targetObj)) {
            moveArtefactToNewParent(ureq, artefact, droppedParentObj, targetObj);
        } else if (targetParentObj != null && targetParentObj.equals(droppedParentObj)) {
            reorder(ureq, artefact, (TreeNode) targetNode.getParent(), targetObj);
        }
    } else if (droppedObj instanceof PortfolioStructure) {
        PortfolioStructure droppedStruct = (PortfolioStructure) droppedObj;
        if (checkStructureTarget(droppedStruct, droppedParentObj, targetObj, targetParentObj, asChild)) {
            if (asChild) {
                int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
                moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetObj, newPos);
            } else if (droppedParentObj != null && targetParentObj != null && droppedParentObj.equals(targetParentObj)) {
                int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
                moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetParentObj, newPos);
            } else {
                int newPos = TreeHelper.indexOfByUserObject(targetObj, (TreeNode) targetNode.getParent());
                moveStructureToNewParent(ureq, droppedStruct, droppedParentObj, targetParentObj, newPos);
            }
        }
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 98 with AbstractArtefact

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

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)

Example 99 with AbstractArtefact

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

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 100 with AbstractArtefact

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

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)

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