Search in sources :

Example 16 with EPAbstractMap

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

the class EPTOCController method refreshAddElements.

/**
 * refreshing the add elements link to actual structure
 * @param ureq
 * @param struct maybe null -> hiding the add-button
 */
private void refreshAddElements(UserRequest ureq, PortfolioStructure struct) {
    tocV.remove(tocV.getComponent("addElement"));
    removeAsListenerAndDispose(addElCtrl);
    if (struct != null) {
        addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
        if (struct instanceof EPPage) {
            if (secCallback.canAddStructure()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
            }
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        } else if (struct instanceof EPAbstractMap) {
            if (secCallback.canAddPage()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
            }
        } else {
            // its a structure element
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        }
        listenTo(addElCtrl);
        tocV.put("addElement", addElCtrl.getInitialComponent());
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPAddElementsController(org.olat.portfolio.ui.structel.EPAddElementsController)

Example 17 with EPAbstractMap

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

Example 18 with EPAbstractMap

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

the class EPCollectStepForm04 method formOK.

/**
 * @see org.olat.core.gui.control.generic.wizard.StepFormBasicController#formOK(org.olat.core.gui.UserRequest)
 */
@Override
protected void formOK(UserRequest ureq) {
    PortfolioStructure selectedPortfolioStructure = preSelectedStructure;
    TreeNode node = mapsTreeController == null ? null : mapsTreeController.getSelectedNode();
    if (node != null) {
        Object obj = node.getUserObject();
        if (obj == null) {
            selectedPortfolioStructure = null;
        } else if (obj instanceof PortfolioStructure && !(obj instanceof EPAbstractMap)) {
            selectedPortfolioStructure = (PortfolioStructure) obj;
        }
    }
    if (selectedPortfolioStructure != null) {
        ePFMgr.setUsersLastUsedPortfolioStructure(getIdentity(), selectedPortfolioStructure);
    }
    if (isUsedInStepWizzard()) {
        addToRunContext("selectedStructure", selectedPortfolioStructure);
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else {
        if (selectedPortfolioStructure != null && !selectedPortfolioStructure.getKey().equals(oldStructure.getKey())) {
            ePFMgr.moveArtefactFromStructToStruct(artefact, oldStructure, selectedPortfolioStructure);
            // refresh ui
            fireEvent(ureq, new EPStructureChangeEvent(EPStructureChangeEvent.CHANGED, selectedPortfolioStructure));
        }
    }
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) TreeNode(org.olat.core.gui.components.tree.TreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPStructureChangeEvent(org.olat.portfolio.ui.structel.EPStructureChangeEvent)

Aggregations

EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)18 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)12 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 EPPage (org.olat.portfolio.model.structel.EPPage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 StringWriter (java.io.StringWriter)2 Writer (java.io.Writer)2 ZipInputStream (java.util.zip.ZipInputStream)2 Transformer (javax.xml.transform.Transformer)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 StreamResult (javax.xml.transform.stream.StreamResult)2 StreamSource (javax.xml.transform.stream.StreamSource)2 CommentAndRatingService (org.olat.core.commons.services.commentAndRating.CommentAndRatingService)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 Link (org.olat.core.gui.components.link.Link)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2