Search in sources :

Example 1 with MediaEvent

use of org.olat.modules.portfolio.ui.event.MediaEvent in project OpenOLAT by OpenOLAT.

the class MediaCenterController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (mediaUploadCtrl == source || textUploadCtrl == source || citationUploadCtrl == source) {
        if (event == Event.DONE_EVENT) {
            loadModel();
            tableEl.reloadData();
        }
        cmc.deactivate();
        cleanUp();
        if (select || event == Event.DONE_EVENT) {
            if (mediaUploadCtrl == source) {
                doSelect(ureq, mediaUploadCtrl.getMediaReference().getKey());
            } else if (textUploadCtrl == source) {
                doSelect(ureq, textUploadCtrl.getMediaReference().getKey());
            } else if (citationUploadCtrl == source) {
                doSelect(ureq, citationUploadCtrl.getMediaReference().getKey());
            }
        }
    } else if (importArtefactv1Ctrl == source) {
        Media media = null;
        if (event instanceof EPArtefactChoosenEvent) {
            EPArtefactChoosenEvent cEvent = (EPArtefactChoosenEvent) event;
            media = doImportArtefactV1(cEvent.getArtefact());
            loadModel();
            tableEl.reloadData();
        } else if (event instanceof EPArtefactListChoosenEvent) {
            EPArtefactListChoosenEvent cmEvent = (EPArtefactListChoosenEvent) event;
            for (AbstractArtefact artefact : cmEvent.getArtefacts()) {
                media = doImportArtefactV1(artefact);
            }
            if (cmEvent.getArtefacts().size() > 1) {
                // only auto select a single media
                media = null;
            }
            loadModel();
            tableEl.reloadData();
            showInfo("message.imported.successfully", new String[] { Integer.toString(cmEvent.getArtefacts().size()) });
        }
        cmc.deactivate();
        cleanUp();
        if (select && media != null) {
            doSelect(ureq, media.getKey());
        }
    } else if (newMediasCtrl == source) {
        newMediasCalloutCtrl.deactivate();
        if ("add.file".equals(event.getCommand())) {
            doAddMedia(ureq, "add.file");
        } else if ("add.media".equals(event.getCommand())) {
            doAddMedia(ureq, "add.media");
        } else if ("add.text".equals(event.getCommand())) {
            doAddTextMedia(ureq);
        } else if ("add.citation".equals(event.getCommand())) {
            doAddCitationMedia(ureq);
        } else if ("import.artefactV1".equals(event.getCommand())) {
            doChooseArtefactV1(ureq);
        }
    } else if (detailsCtrl == source) {
        if (event instanceof MediaEvent) {
            MediaEvent me = (MediaEvent) event;
            if (MediaEvent.DELETED.equals(me.getCommand())) {
                stackPanel.popUpToController(this);
                loadModel();
                tableEl.reset(false, true, true);
            }
        }
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : MediaEvent(org.olat.modules.portfolio.ui.event.MediaEvent) Media(org.olat.modules.portfolio.Media) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) EPArtefactListChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactListChoosenEvent) EPArtefactChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactChoosenEvent)

Example 2 with MediaEvent

use of org.olat.modules.portfolio.ui.event.MediaEvent in project openolat by klemens.

the class MediaCenterController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (mediaUploadCtrl == source || textUploadCtrl == source || citationUploadCtrl == source) {
        if (event == Event.DONE_EVENT) {
            loadModel();
            tableEl.reloadData();
        }
        cmc.deactivate();
        cleanUp();
        if (select || event == Event.DONE_EVENT) {
            if (mediaUploadCtrl == source) {
                doSelect(ureq, mediaUploadCtrl.getMediaReference().getKey());
            } else if (textUploadCtrl == source) {
                doSelect(ureq, textUploadCtrl.getMediaReference().getKey());
            } else if (citationUploadCtrl == source) {
                doSelect(ureq, citationUploadCtrl.getMediaReference().getKey());
            }
        }
    } else if (importArtefactv1Ctrl == source) {
        Media media = null;
        if (event instanceof EPArtefactChoosenEvent) {
            EPArtefactChoosenEvent cEvent = (EPArtefactChoosenEvent) event;
            media = doImportArtefactV1(cEvent.getArtefact());
            loadModel();
            tableEl.reloadData();
        } else if (event instanceof EPArtefactListChoosenEvent) {
            EPArtefactListChoosenEvent cmEvent = (EPArtefactListChoosenEvent) event;
            for (AbstractArtefact artefact : cmEvent.getArtefacts()) {
                media = doImportArtefactV1(artefact);
            }
            if (cmEvent.getArtefacts().size() > 1) {
                // only auto select a single media
                media = null;
            }
            loadModel();
            tableEl.reloadData();
            showInfo("message.imported.successfully", new String[] { Integer.toString(cmEvent.getArtefacts().size()) });
        }
        cmc.deactivate();
        cleanUp();
        if (select && media != null) {
            doSelect(ureq, media.getKey());
        }
    } else if (newMediasCtrl == source) {
        newMediasCalloutCtrl.deactivate();
        if ("add.file".equals(event.getCommand())) {
            doAddMedia(ureq, "add.file");
        } else if ("add.media".equals(event.getCommand())) {
            doAddMedia(ureq, "add.media");
        } else if ("add.text".equals(event.getCommand())) {
            doAddTextMedia(ureq);
        } else if ("add.citation".equals(event.getCommand())) {
            doAddCitationMedia(ureq);
        } else if ("import.artefactV1".equals(event.getCommand())) {
            doChooseArtefactV1(ureq);
        }
    } else if (detailsCtrl == source) {
        if (event instanceof MediaEvent) {
            MediaEvent me = (MediaEvent) event;
            if (MediaEvent.DELETED.equals(me.getCommand())) {
                stackPanel.popUpToController(this);
                loadModel();
                tableEl.reset(false, true, true);
            }
        }
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : MediaEvent(org.olat.modules.portfolio.ui.event.MediaEvent) Media(org.olat.modules.portfolio.Media) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) EPArtefactListChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactListChoosenEvent) EPArtefactChoosenEvent(org.olat.portfolio.ui.artefacts.view.EPArtefactChoosenEvent)

Aggregations

Media (org.olat.modules.portfolio.Media)2 MediaEvent (org.olat.modules.portfolio.ui.event.MediaEvent)2 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)2 EPArtefactChoosenEvent (org.olat.portfolio.ui.artefacts.view.EPArtefactChoosenEvent)2 EPArtefactListChoosenEvent (org.olat.portfolio.ui.artefacts.view.EPArtefactListChoosenEvent)2