Search in sources :

Example 66 with EPStructureElement

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

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)

Aggregations

EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)66 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)18 EPStructureToStructureLink (org.olat.portfolio.model.structel.EPStructureToStructureLink)16 EPStructureToArtefactLink (org.olat.portfolio.model.structel.EPStructureToArtefactLink)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)8 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)8 EPPage (org.olat.portfolio.model.structel.EPPage)8 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)6 Identity (org.olat.core.id.Identity)4 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2