Search in sources :

Example 66 with AbstractArtefact

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

the class EPAddArtefactController method prepareNewTextArtefactWizzard.

/**
 * prepare a new text artefact and open with wizzard initialized with a
 * special first step for text-artefacts
 *
 * @param ureq
 */
private void prepareNewTextArtefactWizzard(UserRequest ureq) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EPTextArtefact.TEXT_ARTEFACT_TYPE);
    AbstractArtefact artefact1 = artHandler.createArtefact();
    artefact1.setAuthor(getIdentity());
    artefact1.setSource(translate("text.artefact.source.info"));
    artefact1.setCollectionDate(new Date());
    artefact1.setSignature(-20);
    vfsTemp = ePFMgr.getArtefactsTempContainer(getIdentity());
    Step start = new EPCreateTextArtefactStep00(ureq, artefact1, preSelectedStruct, vfsTemp);
    StepRunnerCallback finish = new EPArtefactWizzardStepCallback(vfsTemp);
    collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.text.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_text_wizard");
    listenTo(collectStepsCtrl);
    getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) Date(java.util.Date) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Example 67 with AbstractArtefact

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

the class EPMultipleArtefactSmallReadOnlyPreviewController method init.

private void init(UserRequest ureq) {
    if (artefactCtrls != null)
        disposeArtefactControllers();
    if (optionLinkCtrls != null)
        disposeOptionLinkControllers();
    optionLinkCtrls = new ArrayList<Controller>();
    artefactCtrls = new ArrayList<Controller>();
    List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
    List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
    int i = 1;
    for (AbstractArtefact artefact : artefacts) {
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
        Controller artCtrl;
        // check for special art-display:
        boolean special = artHandler.isProvidingSpecialMapViewController();
        if (special) {
            artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
            if (artCtrl != null) {
                // add the optionsLink to the artefact
                EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
                vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
                listenTo(optionsLinkCtrl);
                optionLinkCtrls.add(optionsLinkCtrl);
            }
        } else {
            artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
        }
        if (artCtrl != null) {
            artefactCtrls.add(artCtrl);
            Component artefactCtrlComponent = artCtrl.getInitialComponent();
            listenTo(artCtrl);
            Panel namedPanel = new Panel("artCtrl" + i);
            namedPanel.setContent(artefactCtrlComponent);
            if (special) {
                if (!artefactCtrlCompLine.isEmpty()) {
                    artefactCtrlCompLines.add(artefactCtrlCompLine);
                }
                artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
                artefactCtrlCompLine = new ArrayList<Panel>();
            } else {
                if (artefactCtrlCompLine.size() == 3) {
                    if (!artefactCtrlCompLine.isEmpty()) {
                        artefactCtrlCompLines.add(artefactCtrlCompLine);
                    }
                    artefactCtrlCompLine = new ArrayList<Panel>();
                }
                artefactCtrlCompLine.add(namedPanel);
            }
            vC.put("artCtrl" + i, namedPanel);
            if (special) {
                // need a flag in a lopp for the velociy template
                vC.put("specialartCtrl" + i, artefactCtrlComponent);
            }
            i++;
        }
    }
    if (!artefactCtrlCompLine.isEmpty()) {
        artefactCtrlCompLines.add(artefactCtrlCompLine);
    }
    vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
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) Panel(org.olat.core.gui.components.panel.Panel) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.olat.core.gui.components.Component)

Example 68 with AbstractArtefact

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

the class EPMultipleArtefactsAsTableController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    OLATResourceable ores = entries.get(0).getOLATResourceable();
    if ("AbstractArtefact".equals(ores.getResourceableTypeName())) {
        Long resId = ores.getResourceableId();
        ArtefactTableDataModel model = (ArtefactTableDataModel) artefactListTblCtrl.getTableDataModel();
        for (int i = 0; i < model.getRowCount(); i++) {
            AbstractArtefact artefact = model.getObject(i);
            if (artefact.getKey().equals(resId)) {
                int artefactsPerPage = artefactListTblCtrl.getPageSize();
                int rest = (i % artefactsPerPage);
                int page = (i - rest) / artefactsPerPage;
                artefactListTblCtrl.setPage(new Integer(page + 1));
                break;
            }
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 69 with AbstractArtefact

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

the class EPTagBrowseController 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) {
    // nothing
    if (tagLinks.contains(source)) {
        Link tagLink = (Link) source;
        TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
        if (TagState.possible.equals(tagWrapper.getState())) {
            tagWrapper.setState(TagState.selected);
            List<AbstractArtefact> artefacts = recalculateTagCloud();
            fireEvent(ureq, new EPTagBrowseEvent(artefacts));
        } else if (TagState.selected.equals(tagWrapper.getState())) {
            tagWrapper.setState(TagState.possible);
            List<AbstractArtefact> artefacts = recalculateTagCloud();
            fireEvent(ureq, new EPTagBrowseEvent(artefacts));
        }
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList) List(java.util.List) Link(org.olat.core.gui.components.link.Link)

Example 70 with AbstractArtefact

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

the class EPStructureElementsController 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)
 */
protected void initForm(UserRequest ureq) {
    flc.contextPut("structElements", structElements);
    tableCtrls = new ArrayList<Controller>();
    addBtnCtrls = new ArrayList<Controller>();
    int i = 1;
    removeComponents();
    for (PortfolioStructure portStruct : structElements) {
        if (secCallback.isRestrictionsEnabled()) {
            List<CollectRestriction> restrictions = portStruct.getCollectRestrictions();
            if (!restrictions.isEmpty()) {
                boolean check = ePFMgr.checkCollectRestriction(portStruct);
                EPCollectRestrictionResultController resultCtrl = new EPCollectRestrictionResultController(ureq, getWindowControl());
                resultCtrl.setMessage(portStruct.getCollectRestrictions(), check);
                flc.put("checkResults" + i, resultCtrl.getInitialComponent());
                listenTo(resultCtrl);
            }
        }
        // get artefacts for this structure
        List<AbstractArtefact> artefacts = ePFMgr.getArtefacts(portStruct);
        if (artefacts.size() != 0) {
            EPMultiArtefactsController artefactCtrl = EPUIFactory.getConfigDependentArtefactsControllerForStructure(ureq, getWindowControl(), artefacts, portStruct, secCallback);
            flc.put("artefacts" + i, artefactCtrl.getInitialComponent());
            listenTo(artefactCtrl);
            tableCtrls.add(artefactCtrl);
        }
        if (!parentMapClosed && secCallback.canAddArtefact()) {
            // get an addElement-button for each structure
            EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), portStruct);
            listenTo(addButton);
            addButton.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            flc.put("addButton" + i, addButton.getInitialComponent());
            addBtnCtrls.add(addButton);
        }
        i++;
    }
    if (i != maxStructAmount)
        maxStructAmount = i;
}
Also used : EPCollectRestrictionResultController(org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController) EPMultiArtefactsController(org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) Controller(org.olat.core.gui.control.Controller) EPMultiArtefactsController(org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController) BasicController(org.olat.core.gui.control.controller.BasicController) EPCollectRestrictionResultController(org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController)

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